/* Se muestra desde auth.js solo si la página no está dentro de un iframe. */
html { display: none; }

/* Bootstrap usa display con !important: el atributo hidden debe ganar. */
[hidden] { display: none !important; }

:root {
    --brand: #0d1f24;
    --brand-2: #16343b;
    --brand-3: #08161a;
    --oro: #d2a453;
    --oro-claro: #f2d08b;
    --ink: #101517;
    --muted: #6d7477;
    --bg: #f6f5f1;
    --surface: #ffffff;
    --line: #e4e2da;
    --sidebar-width: 248px;
    --radio-lg: 30px;
    --radio-md: 20px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -.025em;
}

/* ---------- Navegación lateral ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-3) 100%);
    border-right: 1px solid rgba(210, 164, 83, .22);
    color: #f4f1ea;
    padding: 1.4rem .95rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    z-index: 1040;
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}

.brand {
    position: relative;
    display: flex;
    align-items: center;
    gap: .7rem;
    font-size: 1.08rem;
    font-weight: 650;
    letter-spacing: -.015em;
    padding: .35rem .65rem 1.5rem;
    color: #fff;
}

/* Moneda: figura propia de la marca, sin depender de iconos externos. */
.brand::before {
    content: "";
    position: absolute;
    left: .55rem;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 50%;
    border: 1px solid var(--oro);
    background:
        radial-gradient(circle at 50% 50%, var(--oro-claro) 0 26%, transparent 27% 40%, var(--oro) 41% 100%);
    box-shadow: 0 0 0 3px rgba(210, 164, 83, .12);
}

.brand i { display: none; }
.brand span { padding-left: 1.9rem; }

.nav-label {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .16em;
    color: rgba(242, 208, 139, .62);
    padding: .6rem .8rem .35rem;
}

.sidebar .nav-link {
    position: relative;
    color: rgba(244, 241, 234, .78);
    border-radius: 13px;
    padding: .6rem .8rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .9rem;
    transition: background .18s ease, color .18s ease;
}

.sidebar .nav-link i { color: var(--oro); font-size: .95rem; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.sidebar .nav-link.active {
    background: rgba(210, 164, 83, .14);
    color: var(--oro-claro);
    font-weight: 600;
}

.sidebar .nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    width: 3px;
    height: 20px;
    border-radius: 999px;
    background: var(--oro);
}

.sidebar-footer {
    margin-top: auto;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: rgba(242, 208, 139, .7);
    padding: 1rem .8rem 0;
    border-top: 1px solid rgba(210, 164, 83, .18);
}

