/* Variables CSS */
:root {
    --bg-color: #121212;
    --surface-color: #1E1E1E;
    --primary-color: #FF5722;
    --text-light: #FFFFFF;
    --text-muted: #B0B0B0;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-light);
    overflow-x: hidden; /* Evita scroll horizontal */
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    background-color: var(--surface-color);
    border-bottom: 2px solid var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    height: 60px; /* Ajusta según el tamaño de tu logo */
}

/* Navegación y Filtros */
.nav-filtros {
    display: flex;
    gap: 1rem;
    overflow-x: auto; /* Permite scroll solo en botones si la pantalla es muy chica */
    padding-bottom: 5px;
}

.nav-filtros::-webkit-scrollbar {
    height: 4px;
}
.nav-filtros::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
}

.filtro-btn {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.filtro-btn.activo, .filtro-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Icono Carrito */
.carrito-icono {
    position: relative;
    cursor: pointer;
    font-size: 1.5rem;
}

.contador {
    position: absolute;
    top: -8px;
    right: -10px;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 50%;
}

/* Grilla de Productos (Responsiva) */
.contenedor-productos {
    display: grid;
    /* Esto crea columnas automáticas. Min 250px, Max 1 fracción. Elimina el scroll horizontal */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 2rem 5%;
    max-width: 1200px;
    margin: 0 auto;
}

.card-producto {
    background-color: var(--surface-color);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    transition: var(--transition);
    border: 1px solid transparent;
}

.card-producto:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 5px 15px rgba(255, 87, 34, 0.2);
}

