@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #689F38;        
    --primary-dark: #33691E;   
    --secondary: #5D4037;      
    --secondary-light: #8D6E63;
    --accent: #AED581;         
    --bg-main: #F4F7F6;
    --surface: #FFFFFF;
    --text-main: #2D3748;
    --text-muted: #718096;
    --border: #E2E8F0;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-pill: 50px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08);
    --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   1. MODO OSCURO (Global)
========================================= */
body.dark-theme {
    --bg-main: #0f172a;       
    --surface: #1e293b;       
    --text-main: #f8fafc;     
    --text-muted: #94a3b8;    
    --border: #334155;        
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.4);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.5);
    --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.6);
}

body { font-family: 'Poppins', sans-serif; background-color: var(--bg-main); color: var(--text-main); margin: 0; line-height: 1.6; }

/* Textos Globales en Modo Oscuro */
body.dark-theme h1, body.dark-theme h2, body.dark-theme h3, body.dark-theme h4 { color: var(--text-main); }
body.dark-theme p { color: var(--text-muted); }

/* Tarjetas Globales (Para Nosotros y Contacto) */
body.dark-theme .card, body.dark-theme .modal-content { background-color: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); }

/* Formulario Distribuidor Dark */
body.dark-theme .distributor-section { background: linear-gradient(135deg, #2D1A11 0%, #462c21 100%); box-shadow: inset 0 0 20px rgba(0,0,0,0.5); }
body.dark-theme #distribuidorForm { background: var(--surface) !important; box-shadow: 0 15px 35px rgba(0,0,0,0.4) !important; border: 1px solid var(--border); }
body.dark-theme .distributor-section p { color: #cbd5e0 !important; }

/* Buscador Dark Mode Perfeccionado */
body.dark-theme .search-input, body.dark-theme .input-form { background-color: var(--surface) !important; color: var(--text-main) !important; border: 1px solid var(--border) !important; }
body.dark-theme .search-input::placeholder, body.dark-theme .input-form::placeholder { color: var(--text-muted) !important; }
body.dark-theme .search-input:focus, body.dark-theme .input-form:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(104, 159, 56, 0.2) !important; }
body.dark-theme .search-icon { color: var(--text-muted) !important; }

/* Switch Dark Mode */
.theme-switch { position: relative; width: 60px; height: 30px; background: #e2e8f0; border-radius: 50px; cursor: pointer; display: flex; align-items: center; padding: 0 5px; transition: var(--transition); border: none; margin-left: 10px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
body.dark-theme .theme-switch { background: #334155; box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); }
.switch-circle { width: 22px; height: 22px; background: white; border-radius: 50%; position: absolute; left: 4px; transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); box-shadow: 0 2px 4px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: #f59e0b; }
body.dark-theme .switch-circle { transform: translateX(30px); background: #1e293b; color: #cbd5e0; }

/* =========================================
   2. NAVBAR
========================================= */
.navbar { background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(10px); padding: 12px 5%; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 4px 20px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 1000; }
body.dark-theme .navbar { background: rgba(30, 41, 59, 0.95); }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-text { display: flex; flex-direction: column; justify-content: center; }
.brand-title { font-size: 1.4rem; font-weight: 800; color: #689F38; line-height: 1.1; letter-spacing: -0.5px; }
body.dark-theme .brand-title { color: var(--accent); }
.brand-subtitle { font-size: 0.65rem; color: #64748b; font-weight: 600; letter-spacing: 0.5px; margin-top: 2px; }

.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-item { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #475569; font-size: 0.95rem; font-weight: 600; padding: 8px 20px; border-radius: var(--radius-pill); transition: var(--transition); border: 1px solid transparent; }
.nav-item i { font-size: 1.1rem; color: #64748b; transition: var(--transition); }

body.dark-theme .nav-item:not(.active) { color: #cbd5e0; }
.nav-item:hover { color: var(--primary-dark); background-color: #f1f5f9; border-color: #e2e8f0; }
body.dark-theme .nav-item:hover { background-color: #334155; border-color: #475569; }
.nav-item:hover i { color: var(--primary); }

.nav-item.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #ffffff !important; box-shadow: 0 4px 12px rgba(104, 159, 56, 0.35); border: none; }
.nav-item.active i { color: #ffffff !important; }
.nav-item.active:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(104, 159, 56, 0.45); }
.nav-links .btn-primary { margin-left: 10px; padding: 8px 20px; font-size: 0.95rem; box-shadow: 0 4px 12px rgba(104, 159, 56, 0.25); }

/* =========================================
   3. BOTONES Y FORMULARIOS GLOBALES
========================================= */
/* Añadido justify-content: center; para garantizar que todo el texto y los iconos estén perfectamente centrados */
.btn-primary { background: var(--primary); color: white; padding: 10px 24px; border-radius: var(--radius-pill); text-decoration: none; border: none; font-weight: 600; cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 10px rgba(104, 159, 56, 0.3); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 6px 15px rgba(104, 159, 56, 0.4); }
.btn-secondary { background: var(--secondary); color: white; border: none; padding: 10px 24px; border-radius: var(--radius-pill); font-weight: 600; cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-secondary:hover { background: var(--secondary-light); }

.input-form { width: 100%; padding: 12px 15px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-main); font-family: inherit; transition: var(--transition); box-sizing: border-box; }
.input-form:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(104,159,56,0.1); }

/* =========================================
   4. CARRUSEL CYBERPUERTA (CENTERED)
========================================= */
.carousel-container { position: relative; width: 100%; height: 400px; margin: 1.5rem 0 3rem 0; overflow: hidden; background: transparent; }
.carousel-slide { display: flex; width: max-content; height: 100%; transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1); align-items: center; }
.carousel-item { width: 70vw; max-width: 1100px; height: 100%; margin: 0 10px; position: relative; flex-shrink: 0; border-radius: 20px; overflow: hidden; cursor: pointer; opacity: 0.4; transform: scale(0.88); transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1); box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.carousel-item.active { opacity: 1; transform: scale(1); box-shadow: 0 15px 35px rgba(0,0,0,0.25); cursor: default; }
.carousel-item img { width: 100%; height: 100%; object-fit: cover; }
.carousel-caption { position: absolute; bottom: 0; left: 0; width: 100%; background: linear-gradient(to top, rgba(15, 23, 42, 0.85), transparent); color: white; padding: 70px 40px 30px; text-align: left; opacity: 0; transform: translateY(30px); transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.3s; }
.carousel-item.active .carousel-caption { opacity: 1; transform: translateY(0); }
.carousel-caption h1 { margin:0; font-size: 2.5rem; font-weight: 700; text-shadow: 0 2px 4px rgba(0,0,0,0.5); letter-spacing: -0.5px;}
.carousel-caption p { margin: 5px 0 0; font-size: 1.1rem; color: var(--accent); font-weight: 500;}

.carousel-btn { position: absolute; top: 50%; transform: translateY(-50%) scale(0.8); background: #ffffff; color: var(--primary); border: none; border-radius: 50%; width: 55px; height: 55px; font-size: 1.5rem; cursor: pointer; z-index: 10; opacity: 0; visibility: hidden; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.carousel-container:hover .carousel-btn { opacity: 1; visibility: visible; transform: translateY(-50%) scale(1); }
.carousel-btn:hover { background: var(--bg-main); color: var(--primary-dark); box-shadow: 0 6px 20px rgba(0,0,0,0.3); transform: translateY(-50%) scale(1.1) !important; }
.prev { left: 4%; }
.next { right: 4%; }

@media (max-width: 768px) {
    .carousel-item { width: 85vw; } .carousel-container { height: 220px; } .carousel-caption h1 { font-size: 1.5rem; } .carousel-caption p { font-size: 0.9rem; }
    .carousel-btn { width: 40px; height: 40px; font-size: 1.2rem; opacity: 0.85; visibility: visible; transform: translateY(-50%) scale(1); } .prev { left: 10px; } .next { right: 10px; }
}

/* =========================================
   5. BUSCADOR Y FILTROS
========================================= */
.search-container { max-width: 600px; margin: 0 0 20px 0; position: relative; }
.search-input { width: 100%; padding: 12px 20px 12px 45px; border: 1px solid var(--border); border-radius: var(--radius-pill); font-size: 1rem; font-family: inherit; transition: var(--transition); box-sizing: border-box; }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(104,159,56,0.1); }
.search-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.filters-wrapper { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 30px; }
.filters-wrapper::-webkit-scrollbar { height: 6px; }
.filters-wrapper::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 10px; }
.filter-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-main); padding: 8px 16px; border-radius: var(--radius-pill); font-size: 0.9rem; cursor: pointer; white-space: nowrap; transition: var(--transition); display: flex; align-items: center; gap: 8px; }
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--secondary); color: white; border-color: var(--secondary); }

/* =========================================
   6. GRID DE PRODUCTOS Y ANIMACIÓN CASCADA
========================================= */
.container { max-width: 1280px; margin: 0 auto; padding: 2rem 5%; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2rem; }

/* Animación corregida (both asegura que sea invisible al cargar y visible al final) */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-up { animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }

.card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; transition: var(--transition); position: relative; }
.card:hover { transform: translateY(-8px); box-shadow: var(--shadow-hover); border-color: var(--accent); }
.card img { width: 100%; height: 220px; object-fit: cover; transition: transform 0.5s ease; }
.card:hover img { transform: scale(1.05); }
.card-body { padding: 1.5rem; background: var(--surface); position: relative; z-index: 2;}

.badge { background: var(--secondary); color: white; padding: 6px 12px; border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 600; position: absolute; top: 15px; right: 15px; z-index: 3; box-shadow: var(--shadow-sm); }
.badge.dorado { background: #f59e0b; color: white; }

.price-toggle { display: flex; background: var(--bg-main); border-radius: var(--radius-pill); padding: 5px; margin: 15px 0; border: 1px solid var(--border); }
.toggle-btn { flex: 1; text-align: center; padding: 8px; border-radius: var(--radius-pill); cursor: pointer; font-size: 0.9rem; font-weight: 500; transition: var(--transition); color: var(--text-muted); }
.toggle-btn.active { background: var(--surface); color: var(--primary-dark); font-weight: 600; box-shadow: var(--shadow-sm); }

.qty-control { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); height: 42px; }
.qty-btn { background: none; border: none; padding: 0 12px; cursor: pointer; color: var(--text-muted); font-size: 1rem; height: 100%; transition: 0.2s; }
.qty-btn:hover { background: #f1f5f9; color: var(--text-main); }
body.dark-theme .qty-btn:hover { background: #334155; }
.qty-input { width: 35px; border: none; text-align: center; font-weight: 600; color: var(--text-main); background: transparent; font-family: inherit; -moz-appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* =========================================
   7. EXTRAS (DISTRIBUIDOR, CARRITO, FOOTER)
========================================= */
.distributor-section { background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%); color: white; padding: 4rem 5%; border-radius: var(--radius-lg); margin-top: 4rem; box-shadow: var(--shadow-md); text-align: center; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; margin-bottom: 2rem; text-align: left; }
.footer-title { color: var(--accent); margin-bottom: 1rem; font-size: 1.1rem; }
.footer-text { color: #cbd5e0; font-size: 0.9rem; margin: 8px 0; display: flex; align-items: center; gap: 10px;}

.cart-float { position: fixed; bottom: 30px; right: 30px; background: var(--primary); color: white; width: 65px; height: 65px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; cursor: pointer; box-shadow: 0 10px 25px rgba(104,159,56,0.5); z-index: 1000; transition: var(--transition); }
.cart-float:hover { transform: scale(1.1) rotate(-5deg); background: var(--primary-dark); }
.cart-count { position: absolute; top: -5px; right: -5px; background: var(--secondary); width: 24px; height: 24px; border-radius: 50%; font-size: 0.85rem; font-weight: bold; display: flex; align-items: center; justify-content: center; border: 2px solid white; }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 2000; justify-content: center; align-items: center; }
.modal-content { background: var(--surface); padding: 2.5rem; border-radius: var(--radius-lg); width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-hover); }

/* Correcciones estéticas del Carrito para Modo Oscuro */
body.dark-theme .cart-count { border-color: var(--surface); }
body.dark-theme #checkout-form { background-color: var(--surface) !important; }
body.dark-theme #cart-items div { border-bottom-color: var(--border) !important; }

/* =========================================
   8. DISEÑO PREMIUM DEL CARRITO (MODAL)
========================================= */
.cart-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 15px 0;
    color: var(--text-main);
    gap: 15px;
}
.cart-item-row:last-child { border-bottom: none; }

.cart-item-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.cart-item-info strong { font-size: 1rem; line-height: 1.2; margin-bottom: 4px; }
.cart-item-info small { color: var(--text-muted); font-size: 0.85rem; font-weight: 500;}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Selector de Cantidad miniatura para el Carrito */
.cart-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-main);
    height: 32px;
}
.cart-qty-btn {
    background: transparent; border: none; padding: 0 10px;
    cursor: pointer; color: var(--text-main);
    font-size: 0.8rem; height: 100%; transition: 0.2s;
}
.cart-qty-btn:hover { background: #e2e8f0; }
.cart-qty-input {
    width: 30px; border: none; text-align: center; background: transparent;
    font-weight: 600; color: var(--text-main); font-size: 0.9rem;
    pointer-events: none; /* Evita que el teclado del celular estorbe */
}

/* Precio Subtotal del Item */
.cart-item-subtotal {
    font-weight: 700;
    font-size: 1.1rem;
    min-width: 70px;
    text-align: right;
    color: var(--primary-dark);
}

/* Botón de Basura Elegante */
.cart-btn-delete {
    background: #fee2e2; /* Fondo rojo clarito */
    color: #ef4444; /* Icono rojo fuerte */
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.cart-btn-delete:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
}

/* Adaptación a Modo Oscuro */
body.dark-theme .cart-item-row { border-bottom-color: var(--border); }
body.dark-theme .cart-qty-control { background: var(--surface); border-color: var(--border); }
body.dark-theme .cart-qty-btn:hover { background: #334155; }
body.dark-theme .cart-btn-delete { background: rgba(239, 68, 68, 0.15); }
body.dark-theme .cart-btn-delete:hover { background: #ef4444; color: white; }
body.dark-theme .cart-item-subtotal { color: var(--accent); }

/* Adaptación para Pantallas Pequeñas (Celulares) */
@media (max-width: 600px) {
    .cart-item-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .cart-item-actions { width: 100%; justify-content: space-between; }
}

/* =========================================
   9. DISEÑO RESPONSIVE (MÓVILES Y TABLETS)
========================================= */

/* Botón Hamburguesa Animado */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.8rem;
    color: var(--primary-dark);
    cursor: pointer;
    padding: 5px;
}

.mobile-menu-btn i {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
}

.mobile-menu-btn.open i {
    transform: rotate(180deg) scale(1.1);
    color: var(--primary);
}

body.dark-theme .mobile-menu-btn { color: var(--accent); }

@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    
    .nav-links {
        position: absolute;
        top: calc(100% + 10px);
        
        /* 🔥 EL TRUCO DEL CENTRADO PERFECTO 🔥 */
        left: 50%; 
        width: 92vw; /* Usa el 92% del ancho real de la pantalla */
        transform: translate(-50%, -15px); /* Lo centra matemáticamente y lo sube un poco */
        
        background: var(--surface);
        border-radius: var(--radius-lg);
        flex-direction: column;
        
        max-height: 0;
        opacity: 0;
        visibility: hidden;
        box-shadow: 0 15px 35px rgba(0,0,0,0.15);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        overflow: hidden; 
    }
    
    body.dark-theme .nav-links {
        border: 1px solid var(--border);
        box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    }
    
    .nav-links.active {
        max-height: 500px;
        opacity: 1;
        visibility: visible;
        /* Al abrir, mantiene el centrado y baja a su lugar original */
        transform: translate(-50%, 0); 
        padding: 20px;
    }
    
    .nav-item { 
        width: 100%; 
        padding: 14px 20px; 
        margin-bottom: 8px;
        font-size: 1.05rem;
        border-radius: var(--radius-md);
        box-sizing: border-box;
    }
    
    .nav-links .btn-primary { 
        margin-left: 0; 
        margin-top: 10px; 
        width: 100%; 
        justify-content: center; 
        padding: 14px;
        font-size: 1.05rem;
        box-sizing: border-box;
    }
    
    .theme-switch { margin: 15px auto 0; transform: scale(1.2); }
    .nav-links div[style*="width: 1px"] { display: none; } 

    .brand-title { font-size: 1.2rem; }
    .brand-subtitle { font-size: 0.6rem; }
    .about-hero, .contact-hero { padding: 3rem 5% 6rem; }
    .about-hero h1, .contact-hero h1 { font-size: 2.2rem !important; }
    .carousel-caption h1 { font-size: 1.5rem !important; }
    .stats-banner { grid-template-columns: 1fr 1fr; gap: 1rem; }
    .modal-content { width: 95%; padding: 1.5rem; box-sizing: border-box; }
}

/* =========================================
   10. BOTÓN FLOTANTE DE WHATSAPP
========================================= */
.whatsapp-float {
    position: fixed;
    width: 60px;
    height: 60px;
    bottom: 120px; /* Le damos altura para saltar el carrito */
    right: 35px;   /* Lo mandamos a la derecha */
    background-color: #25D366; 
    color: #FFF;
    border-radius: 50px;
    text-align: center;
    font-size: 35px;
    box-shadow: 0px 4px 15px rgba(37, 211, 102, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.whatsapp-float:hover {
    transform: scale(1.1); 
    color: #FFF;
    box-shadow: 0px 6px 20px rgba(37, 211, 102, 0.6);
}

/* Ajuste sutil para celulares */
@media (max-width: 768px) {
    .whatsapp-float {
        width: 55px;
        height: 55px;
        bottom: 120px; /* Altura ajustada para móviles */
        right: 31px;
        font-size: 32px;
    }
}