/* El nombre del usuario sustituye a cualquier dato de contacto en el sidebar. */
.sidebar-usuario {
    display: flex;
    align-items: center;
    gap: .35rem;
    text-transform: none;
    letter-spacing: normal;
    font-size: .86rem;
    font-weight: 600;
    color: #f7f2e6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-usuario i { color: var(--oro); font-size: 1.05rem; }

.sidebar-footer .btn-salir {
    border-color: rgba(242, 208, 139, .35);
    color: #f2d08b;
    background: rgba(255, 255, 255, .04);
    letter-spacing: .02em;
    text-transform: none;
}

.sidebar-footer .btn-salir:hover {
    background: rgba(210, 164, 83, .16);
    color: #fff;
}

/* ---------- Estructura ---------- */
.main { margin-left: var(--sidebar-width); min-height: 100vh; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1.75rem;
    background: rgba(246, 245, 241, .9);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.content { padding: 2rem 1.75rem 3rem; }

.page-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 680; margin: 0; }
.page-head p { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- Componentes ---------- */
.card, .card-table {
    border: 1px solid var(--line);
    border-radius: var(--radio-lg);
    background: var(--surface);
    box-shadow: 0 12px 40px rgba(13, 31, 36, .05);
}

.card-table { overflow: hidden; }
.card-body { padding: 1.5rem; }

.btn {
    border-radius: 999px;
    font-weight: 600;
    font-size: .875rem;
    padding: .55rem 1.15rem;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn:active { transform: scale(.98); }

.btn-brand {
    background: linear-gradient(135deg, var(--oro-claro), var(--oro));
    border: 0;
    color: var(--brand-3);
    box-shadow: 0 6px 18px rgba(210, 164, 83, .28);
}

.btn-brand:hover { color: var(--brand-3); filter: brightness(1.05); }

.btn-salir {
    background: #8a2b2b;
    border-color: #8a2b2b;
    color: #fff;
}

.btn-salir:hover { background: #6f2020; border-color: #6f2020; color: #fff; }

.btn-outline-primary,
.btn-outline-success {
    color: var(--brand);
    border-color: rgba(13, 31, 36, .28);
}

.btn-outline-primary:hover,
.btn-outline-success:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-light, .btn-outline-light {
    color: var(--brand);
    border-color: var(--line);
}

.btn-outline-light { border-color: rgba(255, 255, 255, .45); color: #fff; }
.btn-outline-light:hover { background: #fff; color: var(--brand); }

.btn-action {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border-radius: 11px;
}

.form-control, .form-select {
    min-height: 44px;
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: .6rem .9rem;
    background-color: #fff;
    box-shadow: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--oro);
    box-shadow: 0 0 0 3px rgba(210, 164, 83, .16);
}

.form-label {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--muted);
    font-weight: 650;
}

.table { --bs-table-bg: transparent; }
.table thead th {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .11em;
    color: var(--muted);
    border-bottom: 1px solid var(--line) !important;
}
.table td { border-color: #efede7; vertical-align: middle; }

.modal-content {
    border: 0;
    border-radius: 26px;
    box-shadow: 0 30px 80px rgba(8, 22, 26, .22);
}
.modal-header, .modal-footer { border-color: var(--line); }

.alert { border: 0; border-radius: 14px; }
.badge { border-radius: 999px; }
#cartCount { background: var(--oro); color: var(--brand-3); }
.empty-hint { color: var(--muted); font-size: .9rem; }

/* ---------- Portada e-commerce ---------- */
.hero-tienda {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #f4f1ea;
    border-radius: var(--radio-lg);
    padding: clamp(2.25rem, 5vw, 4rem);
    margin-bottom: 1.75rem;
}

.hero-tienda::before,
.hero-tienda::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(242, 208, 139, .2);
    pointer-events: none;
}

.hero-tienda::before {
    width: 430px;
    height: 430px;
    border-radius: 50%;
    right: -150px;
    top: -190px;
}

.hero-tienda::after {
    width: 210px;
    height: 210px;
    border-radius: 34px;
    right: 14%;
    bottom: -130px;
    transform: rotate(45deg);
}

.hero-tienda > *:not(.hero-formas) { position: relative; z-index: 2; }

.hero-formas { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.forma { position: absolute; display: block; }

.forma-moneda {
    width: 116px;
    height: 116px;
    right: 8%;
    top: 20%;
    border-radius: 50%;
    border: 1px solid rgba(242, 208, 139, .5);
    background: radial-gradient(circle, rgba(242, 208, 139, .22) 0 32%, transparent 33% 45%, rgba(242, 208, 139, .1) 46%);
    box-shadow: 0 0 0 8px rgba(242, 208, 139, .05);
}

.forma-arco {
    width: 180px;
    height: 180px;
    right: 24%;
    bottom: -78px;
    border-radius: 50%;
    border: 1px dashed rgba(242, 208, 139, .3);
}

.forma-lineas {
    width: 92px;
    height: 92px;
    right: 34%;
    top: 28%;
    background: repeating-linear-gradient(90deg, rgba(242, 208, 139, .32) 0 1px, transparent 1px 13px);
    transform: rotate(-18deg);
}

.hero-tienda h1 {
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    font-weight: 700;
    line-height: 1.02;
    margin: 0 0 1rem;
}

.hero-tienda p {
    color: rgba(244, 241, 234, .8);
    max-width: 44rem;
    line-height: 1.65;
}

.hero-tienda .btn { margin-top: .6rem; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: rgba(242, 208, 139, .14);
    color: var(--oro-claro);
    border: 1px solid rgba(242, 208, 139, .32);
    border-radius: 999px;
    padding: .4rem .9rem;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 650;
}

.cat-chip {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--brand);
    border-radius: 999px;
    padding: .5rem 1rem;
    font-size: .84rem;
    font-weight: 600;
    transition: transform .16s ease, background .16s ease;
}

.cat-chip:hover { transform: translateY(-2px); }
.cat-chip.activa { background: var(--brand); border-color: var(--brand); color: #fff; }

.barra-busqueda {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radio-md);
    padding: 1rem;
    box-shadow: 0 8px 30px rgba(13, 31, 36, .04);
}

.grid-productos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1.15rem;
    margin-top: 1.35rem;
}

.card-producto {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radio-md);
    background: #fff;
    padding: 1.1rem;
    min-height: 190px;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    box-shadow: 0 1px 2px rgba(13, 31, 36, .04);
    transition: transform .22s ease, box-shadow .22s ease;
}

.card-producto::after {
    content: "";
    position: absolute;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 1px solid rgba(210, 164, 83, .22);
    top: -22px;
    right: -20px;
}

.card-producto:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 45px rgba(13, 31, 36, .1);
}

.card-producto h3 { font-size: 1rem; margin: 0; font-weight: 650; }
.card-producto .meta { font-size: .83rem; color: var(--muted); }
.card-producto .precio {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand);
    margin-top: auto;
}

