/* ==========================================================================
   1. VARIABLES GLOBALES Y RESET (QUICKSAND)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #0044ff;       /* Azul eléctrico de la imagen */
    --primary-hover: #0033cc;
    --cyan: #00d2ff;          /* Celeste para badges (Hot, Carrito) */
    --red: #ff0000;
    --text-dark: #1e293b;
    --text-gray: #64748b;
    --text-light: #94a3b8;
    --bg-gray: #f4f5f8;       /* Fondo del buscador */
    --border-color: #e2e8f0;
    --white: #ffffff;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Quicksand', sans-serif; }

/* Compensa la altura de la cabecera fija (135px en PC) */
body { background-color: var(--white); color: var(--text-dark); line-height: 1.6; padding-top: 135px; }

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }

.web-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* Proteger Material Icons de la fuente global */
.material-icons {
    font-family: 'Material Icons' !important;
    font-weight: normal; font-style: normal; font-size: 24px;
    line-height: 1; letter-spacing: normal; text-transform: none;
    display: inline-block; white-space: nowrap; word-wrap: normal;
    direction: ltr; -webkit-font-smoothing: antialiased; vertical-align: middle;
}

/* Color azul para la página activa */
.nav-links a.active {
    color: var(--primary) !important; /* El azul eléctrico */
    border-bottom: 2px solid var(--primary); /* Opcional: una línea debajo */
}

/* También para el link de promo a la derecha */
.promo-link.active {
    opacity: 1;
}

/* Rotación de la flechita del perfil */
#userDropdownWrapper.active .material-icons {
    transform: rotate(180deg);
}

/* ESTILOS PARA EL MENÚ DESPLEGABLE DE USUARIO */
.user-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* El menú oculto por defecto */
.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--white, #ffffff);
    min-width: 220px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    padding: 10px 0;
    margin-top: 15px;
    
    /* Ocultamos con opacidad para poder animarlo */
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: all 0.3s ease;
    z-index: 1000;
}

/* CUANDO EL JAVASCRIPT LE PONE LA CLASE .ACTIVE -> SE MUESTRA */
.user-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    margin-bottom: 5px;
    color: var(--text-gray, #475569);
    font-size: 0.85rem;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-dark, #0f172a);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.user-dropdown-item:hover {
    background-color: var(--bg-gray, #f8fafc);
    color: var(--primary, #4f46e5);
}

/* Para que la flechita gire cuando se abre */
.user-dropdown-wrapper .material-icons {
    transition: transform 0.3s ease;
}
.user-dropdown-wrapper.active .material-icons {
    transform: rotate(180deg);
}

/* ==========================================================================
   2. CABECERA (3 NIVELES - ESTILO PC POR DEFECTO)
   ========================================================================== */
.header-wrapper {
    position: fixed; top: 0; left: 0; width: 100%;
    background: var(--white); z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* --- Nivel 1: Top Bar (Avisos grises) --- */
.top-bar {
    background-color: #f8fafc; border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem; color: var(--text-gray); padding: 6px 0;
}
.top-bar .web-container { display: flex; justify-content: space-between; align-items: center; }
.top-bar-left strong { color: var(--primary); font-weight: 700; cursor: pointer; transition: 0.2s; }
.top-bar-left strong:hover { text-decoration: underline; }
.top-bar-right { display: flex; gap: 20px; }
.top-bar-right div { display: flex; align-items: center; gap: 5px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.top-bar-right div:hover { color: var(--primary); }
.top-bar .material-icons { font-size: 14px !important; }

/* --- Nivel 2: Main Header (Logo, Buscador, Iconos) --- */
.main-header-web { padding: 15px 0; background: var(--white); }
.main-header-web .web-container { display: flex; justify-content: space-between; align-items: center; gap: 30px; }

/* Logo */
.web-logo { display: flex; align-items: center; gap: 8px; font-size: 1.6rem; font-weight: 800; color: var(--primary); flex-shrink: 0; }
.web-logo img { height: 45px; width: auto; object-fit: contain; }

/* Buscador Central */
.search-container { flex: 1; max-width: 600px; display: flex; align-items: center; }
.search-input {
    width: 100%; padding: 12px 20px; font-size: 0.9rem; font-weight: 500; color: var(--text-dark);
    background-color: var(--bg-gray); border: 1px solid var(--bg-gray); 
    border-radius: 6px 0 0 6px; outline: none; transition: 0.2s;
}
.search-input:focus { border-color: var(--primary); background-color: var(--white); }
.search-btn {
    background: var(--primary); color: var(--white); border: none; padding: 0 25px;
    height: 44px; border-radius: 0 6px 6px 0; cursor: pointer; display: flex; align-items: center; transition: 0.2s;
}
.search-btn:hover { background: var(--primary-hover); }

/* Acciones (Perfil, Carrito, Menú Hamburguesa) */
.action-icons { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
.icon-item { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-dark); font-weight: 700; transition: 0.2s; }
.icon-item:hover { color: var(--primary); }
.icon-item .material-icons { font-size: 26px !important; color: var(--text-dark); transition: 0.2s; }
.icon-item:hover .material-icons { color: var(--primary); }

.profile-img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-color); }
.cart-wrapper { position: relative; display: flex; align-items: center; }
.cart-badge {
    position: absolute; top: -5px; right: -8px;
    background: var(--cyan); color: var(--white); font-size: 10px; font-weight: 800;
    height: 18px; min-width: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--white);
}

.menu-toggle { display: none; background: transparent; border: none; color: var(--text-dark); cursor: pointer; transition: 0.2s; }
.menu-toggle:hover { color: var(--primary); }

/* --- Nivel 3: Bottom Nav Bar --- */
.bottom-nav { padding: 10px 0; background: var(--white); }
.bottom-nav .web-container { display: flex; justify-content: center; align-items: center; position: relative; }
.nav-links { display: flex; gap: 35px; align-items: center; }
.nav-links a { font-size: 1rem; font-weight: 700; color: var(--text-dark); position: relative; display: flex; align-items: center; gap: 5px; }
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.badge-hot { background: var(--red); color: white; font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: 800; text-transform: uppercase; margin-left: 3px; }

/* Ofertas del día (Derecha absoluta en PC) */
.promo-link { position: absolute; right: 20px; color: var(--primary); font-weight: 700; display: flex; align-items: center; gap: 5px; font-size: 0.95rem; }

/* Overlay fondo oscuro para menú móvil */
.nav-overlay {
    position: fixed; inset: 0; 
    background: rgba(15, 23, 42, 0.7); /* Color oscuro elegante */
    backdrop-filter: blur(3px);
    z-index: 990; /* CRUCIAL: Debe ser menor a 1000 para que el logo resalte por encima */
    opacity: 0; visibility: hidden; transition: 0.3s ease;
}
.nav-overlay.active { opacity: 1; visibility: visible; }

/* ==========================================================================
   3. ADAPTACIÓN A TABLETS (PANTALLAS MEDIANAS: 769px a 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    /* Ocultamos el Top Bar y la Promo Link para ganar espacio */
    .top-bar, .promo-link { display: none; }
    
    /* El cuerpo empieza antes porque quitamos el Top Bar */
    body { padding-top: 110px; } 

    /* Acercamos más los links */
    .nav-links { gap: 20px; }
    .nav-links a { font-size: 0.9rem; }
}

