/* ==========================================================================
   VARIABLES Y CONFIGURACIÓN BASE
   ========================================================================== */
:root {
    /* Paleta Premium Oscura */
    --bg-color: #12121e;        /* Azul marino muy oscuro / fondo general */
    --surface: #1a1a2e;         /* Azul marino para tarjetas y modales */
    --surface-hover: #23233d;
    --accent: #f5b041;          /* Dorado/Ámbar para botones y llamados a la acción */
    --accent-hover: #d49330;
    --text-main: #f8f9fa;       /* Texto principal claro */
    --text-muted: #adb5bd;      /* Texto secundario grisáceo */
    --border-color: #2d2d44;
    --success: #2ecc71;         /* Verde para WhatsApp y confirmaciones */
    --danger: #e74c3c;          /* Rojo para eliminar items o cerrado */
    
    /* Tipografía y Espaciados */
    --font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    --border-radius: 12px;
    --transition: 0.3s ease;
    
    /* Z-Index architecture */
    --z-header: 100;
    --z-fab: 200;
    --z-overlay: 300;
    --z-drawer: 400;
    --z-modal: 500;
}

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 80px; /* Espacio para el FAB del carrito */
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; background: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ==========================================================================
   UTILIDADES
   ========================================================================== */
.hidden { display: none !important; }
.w-100 { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }

/* Botones genéricos */
.btn-primary {
    background-color: var(--accent);
    color: #000;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    transition: background-color var(--transition);
    font-size: 1rem;
}
.btn-primary:hover:not(:disabled) { background-color: var(--accent-hover); }
.btn-primary:disabled { background-color: #555; color: #888; cursor: not-allowed; }

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: var(--border-radius);
    font-weight: 500;
}

.btn-whatsapp {
    display: inline-block;
    background-color: var(--success);
    color: #fff;
    padding: 14px 24px;
    border-radius: var(--border-radius);
    font-weight: 600;
    text-decoration: none;
    font-size: 1.1rem;
    transition: opacity var(--transition);
}
.btn-whatsapp:hover { opacity: 0.9; }

.icon-btn { font-size: 1.5rem; color: var(--text-muted); }

/* ==========================================================================
   HEADER
   ========================================================================== */
.main-header {
    background-color: var(--surface);
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.header-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand h1 { font-size: 1.5rem; font-weight: 700; color: var(--accent); }

.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-badge.checking { background: #555; color: #fff; }
.status-badge.open { background: rgba(46, 204, 113, 0.2); color: var(--success); border: 1px solid var(--success); }
.status-badge.closed { background: rgba(231, 76, 60, 0.2); color: var(--danger); border: 1px solid var(--danger); }

.header-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
}
.phone-link { color: var(--accent); font-weight: 500; }

/* ==========================================================================
   NAVEGACIÓN (Categorías Stories Style)
   ========================================================================== */
.category-nav {
    background-color: var(--bg-color);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.category-list {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0 1rem;
    scrollbar-width: none; /* Firefox */
}
.category-list::-webkit-scrollbar { display: none; } /* Chrome, Safari */

.cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 70px;
    opacity: 0.6;
    transition: opacity var(--transition);
}
.cat-item.active, .cat-item:hover { opacity: 1; }

.cat-icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: 2px solid transparent;
    transition: border var(--transition);
}
.cat-item.active .cat-icon-wrapper { border-color: var(--accent); }
.cat-name { font-size: 0.8rem; font-weight: 500; text-align: center; }

/* Skeleton Loading para categorías */
.category-skeleton { width: 60px; height: 60px; border-radius: 50%; background-color: var(--surface); animation: pulse 1.5s infinite; }

/* ==========================================================================
   MAIN CONTENT & GRID
   ========================================================================== */
.main-content { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }

.closed-banner {
    background-color: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columnas en móvil (Requisito) */
    gap: 1rem;
}

/* Tarjeta de Producto */
.product-card {
    background-color: var(--surface);
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    transition: transform var(--transition);
}
.product-card:active { transform: scale(0.98); }

.product-img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background-color: #2a2a4a; /* Placeholder por si tarda en cargar */
}

