@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }
html { scroll-behavior: smooth; /* Scroll suave de fábrica */ }
body { background: #f4f4f4; padding-bottom: 120px; }

/* --- HEADER GIGANTE Y ESTABLE --- */
.main-header {
    background: linear-gradient(135deg, #8b0000 0%, #e63946 100%);
    padding: 20px;
    display: flex;
    justify-content: center; /* Centrado horizontal */
    align-items: center;    /* Centrado VERTICAL de todos los hijos */
    position: relative;
    min-height: 200px; /* Altura considerable */
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 1002; /* Capa más alta para el header */
}

.header-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    align-items: center; /* Asegura centrado vertical dentro del contenedor */
    justify-content: center;
    position: relative;
}

/* Alineación del Logo (Corregido) */
.logo-left {
    position: absolute;
    left: 20px; /* Separación del borde izq */
    /* Eliminamos top:10px y usamos centrado vertical absoluto */
    top: 50%;
    transform: translateY(-50%); /* Truco clásico para centrar verticalmente */
    
    height: 100px; /* Tamaño del logo */
    width: auto;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.2));
    transition: transform 0.2s ease;
}

.logo-left:hover {
    transform: translateY(-50%) scale(1.05); /* Mantiene centrado al hacer hover */
}

/* Alineación del Letrero Central (Corregido) */
.title-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center; /* Centrado vertical del letrero */
    padding: 0 140px; /* Espacio para que el logo no toque el título */
}

.title-center {
    height: auto;
    width: 100%;
    max-width: 300px; /* Ancho ideal para tus letreros horizontales */
    object-fit: contain;
}

/* --- BUSCADOR FIJO (STICKY) --- */
.search-bar {
    background: white;
    padding: 15px;
    position: sticky; /* Se queda pegado arriba sin brincos */
    top: 0;
    z-index: 1001; /* Debajo del header pero sobre los productos */
    display: none; /* Se activa por JS en subcatálogos */
    justify-content: center;
    border-bottom: 2px solid #ddd;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.search-input-wrapper {
    width: 90%;
    max-width: 500px;
    position: relative;
    display: flex;
    align-items: center;
}

#searchInput {
    width: 100%;
    padding: 14px 45px 14px 25px;
    border-radius: 30px;
    border: 2px solid #ddd;
    font-size: 16px;
    outline: none;
}

.search-icon {
    position: absolute;
    right: 20px;
    font-size: 20px;
    color: #888;
}

/* --- MENÚ DE CATEGORÍAS (GRIDS) --- */
.content { padding: 40px 20px; max-width: 1100px; margin: 0 auto; }
.grid-menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

.card-btn {
    background: white; border: 2px solid #8b0000; padding: 45px 10px;
    border-radius: 20px; text-align: center; cursor: pointer;
    font-weight: bold; color: #8b0000; transition: 0.2s;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}

.card-btn:active { background: #8b0000; color: white; transform: scale(0.95); }

/* --- PRODUCTOS (TARJETAS GRANDES) --- */
.grid-products { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); 
    gap: 30px; 
    margin-top: 30px; 
}

.p-card { 
    background: white; padding: 20px; border-radius: 20px; 
    text-align: center; box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    display: flex; flex-direction: column; justify-content: space-between;
    height: 100%;
}

.p-card img { width: 100%; height: 220px; object-fit: contain; margin-bottom: 15px; }
.p-card h3 { font-size: 1.1rem; height: 3.2rem; overflow: hidden; margin-bottom: 15px; line-height: 1.2; }

.btn-add { 
    background: #e63946; color: white; border: none; padding: 15px; 
    border-radius: 12px; cursor: pointer; font-weight: bold; font-size: 1rem;
}
/* --- BOTONES FLOTANTES (CORREGIDO) --- */

/* Carrito Flotante (Base) */
.cart-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #e63946;
    color: white;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    z-index: 1005;
    border: 2px solid white;
    /* ESTO ES LO QUE ANCLA EL CONTADOR */
    position: fixed; 
}

#cart-count {
    position: absolute;
    /* Ajuste para que quede sobre el borde */
    top: -2px; 
    right: -2px;
    background: #333;
    color: white; /* Aseguramos color de texto */
    font-size: 14px;
    font-weight: bold;
    min-width: 25px; /* Para que sea un círculo perfecto */
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid white;
}

/* Botón Volver Arriba (Terracota) - ALINEADO PERFECTO */
#btnTop {
    display: none; 
    position: fixed;
    right: 30px;   
    bottom: 115px; 
    width: 70px;
    height: 70px;
    z-index: 1004;
    border: 2px solid white;
    background-color: #952519; 
    color: white;
    cursor: pointer;
    border-radius: 50%;
    font-size: 25px;
    box-shadow: 0px 4px 10px rgba(0,0,0,0.3);
    transition: background 0.3s, transform 0.2s;
    /* FLEXBOX PARA CENTRAR EL TRIÁNGULO */
    align-items: center;
    justify-content: center;
}

#btnTop:hover {
    background-color: #5D2906;
    transform: scale(1.05);
}

/* Modal del Carrito */
.cart-modal { position: fixed; bottom: 120px; right: 30px; background: white; width: 320px; padding: 20px; border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); display: none; z-index: 1006; }
.btn-back { background: #333; color: white; border: none; padding: 15px; border-radius: 30px; width: 100%; cursor: pointer; font-weight: bold; margin-bottom: 20px; }
.btn-whatsapp { background: #25d366; color: white; border: none; padding: 15px; width: 100%; border-radius: 10px; font-weight: bold; cursor: pointer; margin-top: 10px; }

/* --- RESPONSIVO --- */
@media (max-width: 650px) {
    .main-header { padding: 20px 10px; min-height: 140px; }
    .logo-left { height: 60px; left: 10px; }
    .title-wrapper { padding: 0 10px; margin-top: 40px; /* Baja el título para no chocar con el logo en móvil */ }
    .title-center { max-width: 280px; }
    .grid-menu { gap: 10px; grid-template-columns: 1fr; /* Una columna en móvil muy pequeño */ }
    .card-btn { padding: 30px 10px; }
    
    /* Botones más pequeños en móvil */
    .cart-fab, #btnTop { width: 60px; height: 60px; right: 20px; }
    .cart-fab { bottom: 20px; }
    #btnTop { bottom: 95px; /* 20 + 60 + 15 */ right: 20px; }
}