/* ==========================================================================
   4. ADAPTACIÓN A MÓVILES (PANTALLAS PEQUEÑAS: max 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* El cuerpo sube un poco porque colapsaremos componentes */
    body { padding-top: 70px; }

    /* Main Header: Solo Logo, Carrito, Perfil y Hamburguesa */
    .main-header-web { padding: 12px 0; }
    .main-header-web .web-container { gap: 15px; }
    
    .web-logo { font-size: 1.3rem; }
    .web-logo img { height: 35px; }

    /* Ocultar Buscador y textos en la barra principal móvil */
    .search-container { display: none; }
    .icon-item span.cart-price, .icon-item span.user-name { display: none; }
    
    /* Aparece el botón hamburguesa */
    .menu-toggle { display: block; }
    .menu-toggle .material-icons { font-size: 30px !important; }

    /* MENU LATERAL (AHORA EMPIEZA DEBAJO DE LA CABECERA) */
    .bottom-nav {
        position: absolute; /* En lugar de fixed, para que dependa de la cabecera */
        top: 100%;          /* Empieza exactamente donde termina la línea blanca de la cabecera */
        left: -100%;        /* Escondido a la izquierda */
        width: 280px; 
        height: 100vh; 
        background: var(--white);
        box-shadow: 10px 10px 20px rgba(0,0,0,0.15); 
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 995;       /* Menor al logo, mayor al fondo oscuro */
        padding: 0; 
        display: flex; 
        flex-direction: column;
        border-top: 1px solid var(--border-color);
        overflow-y: auto;
    }
    .bottom-nav.active { left: 0; }
    
    .bottom-nav .web-container { padding: 0; width: 100%; }

    /* Diseño de los enlaces del menú lateral */
    .nav-links { flex-direction: column; gap: 0; width: 100%; }
    .nav-links li { width: 100%; border-bottom: 1px solid #f1f5f9; }
    .nav-links a { 
        padding: 18px 20px; width: 100%; font-size: 1.05rem; 
        display: flex; justify-content: space-between;
    }
    .nav-links a:active { background-color: var(--bg-gray); color: var(--primary); }
    .nav-links a .material-icons { display: block !important; color: #cbd5e1; } /* Muestra flechitas */

    /* Botón especial de ofertas en móvil */
    .promo-link {
        position: static; display: flex; padding: 15px 20px; width: 100%;
        margin-top: 20px; background: #f8fafc; justify-content: center;
        border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color);
    }
}

/* ==========================================================================
   5. ADAPTACIÓN A MÓVILES MUY PEQUEÑOS (SMARTPHONES ESTRECHOS: max 480px)
   ========================================================================== */
