/**
 * Dr. Servicios - Header Component Styles
 */

/* Header Styles */
header {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    /* FIXED: Asegurar que el header tome el ancho completo */
    left: 0;
    right: 0;
}

.header-container {
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between; /* FIXED: Mejor distribución del espacio */
    height: 64px;
    position: relative;
    width: 100%;
    max-width: 100%; /* FIXED: Asegurar ancho completo en móviles */
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    /* FIXED: Eliminar position absolute para mejor alineación en móvil */
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0; /* No permitir que se reduzca */
    position: relative; /* Para z-index */
    z-index: 10; /* Por encima del texto central */
}

.logo:hover {
    opacity: 0.8;
}

.logo-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-text {
    font-size: 22px;
    font-weight: bold;
    color: #1f2937;
    /* FIXED: Centrar usando position absolute correctamente */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    pointer-events: none; /* CRÍTICO: No bloquear clicks */
    user-select: none;
    z-index: 1; /* FIXED: Cambiado de -1 a 1 para no bloquear clicks */
}

/* Hamburger Menu Button */
.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    /* FIXED: Eliminar position absolute para mejor alineación */
    color: #1f2937;
    transition: color 0.2s;
    padding: 8px;
    flex-shrink: 0; /* No permitir que se reduzca */
    -webkit-tap-highlight-color: transparent; /* Eliminar highlight azul en móvil */
    position: relative; /* Para z-index */
    z-index: 10; /* Por encima del texto central */
}

.mobile-menu-btn:hover {
    color: #22c55e;
}

.mobile-menu-btn:active {
    transform: scale(0.95); /* Feedback táctil en móvil */
}

/* Notification badge on hamburger menu */
.mobile-menu-btn span {
    position: relative;
    display: inline-block;
}

#header-notification-badge {
    display: none; /* Oculto por defecto */
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    border: 2px solid white;
    align-items: center;
    justify-content: center;
}

#header-notification-badge.active {
    display: flex;
}

/* Menu item badges */
#profile-menu-badge,
#contacts-menu-badge {
    display: none; /* Oculto por defecto */
    background: #ef4444;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    line-height: 1;
    min-width: 20px;
    text-align: center;
}

#profile-menu-badge.active,
#contacts-menu-badge.active {
    display: inline-block;
}

/* Mobile Menus */
.mobile-menu {
    /* FIXED: Usar max-height en lugar de display para animaciones suaves */
    max-height: 0;
    overflow: hidden;
    padding: 0 1rem;
    background: white;
    border-top: 1px solid transparent;
    position: relative;
    z-index: 999;
    /* FIXED: Transiciones optimizadas para rendimiento en móvil */
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-top-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* FIXED: Usar transform para mejor rendimiento */
    will-change: max-height;
}

/* FIXED: Enhanced active state with smooth animation */
.mobile-menu.active {
    max-height: 500px; /* Ajustar según necesidad */
    padding: 1rem;
    border-top-color: #e5e7eb;
}

/* FIXED: Hide menus that are not available for current user state */
.mobile-menu[data-available="false"] {
    display: none !important;
}

/* ✅ BUG FIX #19: Close button for mobile menu */
.mobile-menu-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    /* Ensure good tap target size for mobile */
    min-width: 44px;
    min-height: 44px;
}

.mobile-menu-close-btn span {
    font-size: 28px;
    line-height: 1;
    font-weight: 300;
}

.mobile-menu-close-btn:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.mobile-menu-close-btn:active {
    transform: scale(0.95);
    background: #d1d5db;
}

/* Hide close button when menu is not active */
.mobile-menu:not(.active) .mobile-menu-close-btn {
    display: none;
}

.mobile-menu a {
    display: flex; /* FIXED: Usar flex para alinear badge con texto */
    align-items: center; /* Centrar verticalmente */
    gap: 8px; /* Espacio entre texto y badge */
    padding: 12px 0;
    color: #4b5563;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s;
    /* FIXED: Eliminar highlight azul en móvil */
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu a:hover {
    color: #22c55e;
}

.mobile-menu a:active {
    color: #16a34a; /* Feedback visual al tocar */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .logo-text {
        display: block;
    }

    /* FIXED: Mejor spacing en tablets */
    .header-container {
        padding: 0 0.75rem;
    }
}

@media (max-width: 480px) {
    .logo-text {
        font-size: 18px;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    /* FIXED: Ajustar tamaño del botón en pantallas muy pequeñas */
    .mobile-menu-btn {
        font-size: 22px;
        padding: 6px;
    }

    /* FIXED: Reducir padding del header en móviles pequeños */
    .header-container {
        padding: 0 0.5rem;
        height: 56px;
    }
}
