/* ════════════════════════════════════════════════════════════════
   Fide Wallet · Hoja de estilos de la aplicación (sobre Bootstrap 5.3)
   ════════════════════════════════════════════════════════════════ */

:root {
    --fw-ink: #0f172a;
    --fw-ink-2: #1e293b;
    --fw-accent: #0d9488;
    --fw-accent-2: #14b8a6;
    --fw-accent-soft: #ccfbf1;
    --fw-surface: #f5f7fa;
    --fw-border: #e5e7eb;
    --fw-muted: #64748b;
    --fw-radius: 14px;
    --fw-sidebar: 248px;

    --bs-primary: var(--fw-accent);
    --bs-primary-rgb: 13, 148, 136;
    --bs-link-color: #0f766e;
    --bs-link-hover-color: #115e59;
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-bg: var(--fw-surface);
    --bs-border-radius: 10px;
}

body { -webkit-font-smoothing: antialiased; }

.btn-primary {
    --bs-btn-bg: var(--fw-accent);
    --bs-btn-border-color: var(--fw-accent);
    --bs-btn-hover-bg: #0f766e;
    --bs-btn-hover-border-color: #0f766e;
    --bs-btn-active-bg: #115e59;
    --bs-btn-active-border-color: #115e59;
    --bs-btn-disabled-bg: var(--fw-accent);
    --bs-btn-disabled-border-color: var(--fw-accent);
}
.btn-outline-primary {
    --bs-btn-color: #0f766e;
    --bs-btn-border-color: var(--fw-accent);
    --bs-btn-hover-bg: var(--fw-accent);
    --bs-btn-hover-border-color: var(--fw-accent);
    --bs-btn-active-bg: #0f766e;
}
.text-primary { color: #0f766e !important; }
.bg-primary-soft { background: var(--fw-accent-soft); }
.form-control:focus, .form-select:focus {
    border-color: var(--fw-accent-2);
    box-shadow: 0 0 0 .2rem rgba(20, 184, 166, .2);
}
.form-check-input:checked { background-color: var(--fw-accent); border-color: var(--fw-accent); }

/* ── Layout de panel ──────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--fw-sidebar);
    flex-shrink: 0;
    background: var(--fw-ink);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.app-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.25rem 1.25rem 1rem;
    color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none;
}
.app-brand .brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--fw-accent-2), #0ea5e9);
    color: #fff; font-size: 1.05rem;
}
.app-tenant {
    margin: 0 .9rem 1rem; padding: .7rem .8rem; border-radius: 10px;
    background: var(--fw-ink-2); font-size: .82rem;
}
.app-tenant strong { color: #fff; display: block; font-size: .92rem; }
.app-nav { list-style: none; padding: 0 .6rem; margin: 0; flex: 1; overflow-y: auto; }
.app-nav .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .7rem .35rem; }
.app-nav a {
    display: flex; align-items: center; gap: .7rem;
    padding: .58rem .75rem; border-radius: 9px;
    color: #cbd5e1; text-decoration: none; font-size: .93rem;
}
.app-nav a .bi { font-size: 1.05rem; opacity: .85; }
.app-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.app-nav a.active { background: rgba(20, 184, 166, .16); color: #5eead4; }
.app-nav a.active .bi { opacity: 1; }
.app-sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .06); font-size: .85rem; }
.app-sidebar-footer .btn-link { color: #94a3b8; text-decoration: none; padding: 0; }
.app-sidebar-footer .btn-link:hover { color: #fff; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 2rem; background: #fff; border-bottom: 1px solid var(--fw-border);
    position: sticky; top: 0; z-index: 10;
}
.app-topbar h1 { font-size: 1.25rem; font-weight: 650; margin: 0; }
.app-content { padding: 1.75rem 2rem 3rem; max-width: 1320px; width: 100%; }

.token-pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .35rem .8rem; border-radius: 999px;
    background: var(--fw-accent-soft); color: #115e59; font-weight: 600; font-size: .88rem;
    text-decoration: none;
}
.token-pill.is-low { background: #fee2e2; color: #991b1b; }

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 1045;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    .app-sidebar.is-open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .45); }
    .app-topbar { padding: .8rem 1rem; }
    .app-content { padding: 1.25rem 1rem 3rem; }
}

/* ── Componentes ──────────────────────────────────────────────── */
.card { border: 1px solid var(--fw-border); border-radius: var(--fw-radius); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--fw-border); font-weight: 600; padding: .9rem 1.15rem; }
.card-header:first-child { border-radius: var(--fw-radius) var(--fw-radius) 0 0; }