@media (max-width: 480px) {
    .web-logo span { display: none; } /* Ocultar el texto "Sialab Medic", dejar solo el icono/imagen */
    .action-icons { gap: 10px; }
    .icon-item .material-icons { font-size: 24px !important; }
}

/* =========================================================
   BOTÓN FLOTANTE DE WHATSAPP
   ========================================================= */
.whatsapp-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: #25d366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 2000; /* Por encima de la cabecera y modales */
    transition: all 0.3s ease;
    animation: pulse-wa 2s infinite;
}

.whatsapp-btn img {
    width: 35px;
    height: 35px;
}

.whatsapp-btn:hover {
    transform: scale(1.1);
    background-color: #128c7e;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Tooltip (El globito de texto) */
.wa-tooltip {
    position: absolute;
    right: 75px;
    background: #1e293b;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    box-shadow: var(--shadow-md);
}

/* Triángulo del globito */
.wa-tooltip::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid #1e293b;
}

.whatsapp-btn:hover .wa-tooltip {
    opacity: 1;
    visibility: visible;
    right: 80px;
}

/* Animación de Pulso */
@keyframes pulse-wa {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* Ajuste para móviles para que no tape contenido importante */
@media (max-width: 768px) {
    .whatsapp-btn {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }
    .wa-tooltip { display: none; } /* Ocultar tooltip en móvil */
}

/* --- BUSCADOR INTELIGENTE --- */
.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--bg-gray);
    border-radius: 50px; /* Estilo cápsula */
    padding: 2px 15px;
    border: 1px solid transparent;
    transition: 0.3s;
}

.search-input-group:focus-within {
    background: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.search-main-icon { color: var(--text-light); margin-right: 10px; }

.search-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    padding: 12px 0;
    font-size: 0.95rem;
    outline: none;
}

.search-action-btn {
    background: none;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 5px;
    border-radius: 50%;
    transition: 0.2s;
}

.search-action-btn:hover { background: #e2e8f0; color: var(--primary); }

/* --- LISTA DE SUGERENCIAS MEJORADA --- */
.search-suggestions {
    position: absolute;
    top: 100%;
    
    /* 1. Centramos el contenedor */
    left: 50%;
    transform: translateX(-50%);
    
    /* 2. Definimos un ancho que deje margen (20px a cada lado) */
    width: calc(100% - 40px); 
    
    /* 3. Evitamos que en pantallas gigantes sea demasiado ancho */
    max-width: 600px; 
    
    background: white;
    border-radius: 15px;
    margin-top: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    max-height: 450px;
    overflow-y: auto;
    display: none; /* Se activa vía JS */
    border: 1px solid var(--border-color);
}

.suggestion-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    gap: 15px;
    cursor: pointer;
    transition: 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: #f8fafc; }

.suggestion-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    background: white;
    border-radius: 8px;
    border: 1px solid #eee;
}

.suggestion-info { flex: 1; display: flex; flex-direction: column; }
.suggestion-name { font-weight: 700; font-size: 0.9rem; color: var(--text-dark); margin-bottom: 2px; }
.suggestion-brand { font-size: 0.75rem; color: var(--text-light); text-transform: uppercase; font-weight: 800; }

.suggestion-price {
    font-weight: 800;
    color: var(--primary);
    font-size: 0.95rem;
    white-space: nowrap;
}

/* ESTILOS DEL CARRITO LATERAL */
.cart-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 4000; opacity: 0; visibility: hidden; transition: 0.3s; }
.cart-overlay.active { opacity: 1; visibility: visible; }

.side-cart { position: fixed; top: 0; right: -400px; width: 100%; max-width: 400px; height: 100vh; background: white; z-index: 4001; display: flex; flex-direction: column; transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: -5px 0 25px rgba(0,0,0,0.1); }
.side-cart.active { right: 0; }

.cart-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.cart-header h3 { margin: 0; font-weight: 800; color: var(--text-dark); }
.close-cart-btn { background: none; border: none; cursor: pointer; color: var(--text-gray); }

.cart-items { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.empty-cart-msg { text-align: center; color: var(--text-light); margin-top: 50px; font-weight: 500; }

.cart-item { display: flex; gap: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; }
.cart-item-img { width: 70px; height: 70px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border-color); }
.cart-item-info { flex: 1; }
.cart-item-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 5px; color: var(--text-dark); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;}
.cart-item-price { color: var(--primary); font-weight: 800; font-size: 0.95rem; }
.cart-item-qty { display: flex; align-items: center; gap: 10px; margin-top: 5px; }
.btn-remove-item { color: #ef4444; background: none; border: none; cursor: pointer; font-size: 0.8rem; font-weight: 700; padding: 0; }

.cart-footer { padding: 20px; border-top: 1px solid var(--border-color); background: var(--bg-gray); }
.cart-total-box { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; font-size: 1.2rem; font-weight: 800; color: var(--text-dark); }
.btn-checkout { width: 100%; background: var(--primary); color: white; border: none; padding: 15px; border-radius: 12px; font-weight: 800; font-size: 1.1rem; cursor: pointer; transition: 0.2s; }
.btn-checkout:hover { background: var(--primary-hover); }