.imagen-tesoro {
    width: 100%;
    height: 136px;
    object-fit: cover;
    border-radius: 14px;
    background: #f0eee8;
}

.sin-imagen {
    height: 136px;
    border-radius: 14px;
    background:
        radial-gradient(circle at 70% 30%, rgba(210, 164, 83, .22), transparent 40%),
        linear-gradient(135deg, #ece9e0, #ded9cc);
    display: grid;
    place-items: center;
    font-size: 2.4rem;
}

#estado, #estadoCarga { min-height: 1.5rem; margin: .75rem 0 0; font-size: .9rem; }
#centinela { height: 1px; }

/* ---------- Acceso ---------- */
.pagina-auth {
    position: relative;
    background:
        radial-gradient(circle at 12% 18%, rgba(210, 164, 83, .2), transparent 34%),
        linear-gradient(135deg, var(--brand), var(--brand-3));
}

.pagina-auth::before,
.pagina-auth::after {
    content: "";
    position: fixed;
    pointer-events: none;
    border: 1px solid rgba(242, 208, 139, .18);
}

.pagina-auth::before {
    width: 360px;
    height: 360px;
    border-radius: 50%;
    left: -150px;
    bottom: -150px;
}

.pagina-auth::after {
    width: 200px;
    height: 200px;
    border-radius: 30px;
    right: -70px;
    top: -70px;
    transform: rotate(45deg);
}

.pagina-auth .card { border-radius: 28px; }
.pagina-auth .text-success { color: var(--oro) !important; }

/* ---------- Movimiento ---------- */
.spin { display: inline-block; animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Identidad Token Store ---------- */
.hero-logo {
    display: block;
    width: clamp(70px, 9vw, 104px);
    height: auto;
    margin-bottom: 1.1rem;
    filter: drop-shadow(0 12px 22px rgba(8, 22, 26, .45));
}

.resumen-compra {
    background: rgba(210, 164, 83, .08);
    border: 1px solid rgba(210, 164, 83, .28);
}

.ticket {
    border-style: dashed;
    border-color: rgba(210, 164, 83, .55);
}

.ticket .card-body { position: relative; }

@media print {
    .sidebar, .topbar, .page-head, #catalogo, #carrito,
    #resumenCompra, #chkConfirmar, #btnComprar, .ticket button { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
    .ticket { border: 1px solid #000; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar { padding: .8rem 1rem; }
    .content { padding: 1.4rem 1rem 2.5rem; }
    .forma-moneda { right: 5%; top: 14%; }
    .forma-lineas { display: none; }
}

@media (max-width: 575.98px) {
    .hero-tienda { padding: 1.8rem 1.3rem; border-radius: 24px; }
    .hero-tienda h1 { font-size: 2rem; }
    .grid-productos { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .8rem; }
    .card-producto { padding: .85rem; }
}
