/* ============================================================
   FidePuntos + Tienda — Sistema de diseño basado en Orderry
   Azul principal #0053e2 · Open Sans · SaaS limpio
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

:root {
    --primary: #0053e2;
    --primary-hover: #004ca3;
    --primary-dark: #003795;
    --primary-light: #e8f4ff;
    --primary-lighter: #f8fbff;

    --text: #272624;
    --text-muted: #677489;
    --bg: #f3f4f6;
    --bg-card: #ffffff;
    --border: #e5e7eb;

    --green: #218838;
    --green-light: #e6f4ea;
    --amber: #febd1f;
    --amber-light: #fff7e0;
    --red: #f55052;
    --red-light: #fdeaea;
    --purple: #7c3aed;
    --purple-light: #f5f0ff;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
    --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Open Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }

/* ---------------- Layout app (sidebar) ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: #23272f;
    border-right: 1px solid #2f3540;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
}
.sidebar-brand {
    padding: 18px 20px;
    border-bottom: 1px solid #2f3540;
    display: flex; align-items: center; gap: 10px;
}
.sidebar-brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.sidebar-brand .brand-logo { width: 34px; height: 34px; border-radius: 8px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.sidebar-brand .brand-sub { font-size: 11px; color: rgba(255,255,255,.55); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.45); padding: 14px 12px 6px; font-weight: 600; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: #fff; font-weight: 600; font-size: 13px;
}
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link .ico { width: 20px; text-align: center; font-size: 15px; color: #fff; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px rgba(0,0,0,.15); }

.sidebar-footer { padding: 12px; border-top: 1px solid #2f3540; }
.sidebar-footer .user { display: flex; align-items: center; gap: 8px; padding: 6px; color: #fff; }
.sidebar-footer .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    padding: 12px 24px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 17px; }

.content { padding: 24px; flex: 1; }

/* ---------------- Cards ---------------- */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { color: var(--text-muted); font-size: 12px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Stat cards */
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat .delta { font-size: 12px; margin-top: 2px; }

/* ---------------- Botones ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; transition: .15s;
    text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-lighter); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #d43f41; color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #19692c; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------- Formularios ---------------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.input, select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
    background: #fff; color: var(--text); transition: .15s;
}
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,83,226,.12); }
textarea { resize: vertical; }
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 14px; }
.form-row > .form-group { flex: 1; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.input-search { position: relative; }
.input-search .input { padding-left: 36px; }
.input-search .search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* Switch (toggle) */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 24px; transition: .2s; }
.switch .slider:before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ---------------- Tablas ---------------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 700; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table tbody tr:hover { background: var(--primary-lighter); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-amber { background: var(--amber-light); color: #946200; }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-gray { background: #f3f4f6; color: var(--text-muted); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ---------------- Alertas ---------------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.alert-success { background: var(--green-light); color: var(--green); }
.alert-error { background: var(--red-light); color: var(--red); }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }
.alert-warning { background: var(--amber-light); color: #946200; }

/* ---------------- Modal ---------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: stretch; justify-content: flex-end; z-index: 100; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; width: min(50%, 660px); height: 100%; margin-left: 0; border-radius: 16px 0 0 16px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.modal-backdrop.open .modal { animation: modalSlideIn .28s ease; }
@keyframes modalSlideIn { from { transform: translateX(100%); opacity: .5; } to { transform: translateX(0); opacity: 1; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-body { padding: 20px; flex: 1; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; }

/* ---------------- Login (pantalla dividida) ---------------- */
.auth-split { display: flex; min-height: 100vh; }
.auth-side {
    flex: 1 1 50%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(150deg, #0a5cf0 0%, #0053e2 45%, #003795 100%);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 56px;
}
.auth-side .deco { position: absolute; border-radius: 50%; }
.auth-side .deco-1 { width: 480px; height: 480px; top: -160px; right: -140px; background: rgba(255,255,255,.08); }
.auth-side .deco-2 { width: 300px; height: 300px; bottom: -120px; left: -80px; background: rgba(255,255,255,.05); }
.auth-side-inner { position: relative; z-index: 1; max-width: 460px; width: 100%; }

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.auth-brand .logo { width: 46px; height: 46px; border-radius: 12px; background: #fff; color: var(--primary); font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.auth-brand-name { font-weight: 700; font-size: 18px; line-height: 1.2; }
.auth-brand-sub { font-size: 12px; color: rgba(255,255,255,.7); }

.auth-art-wrap { position: relative; margin: 10px 0 4px; }
.auth-art { width: 100%; max-width: 320px; height: auto; display: block; }
.auth-chip { position: absolute; background: #fff; color: var(--text); border-radius: 12px; padding: 8px 14px; font-weight: 700; font-size: 13px; box-shadow: 0 10px 24px rgba(0,0,0,.22); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.auth-chip b { color: var(--primary); }
.auth-chip.chip-1 { top: 6%; right: 4%; }
.auth-chip.chip-2 { bottom: 12%; left: 0; }

.auth-title { font-size: 24px; font-weight: 700; line-height: 1.25; margin: 16px 0 8px; }
.auth-copy { color: rgba(255,255,255,.85); font-size: 14px; margin: 0 0 4px; }
.auth-features { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-features li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: rgba(255,255,255,.95); }
.auth-features .check { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }

.auth-main { flex: 1 1 50%; background: #fff; display: flex; align-items: center; justify-content: center; padding: 48px; overflow-y: auto; }
.auth-box { width: 100%; max-width: 400px; }
.auth-mobile-logo { display: none; align-items: center; gap: 10px; margin-bottom: 24px; font-weight: 700; font-size: 18px; }
.auth-mobile-logo .logo { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.auth-heading { margin-bottom: 22px; }
.auth-heading h1 { font-size: 24px; margin: 0 0 4px; }
.auth-heading p { margin: 0; color: var(--text-muted); font-size: 14px; }

@media (max-width: 900px) {
    .auth-side { display: none; }
    .auth-mobile-logo { display: flex; }
    .auth-main { padding: 32px 24px; }
}

/* ---------------- Tienda publica ---------------- */
.store-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.store-header .inner { max-width: 1100px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.store-logo { display: flex; align-items: center; gap: 10px; }
.store-logo img, .store-logo .logo { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.store-logo .logo { background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.store-container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.product-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: .15s; }
.product-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.product-img { height: 170px; background: var(--primary-lighter); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 40px; overflow: hidden; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.product-price { color: var(--primary); font-weight: 700; font-size: 16px; }

.cart-side { position: sticky; top: 80px; }

/* ---------------- Ticket termico (impresion) ---------------- */
.ticket {
    width: 80mm; margin: 0 auto; background: #fff; padding: 0;
    font-family: 'Open Sans', sans-serif; font-size: 13px; color: #000; line-height: 1.4;
    box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.ticket .t-head {
    background: #000; color: #fff; text-align: center; padding: 12px 10px;
}
.ticket .t-logo { width: 46mm; max-height: 22mm; object-fit: contain; margin-bottom: 6px; }
.ticket .t-brand { font-size: 23px; font-weight: 900; line-height: 1.1; text-transform: uppercase; letter-spacing: .01em; }
.ticket .t-sub { font-size: 11px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; margin-top: 4px; }
.ticket .t-body { padding: 12px 10px; }
.ticket .t-divider { border-top: 2px solid #000; margin: 10px 0; }
.ticket .t-divider-thin { border-top: 1px dashed #000; margin: 6px 0; }
.ticket .t-title { font-size: 15px; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; text-align: center; margin-bottom: 4px; }
.ticket .t-muted { font-size: 11px; color: #000; font-weight: 700; }
.ticket table.t-rows { width: 100%; font-size: 14px; border-collapse: collapse; }
.ticket table.t-rows td { padding: 3px 0; vertical-align: top; font-weight: 700; }
.ticket table.t-rows td:first-child { font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .03em; }
.ticket table.t-rows td:last-child { text-align: right; font-weight: 900; word-break: break-word; }
.ticket .t-balance { text-align: center; padding: 8px 0; }
.ticket .t-balance-label { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .16em; }
.ticket .t-balance-points { font-size: 44px; font-weight: 900; line-height: 1; letter-spacing: .01em; }
.ticket .t-balance-points span { font-size: 18px; font-weight: 900; }
.ticket .t-balance-value { font-size: 17px; font-weight: 900; margin-top: 3px; }
.ticket .t-footer { text-align: center; margin-top: 8px; }
.ticket .t-thanks { font-weight: 900; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------------- Utilidades ---------------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.empty { text-align: center; color: var(--text-muted); padding: 40px 20px; }
.empty .ico { font-size: 40px; display: block; margin-bottom: 10px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.pill-search { font-size: 20px; padding: 14px 16px; }

/* ---------------- Ayuda ---------------- */
.help-hero { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-radius: var(--radius); padding: 22px 24px; display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.help-hero .muted { color: rgba(255,255,255,.85); }
.help-hero-ico { font-size: 40px; line-height: 1; }
.help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .help-grid { grid-template-columns: 1fr; } }
.help-card { padding: 18px 20px; }
.help-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.help-card-head h3 { margin: 0; }
.help-num { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.help-list { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.help-list li { padding-left: 20px; position: relative; color: var(--text); }
.help-list li::before { content: '▸'; position: absolute; left: 2px; color: var(--primary); font-weight: 700; }
.help-list code { background: var(--primary-lighter); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 12px; color: var(--primary-dark); }
.help-rule { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.help-rule-box { background: var(--primary-lighter); border: 1px solid var(--primary-light); color: var(--primary-dark); font-weight: 700; padding: 8px 14px; border-radius: 8px; font-size: 14px; }
.help-arrow { color: var(--text-muted); font-size: 18px; }
.help-card-accent { border-top: 3px solid var(--primary); }
.help-store-url { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--primary-lighter); border: 1px dashed var(--primary-light); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.help-store-url a { font-weight: 700; word-break: break-all; }
.help-footer { text-align: center; padding: 20px 0 4px; }

/* ---------------- Sub-tabs (Canjear / Venta rápida) ---------------- */
.sub-tabs { display: flex; gap: 8px; border-bottom: 2px solid var(--border); }
.sub-tab { background: transparent; border: none; padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: .15s; }
.sub-tab:hover { color: var(--primary); }
.sub-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Utilidades de display/padding para la vista de Cámaras */
.d-block { display: block !important; }
.d-none { display: none !important; }
.p-2 { padding: 8px !important; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.tab-pane-cam { width: 100%; }

/* Print: solo el ticket */
@media print {
    body { background: #fff; }
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { position: absolute; left: 0; top: 0; width: 72mm; }
    .no-print { display: none !important; }
    .ticket { box-shadow: none; border-radius: 0; }
}