.card-producto img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.card-producto h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.precio {
    color: var(--primary-color);
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.btn-agregar {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    transition: var(--transition);
}

.btn-agregar:hover {
    background-color: #e64a19;
}

/* Panel del Carrito */
.panel-carrito {
    position: fixed;
    top: 0;
    right: -400px;
    width: 350px;
    height: 100%; /* Respaldo para navegadores antiguos */
    height: 100dvh; /* <-- CAMBIO AQUÍ (Dynamic Viewport Height) */
    background-color: var(--surface-color);
    z-index: 1000;
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.panel-carrito.abierto {
    right: 0;
}

.carrito-header {
    display: flex;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #333;
}

.cerrar-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
}

.carrito-items {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.item-carrito {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #333;
}

.item-info h4 {
    font-size: 1rem;
}

.item-info p {
    color: var(--primary-color);
}

.btn-eliminar {
    background: none;
    border: none;
    color: #ff3333;
    cursor: pointer;
}

.carrito-footer {
    padding: 1.5rem;
    border-top: 1px solid #333;
}

.total-container {
    display: flex;
    justify-content: space-between;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.btn-whatsapp {
    background-color: #25D366; /* Color oficial de WhatsApp */
    color: white;
    border: none;
    padding: 1rem;
    width: 100%;
    border-radius: 5px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-whatsapp {
    background-color: #25D366; 
    color: white;
    border: none;
    padding: 0.8rem; /* Reducimos levemente el padding para dar más aire al texto */
    width: 100%;
    border-radius: 5px;
    font-size: 1rem; /* Ajustamos el tamaño base para que quepa mejor */
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center; /* Obliga al texto a centrarse si salta a otra línea */
    gap: 8px; /* Espacio entre el icono y el texto */
    line-height: 1.2; /* Mejora la legibilidad si el texto se divide en dos líneas */
    transition: var(--transition); /* Suaviza el efecto hover */
}

.btn-whatsapp:hover {
    background-color: #128C7E;
}

/* Regla especial para celulares con pantallas muy pequeñas */
@media (max-width: 400px) {
    .btn-whatsapp {
        font-size: 0.9rem; /* Achica un poco más la letra solo en móviles pequeños */
        padding: 0.7rem;
    }
}

/* --- Modal de Detalles del Producto --- */
.modal-producto {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85); /* Fondo oscuro transparente */
    z-index: 2000; /* Siempre por encima de todo */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-producto.activo {
    opacity: 1;
    visibility: visible;
}

.modal-contenido {
    background-color: var(--surface-color);
    border: 1px solid var(--primary-color);
    border-radius: 10px;
    width: 90%;
    max-width: 450px;
    padding: 2rem;
    position: relative;
    transform: scale(0.8);
    transition: var(--transition);
    max-height: 85vh;
    overflow-y: auto; /* Scroll interno si el texto es muy largo */
}

.modal-producto.activo .modal-contenido {
    transform: scale(1);
}

.cerrar-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.5rem;
}

.modal-img {
    width: 100%;
    max-width: 180px;
    display: block;
    margin: 0 auto 1rem;
    border-radius: 8px;
}

.modal-titulo {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.modal-texto {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-light);
    text-align: left;
}

/* Para resaltar palabras clave en el texto */
.modal-texto strong {
    color: var(--primary-color);
}

/* --- Botón Flotante de WhatsApp --- */
.btn-flotante-wsp {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #25D366; /* Verde oficial */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 800; /* Mantiene el botón visible, pero debajo del modal o carritos */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
}

.btn-flotante-wsp:hover {
    transform: scale(1.1); /* Efecto de que crece un poco al pasar el mouse */
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.5); /* Sombra verde sutil */
}

    /* --- VISTA MÓVIL: 2 COLUMNAS --- */
@media (max-width: 768px) {

    /* ¡NUEVO! Reestructuramos el encabezado a dos líneas */
    .header {
        flex-wrap: wrap; /* Permite que los elementos bajen a otra línea */
        padding: 0.8rem 5%;
    }
    
    .logo-container {
        order: 1; /* Logo arriba a la izquierda */
    }
    
    .carrito-icono {
        order: 2; /* Carrito arriba a la derecha */
    }
    
    .nav-filtros {
        order: 3; /* Botones pasan a la línea de abajo */
        width: 100%; /* Ocupan todo el ancho disponible */
        margin-top: 15px; /* Separación con el logo y el carrito */
        padding-bottom: 5px;
    }

    /* DE AQUÍ EN ADELANTE, MANTÉN LO QUE YA TENÍAS */
    .filtro-btn {
        font-size: 0.6rem; 
        padding: 0.3rem 0.6rem; 
    }
    .contenedor-productos {
        /* Fuerza a tener exactamente 2 columnas del mismo tamaño */
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px; /* Reduce el espacio en blanco entre las dos tarjetas */
        padding: 1.5rem 3%; /* Aprovecha mejor los bordes de la pantalla del celular */
    }

    .card-producto {
        padding: 0.6rem; /* Achica el margen interno de la tarjeta */
    }

    .card-producto h3 {
        font-size: 0.9rem; /* Achica el título del producto */
        margin-bottom: 0.3rem;
    }

    .card-producto p {
        font-size: 0.75rem !important; /* Achica la descripción y stock */
    }

    .card-producto .precio {
        font-size: 1.1rem; /* Achica el precio */
        margin-bottom: 0.6rem;
    }

    .btn-agregar {
        padding: 0.5rem;
        font-size: 0.75rem; /* Botón más pequeño para que no se desborde */
    }
    .btn-flotante-wsp {
        width: 55px;
        height: 55px;
        bottom: 15px;
        right: 15px;
    }
    /* Ajustes del panel del carrito para celular */
    .panel-carrito {
        width: 100%; /* Ocupa todo el ancho */
        right: -100%; /* Se esconde completamente al cerrarlo */
    }
}

/* --- NUEVOS ELEMENTOS: Menú Hamburguesa y Carrito Flotante --- */
.menu-mobile-btn {
    display: none; /* Oculto en PC */
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 2.2rem;
    cursor: pointer;
}

.carrito-flotante {
    position: fixed;
    bottom: 20px;
    left: 20px; /* Abajo a la izquierda, como pediste */
    background-color: var(--surface-color);
    border: 2px solid var(--primary-color);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 800;
    cursor: pointer;
    transition: var(--transition);
}

.carrito-flotante span.material-icons {
    color: var(--primary-color);
    font-size: 1.8rem;
}

.carrito-flotante .contador {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 50%;
}

/* --- AJUSTES EXCLUSIVOS PARA MÓVIL --- */
@media (max-width: 768px) {
    .menu-mobile-btn {
        display: block; /* Muestra el botón de hamburguesa en el celular */
    }

    .header {
        position: relative; /* Para poder posicionar el menú debajo */
    }

    .nav-filtros {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--surface-color);
        flex-direction: column;
        padding: 1rem;
        gap: 0.8rem;
        border-bottom: 2px solid var(--primary-color);
        box-shadow: 0 10px 15px rgba(0,0,0,0.5);
        display: none; /* Menú oculto por defecto */
        z-index: 99;
    }

    /* Esta clase la agregaremos con JavaScript para abrir el menú */
    .nav-filtros.menu-abierto {
        display: flex; 
    }

    .filtro-btn {
        width: 100%;
        text-align: left;
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        border-radius: 5px;
        background-color: #2a2a2a; /* Fondo más claro para los botones del menú */
    }

    .carrito-flotante {
        width: 55px;
        height: 55px;
        bottom: 15px;
        left: 15px;
    }
}