:root {
    --bg:#0b0b0c; 
    --panel:#121316; 
    --muted:#bfbfc0; 
    --text:#f2f3f5;
    --accent:#2f81f7; 
    --border:#22242a; 
    --ok:#22c55e; 
    --danger:#ef4444;
    --radius:16px; 
    --shadow:0 10px 30px rgba(0,0,0,.35);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

/* Body */
body {
    margin:0; 
    font:16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu;
    color:var(--text);
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    /* Fondo */
    background:
    radial-gradient(circle, transparent 20%, #87ceeb 20%, #87ceeb 80%, transparent 80%, transparent),
    linear-gradient(90deg, transparent 24%, rgba(255,255,255,0.3) 25%, rgba(255,255,255,0.3) 26%, transparent 27%, transparent 74%, rgba(255,255,255,0.3) 75%, rgba(255,255,255,0.3) 76%, transparent 77%, transparent);
    background-color: #a8d8ea;
    background-size: 15px 15px;
    background-attachment: fixed;
}

/*! CABEZERA */
.header {
    position: sticky;
    top: 0; 
    z-index: 20;
    display: flex; 
    align-items: center; 
    padding: 14px 16px; 
    gap: 12px;
    background: rgba(10,10,12,.6);
    backdrop-filter: blur(8px); 
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Brand - Logo - Texto */
.brand { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    text-decoration: none; 
    flex-shrink: 0;
}

.brand-logo { 
    width: 36px; 
    height: 36px; 
    object-fit: cover; 
    border-radius: 50%; 
    border: 1px solid var(--border);
}

.brand-text { 
    color: var(--text); 
    font-weight: 700; 
    letter-spacing: .2px;
}

/* Search - Buscar */
.search {
    flex: 1;
    max-width: 300px;
}

.search input {
    width: 100%; 
    padding: 10px 12px; 
    border-radius: 999px; 
    background: #0f1115;
    border: 1px solid var(--border); 
    color: var(--text); 
    outline: none;
    font-size: 14px;
}

/* Boton del Carrito */
.cart-btn {
    background: #0f1115; 
    border: 1px solid var(--border); 
    color: var(--text);
    border-radius: 999px; 
    padding: 10px 14px; 
    cursor: pointer;
}

.badge {
    background: var(--accent); 
    color: #fff; 
    border-radius: 999px; 
    padding: 2px 8px; 
    margin-left: 6px; 
    font-size: .85rem;
}

.menu-toggle {
    display: none;
    background: #0f1115; 
    border: 1px solid var(--border); 
    color: var(--text);
    border-radius: 8px; 
    padding: 8px; 
    cursor: pointer;
    font-size: 18px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

/*! NAVEGACION */
.filters{
    display: flex; 
    gap: 8px; 
    flex-wrap: wrap; 
    padding: 10px 16px;
    background: rgba(9,9,10,.05);
    backdrop-filter: blur(8px); 
}

.chip{
    padding: 8px 12px; 
    border-radius: 999px; 
    border: 1px solid var(--border);
    background: #0f1115; 
    color: var(--text); 
    cursor: pointer;
}

.chip.active {
    border-color: var(--accent); 
    box-shadow: inset 0 0 0 1px var(--accent);
}

/*! CONTENEDOR PRINCIPAL */
.container {
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 18px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(1, 1fr);
    grid-auto-rows: 1fr;
}

.empty { 
    text-align: center; 
    color: #ffffff; 
    margin: 40px 0; 
}

/*! MODAL DE IMAGENES */
.modal {
    display: none; 
    position: fixed;
    z-index: 10000;
    padding-top: 60px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
}

.close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #bbb;
}

#caption {
    margin: 15px auto;
    text-align: center;
    color: #ccc;
    font-size: 18px;
}

/*! DRAWER DEL CARRITO */
.drawer {
    position: fixed; 
    inset: 0; 
    display: grid; 
    place-items: stretch; 
    background: rgba(0,0,0,.5);
    z-index: 9999;
}

.drawer[hidden] { 
    display: none; 
}

.drawer-panel {
    margin-left: auto; 
    width: 320px;
    height: 100vh; /* height: 100%;  */
    background: var(--panel); 
    border-left: 1px solid var(--border);
    display: flex; 
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-height: 100vh; /* Nuevo */
}

.drawer:not([hidden]) .drawer-panel {
    transform: translateX(0);
}

.drawer-header {
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    padding: 14px 16px; 
    border-bottom: 1px solid var(--border);
}

.icon-btn {
    background: #0f1115; 
    border: 1px solid var(--border); 
    border-radius: 10px;
    color: var(--text); 
    cursor: pointer; 
    padding: 8px 10px;
}

.cart-items { 
    padding: 12px 16px; 
    /* overflow: auto;  */
    overflow-y: auto; /* Permitir scroll vertical cuando sea necesario */
    overflow-x: hidden; /* Evitar scroll horizontal */
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    min-height: 0; /* Permitir que el contenedor se contraiga */
    max-height: calc(100vh - 140px); /* Reservar espacio para header y footer */
}

/* Mejorar scroll en dispositivos móviles */
.cart-items::-webkit-scrollbar {
    width: 6px;
}

.cart-items::-webkit-scrollbar-track {
    background: transparent;
}

.cart-items::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.cart-items::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

.drawer-footer {
    border-top: 1px solid var(--border); 
    padding: 14px 16px; 
    display: grid; 
    gap: 10px;
    flex-shrink: 0; /* Evitar que el footer se contraiga */
    background: var(--panel); /* Asegurar que el fondo sea sólido */
    position: relative; /* Para asegurar que esté por encima del contenido */
}

.totals { 
    display: flex; 
    justify-content: space-between; 
    font-size: 1.1rem; 
}

.btn-outline {
    background: none; 
    border: 1px solid var(--border); 
    color: var(--text);
    padding: 10px 14px; 
    border-radius: 12px; 
    cursor: pointer;
}

.btn-primary {
    background: var(--ok); 
    color: #07110a; 
    border: none; 
    padding: 10px 14px; 
    border-radius: 12px; 
    cursor: pointer; 
    font-weight: 700;
}

.hint{ 
    color: var(--muted);
}

/* cart-item */
.cart-item {
    display: grid; 
    grid-template-columns: auto 1fr auto; 
    gap: 10px; 
    align-items: center;
    border: 1px solid var(--border); 
    border-radius: 12px; 
    padding: 8px;
}

.cart-item img { 
    width: 64px; 
    height: 64px; 
    object-fit: cover; 
    border-radius: 8px; 
}

.cart-item h4 { 
    margin: 0; 
    font-size: .98rem; 
}

.qty {
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    border: 1px solid var(--border);
    border-radius: 999px; 
    padding: 4px 8px;
}

.qty button { 
    background: none; 
    border: none; 
    color: var(--text); 
    cursor: pointer; 
    font-size: 1.1rem; 
}

/*! TARJETA DE PRODUCTOS */
.card {
    border-radius: var(--radius); 
    overflow: hidden; 
    box-shadow: var(--shadow);
    display: flex; 
    flex-direction: column;
    transition: transform .15s ease;
    height: 100%;
}

.card:hover { 
    transform: translateY(-2px); 
}

.card-img-wrap { 
    width: 100%;
    height: 300px;
    overflow: hidden;
    background: #f2f2f2;
    position: relative;
}

.overlay-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 9px;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
    pointer-events: none;
}

.card-img-wrap:hover .overlay-text {
    opacity: 1;
}

.card-img { 
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    cursor: pointer;
}

.card-body { 
    padding: 14px;
    background: rgba(10,10,12,.65);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-title { 
    margin: 0 0 6px; 
    font-size: 1.05rem; 
}

.card-desc { 
    margin: 0 0 12px; 
    color: var(--muted); 
    font-size: .85rem; 
}

.card-actions { 
    display: flex; 
    justify-content: flex-end;
    align-items: center; 
    margin-top: auto;
}

.btn-add {
    font-weight: bold;
    color: #fff; 
    border: none; 
    padding: 8px 12px; 
    border-radius: 55px; 
    cursor: pointer;
    background: #3b53b5;
    box-shadow: inset -24px -24px 13px #32479a, inset 24px 24px 13px #445fd0;
}

/*! PIE DE PAGINA */
.site-footer {
    margin-top: 20px;
    background: rgba(10,10,12,.6);
    backdrop-filter: blur(8px); 
    color: var(--text);
}

.site-footer p { 
    font-size: 0.8rem;
    margin: 0;
}

.site-footer ul { 
    font-size: 0.9rem; 
}

.site-footer a { 
    text-decoration: none; 
    font-size: 0.8rem;
    color: white;
}

.footer-wrap { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 12px 16px;
    display: grid; 
    gap: 12px;
}

.footer-brand { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

.footer-brand img { 
    width: 36px;
    height: 36px;
    border-radius: 50%; 
    border: 1px solid var(--border); 
}

.footer-cols { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 12px;
}

.footer-cols h4 { 
    margin: 0 0 4px;
    font-size: 0.9rem;
}

.footer-cols ul { 
    margin: 0; 
    padding-left: 14px;
    font-size: 0.85rem;
}

.copy { 
    display: block; 
    text-align: center; 
    padding: 6px 0;
    color: var(--muted); 
    font-size: 0.6rem;
}

/*! TOAST */
.toast-host{
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: grid;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast{
    pointer-events: auto;
    background: rgba(40, 40, 40, 0.9);
    color: #fff;
    border: 1px solid var(--border, #2a2d34);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 10px 26px rgba(0,0,0,.35);
    font-size: 0.95rem;
    display: flex; 
    align-items: center; 
    gap: 8px;
    opacity: 0; 
    transform: translateY(12px);
    transition: opacity .25s ease, transform .25s ease;
}

.toast::before{
    content: "✓";
    background: #22c55e; 
    color:#0b1a0f;
    width: 20px; 
    height: 20px; 
    border-radius: 50%;
    display: inline-grid; 
    place-items: center; 
    font-weight: 700;
}

.toast.show{ 
    opacity: 1; 
    transform: translateY(0); 
}

.toast.hide{ 
    opacity: 0; 
    transform: translateY(12px); 
}

/* MEDIA QUERIES RESPONSIVE */
@media (min-width: 640px) { 
    .grid { 
        grid-template-columns: repeat(2, 1fr);
    } 
}

@media (min-width: 800px) {
    .footer-cols { 
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 960px) { 
    .grid { 
        grid-template-columns: repeat(3, 1fr);
    } 
}

@media (min-width: 1200px) { 
    .grid { 
        grid-template-columns: repeat(4, 1fr);
    } 
}

/* Desktop */
@media (min-width: 769px) {
    .brand-text {
        display: block;
    }
    
    .menu-toggle {
        display: none;
    }
    
    .filters {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        flex-direction: row;
        background: rgba(9,9,10,.05);
    }

    .drawer-panel {
        width: 400px;
        box-shadow: -5px 0 15px rgba(0,0,0,0.3);
    }
    
    .header {
        justify-content: space-between;
        gap: 20px;
    }
    
    .search {
        max-width: 400px;
    }
}

/* Móvil */
@media (max-width: 768px) {
    .header {
        padding: 10px 12px;
        gap: 8px;
        justify-content: space-between;
    }
    
    .brand {
        flex-shrink: 0;
    }
    
    .brand-text {
        display: none;
    }
    
    .brand-logo {
        width: 32px;
        height: 32px;
    }
    
    .search {
        flex: 1;
        max-width: 150px;
        margin: 0 8px;
    }
    
    .search input {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .header-actions {
        flex-shrink: 0;
        margin-left: auto;
    }
    
    .menu-toggle {
        display: flex;
        order: 1;
    }
    
    .cart-btn {
        order: 2;
        flex-shrink: 0;
    }
    
    .filters {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        background: rgba(9,9,10,.95);
        backdrop-filter: blur(12px);
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 15;
        border-bottom: 1px solid var(--border);
    }
    
    .filters.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .chip {
        justify-content: center;
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .container {
        padding: 12px 8px;
    }
    
    .grid {
        gap: 12px;
        grid-template-columns: repeat(2, 1fr);
    }
    
    .drawer-panel {
        width: 100%;
        max-width: 400px;
        height: 100vh; /* Nuevo */
        max-height: 100vh; /* Nuevo */
    }
    
    .card-img-wrap {
        height: 160px;
    }
    
    .card-body {
        padding: 10px;
    }
    
    .card-title {
        font-size: 0.9rem;
        margin-bottom: 4px;
    }
    
    .card-desc {
        font-size: 0.75rem;
        margin-bottom: 8px;
        line-height: 1.3;
    }
    
    .btn-add {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .cart-items {
        max-height: calc(100vh - 160px); /* Más espacio para header y footer en móvil */
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px 10px;
    }
    
    .search {
        max-width: 120px;
    }
    
    .search input {
        padding: 6px 8px;
        font-size: 13px;
    }
    
    .header-actions {
        gap: 6px;
    }
    
    .grid {
        grid-template-columns: 1fr;
    }
    
    .card-img-wrap {
        height: 140px;
    }

    .cart-items {
        max-height: calc(100vh - 180px); /* Aún más espacio en pantallas muy pequeñas */
        padding: 12px 12px;
    }
    
    .drawer-footer {
        padding: 12px;
    }
}

@media (max-width: 380px) {
    .search {
        max-width: 100px;
    }
    
    .header-actions {
        gap: 4px;
    }
    
    .cart-btn {
        padding: 8px 10px;
    }
    
    .menu-toggle {
        width: 36px;
        height: 36px;
        padding: 6px;
    }
    
    .cart-item {
        grid-template-columns: 1fr auto;
    }
    
    .cart-item img {
        display: none;
    }
    
    .drawer-panel {
        width: 280px;
        height: 100vh; /* Nuevo */
    }

    .cart-item {
        max-height: calc(100vh - 200px);
    }
}