.stat-card { padding: 1.1rem 1.2rem; display: flex; gap: .9rem; align-items: flex-start; height: 100%; }
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 1.2rem;
    background: var(--fw-accent-soft); color: #0f766e;
}
.stat-card .stat-icon.is-blue { background: #dbeafe; color: #1d4ed8; }
.stat-card .stat-icon.is-amber { background: #fef3c7; color: #b45309; }
.stat-card .stat-icon.is-rose { background: #ffe4e6; color: #be123c; }
.stat-card .stat-icon.is-violet { background: #ede9fe; color: #6d28d9; }
.stat-card .stat-label { color: var(--fw-muted); font-size: .82rem; }
.stat-card .stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }

.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--fw-muted); font-weight: 600; background: #f8fafc; }
.table-hover tbody tr { cursor: default; }
.table a.row-link { color: inherit; text-decoration: none; font-weight: 600; }
.table a.row-link:hover { color: #0f766e; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--fw-muted); }
.empty-state .bi { font-size: 2.4rem; color: #94a3b8; display: block; margin-bottom: .6rem; }

.avatar {
    width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center;
    background: #e2e8f0; color: #334155; font-weight: 700; font-size: .85rem; flex-shrink: 0;
}

/* Gráfico de barras ligero (SVG generado en app.js) */
.mini-chart { width: 100%; height: 140px; display: block; }
.mini-chart rect { fill: var(--fw-accent-2); }
.mini-chart rect:hover { fill: #0f766e; }
.mini-chart text { font-size: 10px; fill: var(--fw-muted); }

/* ── Vista previa del pase ────────────────────────────────────── */
.pass-preview {
    --pass-bg: #1f2937; --pass-fg: #fff; --pass-label: #d1d5db;
    width: 100%; max-width: 340px; margin: 0 auto;
    border-radius: 16px; overflow: hidden;
    background: var(--pass-bg); color: var(--pass-fg);
    box-shadow: 0 18px 40px -12px rgba(15, 23, 42, .45), 0 2px 6px rgba(15, 23, 42, .12);
    font-family: -apple-system, system-ui, sans-serif;
    transition: background .2s ease;
}
.pass-preview.is-voided { filter: grayscale(1) opacity(.65); }
.pass-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .8rem 1rem .6rem; min-height: 56px; }
.pass-head .pass-logo { max-height: 34px; max-width: 120px; object-fit: contain; }
.pass-head .pass-program { font-weight: 600; font-size: .95rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pass-label { color: var(--pass-label); font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.pass-head .pass-head-field { text-align: right; }
.pass-strip {
    position: relative; aspect-ratio: 375 / 123; background: rgba(255, 255, 255, .08);
    display: flex; align-items: flex-end; overflow: hidden;
}
.pass-strip img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pass-strip .pass-primary { position: relative; padding: .5rem 1rem; text-shadow: 0 1px 6px rgba(0, 0, 0, .45); }
.pass-strip .pass-primary .value { font-size: 2.1rem; font-weight: 300; line-height: 1; }
.pass-fields { display: flex; justify-content: space-between; gap: .8rem; padding: .7rem 1rem; }
.pass-fields .value { font-size: .95rem; }
.pass-stamps { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 1rem .4rem; }
.pass-stamps span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--pass-fg); opacity: .55; }
.pass-stamps span.on { background: var(--pass-fg); opacity: 1; }
.pass-qr { display: grid; place-items: center; padding: .6rem 0 1rem; }
.pass-qr .qr-box { background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
.pass-qr .qr-box img, .pass-qr .qr-box svg { width: 110px; height: 110px; }
.pass-qr small { color: var(--pass-label); margin-top: .35rem; font-size: .7rem; letter-spacing: .08em; }
.pass-voided-badge { text-align: center; font-size: .75rem; padding: .3rem; background: rgba(0, 0, 0, .35); text-transform: uppercase; letter-spacing: .1em; }

/* Notificación de pantalla de bloqueo (simulada) */
.lockscreen {
    border-radius: 22px; padding: 1.1rem; max-width: 360px; margin: 0 auto;
    background: linear-gradient(160deg, #334155, #0f172a 70%);
}
.lockscreen-time { color: #fff; text-align: center; font-size: 2.6rem; font-weight: 200; line-height: 1; margin: .2rem 0 1rem; }
.notif {
    display: flex; gap: .65rem; align-items: flex-start;
    background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
    border-radius: 16px; padding: .65rem .75rem; color: #0f172a;
}
.notif-icon { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--fw-accent); display: grid; place-items: center; color: #fff; }
.notif-title { font-weight: 600; font-size: .85rem; }
.notif-body { font-size: .82rem; color: #334155; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.notif-meta { font-size: .7rem; color: #64748b; }

/* Guía de recorte de imágenes */
.crop-guides { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.crop-guide { border-radius: 8px; overflow: hidden; background: #e2e8f0; position: relative; }
.crop-guide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.crop-guide .ratio-label { position: absolute; left: 6px; bottom: 6px; font-size: .68rem; background: rgba(15, 23, 42, .75); color: #fff; padding: .1rem .4rem; border-radius: 4px; }
.crop-guide.r-strip { aspect-ratio: 1125 / 369; }
.crop-guide.r-hero { aspect-ratio: 1032 / 336; }
.crop-guide.r-og { aspect-ratio: 1200 / 630; }
.crop-guide .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; font-size: 1.4rem; }

.dropzone {
    border: 2px dashed #cbd5e1; border-radius: 12px; padding: 1.4rem; text-align: center;
    background: #f8fafc; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--fw-accent-2); background: #f0fdfa; }
.dropzone .bi { font-size: 1.8rem; color: var(--fw-accent); }

.option-card { cursor: pointer; height: 100%; }
.option-card input { position: absolute; opacity: 0; pointer-events: none; }
.option-card .option-body {
    border: 2px solid var(--fw-border); border-radius: 12px; padding: 1rem; height: 100%;
    transition: border-color .15s, background .15s;
}
.option-card .option-body .bi { font-size: 1.4rem; color: var(--fw-accent); }
.option-card input:checked + .option-body { border-color: var(--fw-accent); background: #f0fdfa; }
.option-card input:focus-visible + .option-body { outline: 3px solid rgba(20, 184, 166, .35); }

.char-counter { font-size: .75rem; color: var(--fw-muted); }
.char-counter.is-over { color: #dc2626; font-weight: 600; }

.sticky-preview { position: sticky; top: 90px; }

/* Escáner */
.scanner-frame { position: relative; border-radius: 16px; overflow: hidden; background: #0f172a; aspect-ratio: 1; max-width: 420px; margin: 0 auto; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame::after {
    content: ""; position: absolute; inset: 18%;
    border: 3px solid rgba(94, 234, 212, .9); border-radius: 18px;
    box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .35);
}
.scanner-frame .scanner-idle { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; text-align: center; padding: 2rem; z-index: 1; }

/* ── Autenticación ────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side {
    background: radial-gradient(circle at 20% 20%, #134e4a, var(--fw-ink) 60%);
    color: #e2e8f0; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side h2 { color: #fff; font-weight: 700; font-size: 2rem; line-height: 1.2; }
.auth-feature { display: flex; gap: .8rem; margin-bottom: 1rem; }
.auth-feature .bi { color: #5eead4; font-size: 1.3rem; }
.auth-form { display: grid; place-items: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 400px; }
@media (max-width: 860px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-side { display: none; }
}

/* ── Páginas públicas (clientes finales) ──────────────────────── */
.public-body { background: #eef2f6; min-height: 100vh; }
.public-container { max-width: 480px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.public-hero { text-align: center; margin-bottom: 1.25rem; }
.public-hero .logo-box {
    width: 84px; height: 84px; border-radius: 22px; margin: 0 auto .8rem; overflow: hidden;
    display: grid; place-items: center; box-shadow: 0 8px 22px -8px rgba(15, 23, 42, .4);
}
.public-hero .logo-box img { width: 100%; height: 100%; object-fit: contain; }
.wallet-btn {
    display: flex; align-items: center; justify-content: center; gap: .6rem;
    width: 100%; padding: .85rem 1rem; border-radius: 12px; font-weight: 600;
    text-decoration: none; border: 0; font-size: 1rem;
}
.wallet-btn.apple { background: #000; color: #fff; }
.wallet-btn.google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.wallet-btn.app { background: var(--fw-accent); color: #fff; }
.wallet-btn:hover { filter: brightness(1.08); }
.wallet-btn .bi { font-size: 1.25rem; }

/* Landing de campaña */
.promo-card { background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 18px 40px -18px rgba(15, 23, 42, .35); }
.promo-media { aspect-ratio: 1200 / 630; background: linear-gradient(135deg, var(--promo-bg, #1f2937), #0f172a); position: relative; }
.promo-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.promo-media .promo-brand {
    position: absolute; left: 12px; top: 12px; display: flex; align-items: center; gap: .5rem;
    background: rgba(255, 255, 255, .92); border-radius: 999px; padding: .25rem .7rem .25rem .3rem; font-size: .8rem; font-weight: 600;
}
.promo-media .promo-brand img { width: 24px; height: 24px; border-radius: 50%; object-fit: contain; background: #fff; }
.promo-body { padding: 1.4rem 1.3rem 1.5rem; }
.promo-body h1 { font-size: 1.45rem; font-weight: 750; }
.promo-text { white-space: pre-line; color: #334155; }
.coupon {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    border: 2px dashed var(--fw-accent); border-radius: 14px; padding: .8rem 1rem; margin: 1.1rem 0;
    background: #f0fdfa;
}
.coupon-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.35rem; font-weight: 700; letter-spacing: .08em; color: #115e59; word-break: break-all; }
.cta-btn { display: flex; align-items: center; justify-content: center; gap: .55rem; width: 100%; padding: .95rem; border-radius: 14px; font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.cta-btn.web { background: var(--fw-ink); color: #fff; }
.cta-btn.whatsapp { background: #25d366; color: #fff; }
.cta-btn:hover { filter: brightness(1.07); color: #fff; }

.copy-btn.is-copied { background: #16a34a !important; border-color: #16a34a !important; color: #fff !important; }

/* Accesibilidad: respetar reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* Admin · vista previa del aspecto de las apps instalables */
.brand-preview { border-radius: 22px; overflow: hidden; border: 1px solid var(--bs-border-color); background: #1e293b; display: grid; gap: 0; max-width: 240px; margin: 0 auto; }
.brand-home { background: linear-gradient(160deg, #334155, #0f172a); padding: 18px 0 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.brand-home-icon canvas { width: 64px; height: 64px; display: block; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35)); }
.brand-home-name { color: #fff; font-size: .75rem; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-bar { color: #fff; font-size: .8rem; font-weight: 700; padding: 8px 12px; display: flex; gap: 6px; align-items: center; mix-blend-mode: normal; }
.brand-splash { height: 110px; display: flex; align-items: center; justify-content: center; }
.brand-splash canvas { width: 56px; height: 56px; }
.app-brand .brand-logo { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; flex: none; }
.brand-tab { background: #e2e8f0; color: #0f172a; font-size: .75rem; display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px 10px 0 0; margin: 10px 10px 0; }
.brand-tab canvas { width: 16px; height: 16px; flex: none; }
.brand-sidebar { background: #0f172a; color: #fff; font-weight: 700; display: flex; align-items: center; gap: 10px; padding: 14px; }
.brand-sidebar canvas { width: 34px; height: 34px; }
.choose-app { border-radius: 18px; transition: border-color .15s; }
.choose-app:hover { border-color: var(--fw-accent); }
.choose-app summary { list-style: none; cursor: pointer; }
.choose-app summary::-webkit-details-marker { display: none; }
.choose-app-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 1.5rem; background: var(--fw-accent-soft); color: #0f766e; flex: none; }
.choose-app-icon.is-business { background: #0f172a; color: #fff; }
.public-hero .brand-mark, .public-hero .brand-logo { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; font-size: 1.7rem; color: #fff; background: linear-gradient(135deg, var(--fw-accent-2), #0ea5e9); object-fit: cover; }

/* Ficha del negocio · encuadre del logo */
.logo-stage { width: 180px; height: 180px; margin: 0 auto; border-radius: 28px; overflow: hidden; position: relative; display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); touch-action: none; }
.logo-stage canvas, .logo-stage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-stage canvas { cursor: grab; }
.logo-stage canvas:active { cursor: grabbing; }
.logo-stage .logo-empty { font-size: 2.4rem; color: #94a3b8; }

/* Textos legales */
.legal-page { max-width: 760px; margin: 0 auto; }
.legal-text { line-height: 1.65; font-size: .95rem; }
.legal-text h2 { font-size: 1.15rem; font-weight: 700; margin: 1.4rem 0 .6rem; }
.legal-text h3, .legal-text h4 { font-size: 1rem; font-weight: 700; margin: 1.1rem 0 .5rem; }
.legal-text ul { padding-left: 1.2rem; }
.legal-footer { text-align: center; font-size: .78rem; margin-top: 1.5rem; }
.legal-footer a { color: inherit; margin: 0 .35rem; }
.stat-mini { background: var(--fw-surface); border: 1px solid var(--fw-border); border-radius: 12px; padding: 8px 4px; height: 100%; }
.stat-mini strong { display: block; font-size: 1rem; line-height: 1.2; }
.stat-mini span { font-size: .7rem; color: var(--fw-muted); }

/* Estado de la ficha en la app (panel) */
.listing-check { background: #fffbeb; border: 1px solid #fde68a; border-radius: .75rem; padding: .75rem 1rem; color: #713f12; }
.listing-check.is-ok { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }

/* Plantilla de tarjeta (color de la tarjeta + icono) */
.preset-swatch { width: 2rem; height: 2rem; flex-shrink: 0; display: grid; place-items: center; border-radius: .5rem; }
.preset-swatch .bi { color: inherit !important; font-size: 1rem; }