.product-info {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-name { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.25rem; }
.product-desc { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.75rem; flex-grow: 1; }
.product-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.product-price { font-weight: 700; color: var(--accent); font-size: 1rem; }

.btn-add {
    background-color: var(--bg-color);
    border: 1px solid var(--accent);
    color: var(--accent);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.2s;
}
.btn-add:hover { background-color: var(--accent); color: #000; }
.btn-add:disabled { border-color: var(--text-muted); color: var(--text-muted); }

/* ==========================================================================
   CARRITO FLOTANTE (FAB)
   ========================================================================== */
.fab-cart {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent);
    color: #000;
    border-radius: 30px;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(245, 176, 65, 0.4);
    z-index: var(--z-fab);
    width: 90%;
    max-width: 400px;
    animation: slideUp 0.3s ease forwards;
}

.fab-icon { font-size: 1.5rem; }
.fab-details { display: flex; justify-content: space-between; flex-grow: 1; font-weight: 600; font-size: 1.1rem; }

/* ==========================================================================
   DRAWER / MODALES
   ========================================================================== */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: var(--z-overlay);
    animation: fadeIn 0.3s ease forwards;
}

/* Drawer del Carrito */
.cart-drawer {
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    max-height: 85vh;
    background-color: var(--surface);
    border-radius: 20px 20px 0 0;
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}
.cart-drawer.closed { transform: translateY(100%); }
.cart-drawer.open { transform: translateY(0); }

.drawer-header { padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }
.drawer-header h2 { font-size: 1.2rem; }

.cart-items { padding: 1rem; overflow-y: auto; flex-grow: 1; }
.cart-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.item-info { flex-grow: 1; }
.item-name { font-weight: 600; font-size: 0.95rem; }
.item-price { color: var(--accent); font-weight: 500; font-size: 0.9rem; }

.item-controls { display: flex; align-items: center; gap: 10px; background: var(--bg-color); border-radius: 20px; padding: 4px 8px; }
.ctrl-btn { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--text-main); font-weight: bold; }
.qty { font-weight: 600; min-width: 15px; text-align: center; }

.cart-summary { padding: 1.5rem; background-color: #171728; border-radius: 0 0 20px 20px; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 0.5rem; color: var(--text-muted); }
.summary-row.highlight span:last-child { color: var(--success); font-weight: bold; }
.summary-row.total { color: var(--text-main); font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; padding-top: 0.5rem; border-top: 1px dashed var(--border-color); }

/* Modales Nativos (Checkout y Success) */
.modal {
    margin: auto;
    background-color: var(--surface);
    color: var(--text-main);
    border: none;
    border-radius: var(--border-radius);
    padding: 0;
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    z-index: var(--z-modal);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }
.modal-content { display: flex; flex-direction: column; height: 100%; }
.modal-header { padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }

/* ==========================================================================
   FORMULARIO CHECKOUT
   ========================================================================== */
.checkout-form { padding: 1.5rem; overflow-y: auto; }
.form-group { margin-bottom: 1.2rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

.checkout-form label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.checkout-form input[type="text"],
.checkout-form input[type="tel"],
.checkout-form textarea {
    width: 100%;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}
.checkout-form input:focus, .checkout-form textarea:focus { border-color: var(--accent); outline: none; }
.checkout-form small { font-size: 0.75rem; color: #888; display: block; margin-top: 4px; }

/* Radio Buttons Premium */
.radio-group { background: var(--bg-color); padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); }
.label-title { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.radio-label { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; font-size: 0.95rem; }
.radio-label input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }

/* ==========================================================================
   ÉXITO
   ========================================================================== */
#success-modal .modal-content { padding: 2.5rem 1.5rem; }
.success-icon { font-size: 4rem; margin-bottom: 1rem; }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.main-footer { background-color: #0f0f1a; padding: 2rem 1rem; text-align: center; color: var(--text-muted); border-top: 1px solid var(--border-color); }
.main-footer h2 { color: var(--text-main); margin-bottom: 0.5rem; }
.footer-links { margin-top: 1rem; }
.footer-links a { color: var(--accent); font-weight: 500; margin: 0 5px; }

/* ==========================================================================
   MEDIA QUERIES (Desktop adapt)
   ========================================================================== */
@media (min-width: 768px) {
    .product-grid { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
    .header-container { flex-direction: row; justify-content: space-between; align-items: center; }
    .fab-cart { left: auto; right: 30px; transform: none; width: auto; min-width: 300px; bottom: 30px; }
}

@media (min-width: 1024px) {
    .product-grid { grid-template-columns: repeat(4, 1fr); }
    .cat-item { cursor: pointer; }
    .cat-item:hover { opacity: 1; transform: translateY(-2px); }
}

/* ==========================================================================
   ANIMACIONES
   ========================================================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 0.3; } 100% { opacity: 0.6; } }