/* ==========================================================================
   TIENDA.CSS - ESTILOS DINÁMICOS PARA LA TIENDA EN LÍNEA
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. MOTOR DE TEMAS (Variables dinámicas)
   -------------------------------------------------------------------------- */
:root {
    /* Tema por Defecto (Todos) */
    --bg-tienda: #f8fafc;
    --accent-tienda: #d97706; /* Ámbar Las Haciendas */
    --accent-light: #fef3c7;
    
    /* Colores Fijos Globales */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --danger: #e11d48;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.1);
}

/* Mutaciones de Color por Categoría */
body.tema-Cremeria { --bg-tienda: #fdfbf7; --accent-tienda: #059669; --accent-light: #d1fae5; } /* Verde Fresco */
body.tema-Bebidas { --bg-tienda: #f0f9ff; --accent-tienda: #2563eb; --accent-light: #dbeafe; } /* Azul Hielo */
body.tema-Botanas_Dulces { --bg-tienda: #fff7ed; --accent-tienda: #ea580c; --accent-light: #ffedd5; } /* Naranja Vibrante */
body.tema-Abarrotes { --bg-tienda: #fefce8; --accent-tienda: #ca8a04; --accent-light: #fef08a; } /* Amarillo/Dorado */
body.tema-Lacteos { --bg-tienda: #f8fafc; --accent-tienda: #0284c7; --accent-light: #e0f2fe; } /* Azul Claro */
body.tema-Enlatados { --bg-tienda: #f1f5f9; --accent-tienda: #475569; --accent-light: #e2e8f0; } /* Gris Pizarra */
body.tema-Pan_Tortillas { --bg-tienda: #fef8f3; --accent-tienda: #b45309; --accent-light: #fef3c7; } /* Café Trigo */
body.tema-Limpieza { --bg-tienda: #f0fdf4; --accent-tienda: #10b981; --accent-light: #d1fae5; } /* Menta Limpio */
body.tema-Higiene { --bg-tienda: #faf5ff; --accent-tienda: #9333ea; --accent-light: #f3e8ff; } /* Morado Suave */
body.tema-Mascotas { --bg-tienda: #fff1f2; --accent-tienda: #be123c; --accent-light: #ffe4e6; } /* Rosa Fuerte */

/* --------------------------------------------------------------------------
   2. CONFIGURACIÓN BASE
   -------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-tienda);
    color: var(--text-main);
    transition: background-color 0.4s ease; /* Transición suave al cambiar categoría */
    padding-bottom: 80px; /* Espacio para el footer/toast */
}

/* --------------------------------------------------------------------------
   3. NAVBAR PÚBLICO
   -------------------------------------------------------------------------- */
.navbar {
    background: var(--card-bg);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.brand-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Poppins', sans-serif;
}

.brand-logo i {
    color: var(--accent-tienda);
    transition: color 0.4s ease;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-item {
    color: var(--text-muted);
    font-size: 1.3rem;
    text-decoration: none;
    transition: 0.2s;
}

.nav-item:hover, .nav-item.active {
    color: var(--accent-tienda);
}

.nav-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-tienda);
}

.cart-icon-wrapper {
    position: relative;
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--card-bg);
}

/* --------------------------------------------------------------------------
   4. SLIDER DE CATEGORÍAS
   -------------------------------------------------------------------------- */
.category-slider {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 20px;
    scrollbar-width: none; /* Oculta scrollbar en Firefox */
}

.category-slider::-webkit-scrollbar {
    display: none; /* Oculta scrollbar en Chrome/Safari */
}

.cat-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: 0.3s;
    box-shadow: var(--shadow-sm);
}

.cat-btn.active {
    background: var(--accent-tienda);
    color: white;
    border-color: var(--accent-tienda);
}

/* --------------------------------------------------------------------------
   5. GRID DE PRODUCTOS Y TARJETAS
   -------------------------------------------------------------------------- */
.store-container {
    max-width: 1200px;
    margin: 0 auto;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    padding: 0 20px 20px 20px;
}

.product-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: 0.3s;
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    border-color: var(--accent-light);
}

.card-img-wrapper {
    position: relative;
    width: 100%;
    height: 140px;
    padding: 15px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.p-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.badge-promo {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

.card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.p-brand {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.p-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    margin-bottom: 8px;
    flex: 1; /* Empuja los precios y botones hacia abajo */
}

.p-price-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.precio-tachado {
    font-size: 0.75rem;
    color: #94a3b8;
    text-decoration: line-through;
}

.precio-final {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--accent-tienda);
    transition: color 0.4s ease;
}

.precio-final small {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   6. SELECTORES (PIEZAS Y GRANEL)
   -------------------------------------------------------------------------- */

/* Selector de Piezas Clásico */
.selector-piezas {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 10px;
}

.btn-qty {
    background: white;
    border: 1px solid var(--border-color);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    transition: 0.2s;
}

.btn-qty:active {
    background: var(--border-color);
}

.selector-piezas input {
    width: 35px;
    text-align: center;
    border: none;
    background: transparent;
    font-weight: 700;
    font-size: 0.9rem;
    outline: none;
    color: var(--text-main);
}

/* Selector a Granel (Cremería) - El Truco del Radio Button */
.selector-granel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 10px;
}

.granel-pill input[type="radio"] {
    display: none; /* Ocultamos el circulito nativo feo */
}

.granel-pill span {
    display: block;
    text-align: center;
    padding: 6px 0;
    font-size: 0.7rem;
    font-weight: 700;
    background: #f1f5f9;
    color: var(--text-muted);
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: 0.2s;
}

/* Cuando el input oculto está checked, modificamos el span adyacente */
.granel-pill input[type="radio"]:checked + span {
    background: var(--accent-light);
    color: var(--accent-tienda);
    border-color: var(--accent-tienda);
}

/* Botón Final de Agregar */
.btn-add {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: var(--accent-tienda);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.4s ease;
}

.btn-add:active {
    transform: scale(0.96);
}

/* --------------------------------------------------------------------------
   7. EXTRAS (Cargador y Notificación)
   -------------------------------------------------------------------------- */
.loader-view {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.loader-view i {
    color: var(--accent-tienda);
    font-size: 1.5rem;
    margin-bottom: 10px;
    display: block;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px dashed var(--border-color);
}

/* Toast de "Agregado al Carrito" */
.toast-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 100px); /* Oculto abajo */
    background: var(--text-main);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    white-space: nowrap;
}

.toast-notification.show {
    transform: translate(-50%, 0); /* Sube a la pantalla */
    opacity: 1;
}

.toast-notification i {
    color: #4ade80; /* Palomita verde */
    font-size: 1.1rem;
}

/* --------------------------------------------------------------------------
   8. RESPONSIVE (Para celulares más grandes o tablets)
   -------------------------------------------------------------------------- */
@media (min-width: 500px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* --------------------------------------------------------------------------
   9. BÚSQUEDA Y BANNERS (NUEVO DISEÑO PREMIUM)
   -------------------------------------------------------------------------- */
.search-wrapper {
    padding: 15px 20px 5px 20px;
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    padding: 14px 45px; /* Más espacio interior para respirar */
    border-radius: 30px; /* Forma de píldora perfecta */
    border: 2px solid transparent; /* Borde invisible para la transición */
    background: var(--card-bg);
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); /* Sombra suave y profunda */
    color: var(--text-main);
}

.search-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.search-input:focus {
    border-color: var(--accent-tienda);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08), 0 0 0 4px var(--accent-light);
    transform: translateY(-1px); /* Ligero efecto de elevación al tocar */
}

.search-icon {
    position: absolute;
    left: 38px;
    /* Ajuste matemático perfecto para centrar en base al padding del contenedor (15px arriba, 5px abajo) */
    top: calc(50% + 5px); 
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 1.1rem;
    pointer-events: none; /* Evita que el click se atore en el icono */
    transition: color 0.3s ease;
}

/* Magia: La lupa cambia al color del tema dinámico cuando seleccionas el buscador */
.search-input:focus ~ .search-icon {
    color: var(--accent-tienda);
}

.clear-icon {
    position: absolute;
    right: 35px;
    top: calc(50% + 5px);
    transform: translateY(-50%);
    color: #cbd5e1;
    cursor: pointer;
    display: none; /* Se oculta hasta que haya texto */
    font-size: 0.9rem;
    transition: all 0.2s;
    background: #f1f5f9;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 24px; /* Centra la "X" en su circulito */
}

.clear-icon:hover { 
    background: var(--danger);
    color: white; 
    transform: translateY(-50%) scale(1.1); /* Efecto de rebote al pasar el mouse */
}

.banners-wrapper {
    padding: 10px 20px;
    max-width: 800px;
    margin: 0 auto;
}

.banner-slider {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-radius: 16px;
    padding-bottom: 5px; /* Espacio para la sombra */
}

.banner-slider::-webkit-scrollbar { display: none; }

.banner-slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 2 / 1;
    position: relative;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
