/* ================================================================
   04-BARRA-SUPERIOR.css - HEADER EJECUTIVO GRIZALUM v2.1
   Sistema de header profesional con especificidad optimizada
   ================================================================ */

/* ===== VARIABLES CSS LOCALES ===== */
:root {
    --header-height: 60px;
    --header-mobile-height: 50px;
    --gold-primary: #d4af37;
    --gold-secondary: #b8941f;
    --gold-light: #e4c06a;
    --gold-shadow: rgba(212, 175, 55, 0.25);
    --gold-shadow-hover: rgba(212, 175, 55, 0.4);
}

/* ===== HEADER EJECUTIVO PRINCIPAL ===== */
.executive-header {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.8) 100%);
    backdrop-filter: var(--backdrop-blur, blur(20px));
    padding: var(--spacing-lg, 16px) var(--spacing-2xl, 32px);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.15));
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all var(--transition-normal, 0.3s ease);
    margin-bottom: 0;
    padding-bottom: 16px;
}

.executive-header:hover {
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.2));
    backdrop-filter: blur(25px);
}

/* ===== BOTÓN MENÚ MÓVIL ===== */
.mobile-menu-toggle {
    display: none;
    background: var(--glass-effect, rgba(255, 255, 255, 0.1));
    backdrop-filter: var(--backdrop-blur, blur(20px));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
    border-radius: 8px;
    padding: var(--spacing-sm, 8px);
    font-size: var(--text-lg, 18px);
    cursor: pointer;
    color: var(--gray-600, #6b7280);
    transition: all var(--transition-normal, 0.3s ease);
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle:hover {
    background: var(--gold-primary);
    color: white;
    transform: scale(1.05);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.15));
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* ===== INFORMACIÓN DE PÁGINA ===== */
.page-header {
    flex: 1;
    max-width: 500px;
}

.page-title {
    font-size: var(--text-3xl, 30px);
    font-weight: 900;
    background: var(--gradient-primary, linear-gradient(135deg, #d4af37 0%, #b8941f 100%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--spacing-xs, 4px);
    line-height: 1.2;
    transition: all var(--transition-normal, 0.3s ease);
}

.page-title:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.page-subtitle {
    color: var(--gray-600, #6b7280);
    font-size: var(--text-base, 16px);
    margin-bottom: var(--spacing-sm, 8px);
    font-weight: 500;
}

/* ===== INSIGHTS DE IA ===== */
.ai-insights {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm, 8px);
    font-size: var(--text-sm, 14px);
    color: var(--gold-primary);
    background: rgba(212, 175, 55, 0.1);
    padding: var(--spacing-sm, 8px) var(--spacing-md, 12px);
    border-radius: 6px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    transition: all var(--transition-normal, 0.3s ease);
    position: relative;
    overflow: hidden;
}

.ai-insights::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(212, 175, 55, 0.1), 
        transparent);
    animation: aiInsightsPulse 3s infinite;
}

@keyframes aiInsightsPulse {
    0%, 90% { left: -100%; }
    100% { left: 100%; }
}

.ai-insights:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.4);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.1));
}

.ai-insights i {
    animation: brainPulse 2s infinite;
}

@keyframes brainPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ===== CONTROLES DEL HEADER ===== */
.header-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg, 16px);
    flex-shrink: 0;
}

/* ===== SELECTOR DE PERÍODO DE TIEMPO ===== */
.time-period-selector {
    display: flex;
    background: var(--gray-100, #f3f4f6);
    border-radius: 8px;
    padding: 4px;
    gap: 2px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.period-btn {
    padding: var(--spacing-sm, 8px) var(--spacing-md, 12px);
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: var(--text-sm, 14px);
    font-weight: 500;
    color: var(--gray-600, #6b7280);
    cursor: pointer;
    transition: all var(--transition-normal, 0.3s ease);
    position: relative;
    overflow: hidden;
    min-width: 60px;
    text-align: center;
}

.period-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-gold, linear-gradient(135deg, #d4af37 0%, #b8941f 100%));
    opacity: 0;
    transition: opacity var(--transition-normal, 0.3s ease);
    border-radius: inherit;
}

.period-btn span {
    position: relative;
    z-index: 1;
}

.period-btn:hover {
    color: var(--gold-primary);
    transform: translateY(-1px);
}

.period-btn:hover::before {
    opacity: 0.1;
}

.period-btn.active {
    background: white;
    color: var(--gold-primary);
    box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.1));
    transform: translateY(-1px);
    font-weight: 600;
}

.period-btn.active::before {
    opacity: 0.1;
}

.period-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== CENTRO DE NOTIFICACIONES - ESPECIFICIDAD MÁXIMA ===== */
/* Selector principal con máxima especificidad */
html body div.app-container main.main-content header.executive-header div.header-controls button#btnNotificaciones.notification-center,
html body div.executive-header div.header-controls button#btnNotificaciones.notification-center,
html body header.executive-header div.header-controls button#btnNotificaciones,
html body button#btnNotificaciones.notification-center,
.header-controls button#btnNotificaciones,
#btnNotificaciones {
    position: relative !important;
    background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-secondary) 100%) !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 12px !important;
    font-size: 18px !important;
    color: white !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: 48px !important;
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 12px var(--gold-shadow) !important;
    overflow: visible !important;
    z-index: 100 !important;
    margin-left: 16px !important;
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Estados hover con máxima especificidad */
html body div.app-container main.main-content header.executive-header div.header-controls button#btnNotificaciones.notification-center:hover,
html body div.executive-header div.header-controls button#btnNotificaciones.notification-center:hover,
html body header.executive-header div.header-controls button#btnNotificaciones:hover,
html body button#btnNotificaciones.notification-center:hover,
.header-controls button#btnNotificaciones:hover,
#btnNotificaciones:hover {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-primary) 100%) !important;
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 8px 20px var(--gold-shadow-hover) !important;
}

/* Estado activo */
html body button#btnNotificaciones.notification-center:active,
#btnNotificaciones:active {
    transform: translateY(-1px) scale(1.02) !important;
    box-shadow: 0 6px 16px var(--gold-shadow-hover) !important;
}

/* Estado focus para accesibilidad */
html body button#btnNotificaciones.notification-center:focus,
#btnNotificaciones:focus {
    outline: 2px solid var(--gold-primary) !important;
    outline-offset: 2px !important;
}

/* Icono dentro del botón */
html body button#btnNotificaciones.notification-center i,
#btnNotificaciones i,
#btnNotificaciones .fas,
#btnNotificaciones .fa-bell {
    color: white !important;
    font-size: 18px !important;
    transition: transform 0.3s ease !important;
}

/* Badge de notificaciones */
.notification-badge,
#btnNotificaciones .notification-badge,
.notification-center .notification-badge {
    position: absolute !important;
    top: -8px !important;
    right: -8px !important;
    background: #ef4444 !important;
    color: white !important;
    border-radius: 50% !important;
    width: 20px !important;
    height: 20px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 2px solid white !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    z-index: 101 !important;
}

/* ===== BOTÓN IA ASSISTANT ===== */
.ai-header-button {
    background: var(--gradient-purple, linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%));
    color: white;
    border: none;
    border-radius: 8px;
    padding: var(--spacing-md, 12px) var(--spacing-lg, 16px);
    font-size: var(--text-sm, 14px);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm, 8px);
    transition: all var(--transition-normal, 0.3s ease);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.15));
    position: relative;
    overflow: hidden;
}

.ai-header-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent);
    transition: left 0.5s ease;
}

.ai-header-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.2));
    filter: brightness(1.1);
}

.ai-header-button:hover::before {
    left: 100%;
}

.ai-header-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.1));
}

.ai-header-button.active {
    background: var(--gradient-gold, linear-gradient(135deg, #d4af37 0%, #b8941f 100%));
    animation: aiButtonPulse 1s ease-out;
}

@keyframes aiButtonPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px rgba(139, 92, 246, 0.4); }
    100% { transform: scale(1); }
}

/* ===== ESTADOS DE CARGA DEL HEADER ===== */
.executive-header.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--gold-primary), 
        transparent);
    animation: headerLoading 1.5s infinite;
}

@keyframes headerLoading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== RESPONSIVE TABLET ===== */
@media (max-width: 991px) {
    .mobile-menu-toggle {
        display: flex;
    }
    
    .executive-header {
        padding: var(--spacing-md, 12px) var(--spacing-lg, 16px);
        flex-wrap: wrap;
        gap: var(--spacing-md, 12px);
    }
    
    .page-header {
        order: 2;
        width: 100%;
        max-width: none;
    }
    
    .header-controls {
        flex-wrap: wrap;
        gap: var(--spacing-md, 12px);
        order: 1;
    }
    
    .page-title {
        font-size: var(--text-2xl, 24px);
    }
    
    .time-period-selector {
        flex-wrap: wrap;
        gap: 1px;
    }
    
    .period-btn {
        min-width: 50px;
        padding: var(--spacing-xs, 6px) var(--spacing-sm, 8px);
        font-size: var(--text-xs, 12px);
    }
}

/* ===== RESPONSIVE MÓVIL ===== */
@media (max-width: 575px) {
    .executive-header {
        padding: var(--spacing-sm, 8px) var(--spacing-md, 12px);
        min-height: var(--header-mobile-height);
    }
    
    .page-title {
        font-size: var(--text-xl, 20px);
        margin-bottom: var(--spacing-xs, 4px);
    }
    
    .page-subtitle {
        font-size: var(--text-sm, 14px);
        margin-bottom: var(--spacing-xs, 4px);
    }
    
    .ai-insights {
        font-size: var(--text-xs, 12px);
        padding: var(--spacing-xs, 6px) var(--spacing-sm, 8px);
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: var(--spacing-sm, 8px);
    }
    
    .time-period-selector {
        flex: 1;
        max-width: 200px;
    }
    
    .period-btn {
        padding: var(--spacing-xs, 6px);
        font-size: 10px;
        min-width: 35px;
    }
    
    /* Botón de notificaciones móvil */
    html body button#btnNotificaciones.notification-center,
    #btnNotificaciones {
        width: 36px !important;
        height: 36px !important;
        padding: 8px !important;
        font-size: 16px !important;
    }
    
    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
        padding: var(--spacing-xs, 6px);
    }
    
    .ai-header-button {
        padding: var(--spacing-xs, 6px) var(--spacing-sm, 8px);
        font-size: var(--text-xs, 12px);
    }
    
    .ai-header-button span {
        display: none;
    }
    
    .notification-badge {
        width: 14px !important;
        height: 14px !important;
        font-size: 8px !important;
        top: -2px !important;
        right: -2px !important;
    }
}

/* ===== MÓVIL MUY PEQUEÑO ===== */
@media (max-width: 375px) {
    .page-title {
        font-size: var(--text-lg, 18px);
    }
    
    .header-controls {
        gap: var(--spacing-xs, 6px);
    }
    
    .time-period-selector {
        max-width: 160px;
    }
    
    .period-btn {
        min-width: 28px;
        font-size: 9px;
        padding: 4px 2px;
    }
    
    .ai-header-button {
        padding: var(--spacing-xs, 6px);
        min-width: 36px;
    }
    
    /* Botón notificaciones extra pequeño */
    html body button#btnNotificaciones.notification-center,
    #btnNotificaciones {
        width: 32px !important;
        height: 32px !important;
        padding: 6px !important;
        font-size: 14px !important;
    }
}

/* ===== ACCESIBILIDAD MEJORADA ===== */
.period-btn:focus,
.ai-header-button:focus,
.mobile-menu-toggle:focus {
    outline: 2px solid var(--gold-primary);
    outline-offset: 2px;
}

/* Mejoras para lectores de pantalla */
.notification-badge::after {
    content: ' notificaciones pendientes';
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.ai-header-button[aria-label] {
    position: relative;
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .executive-header {
        background: white;
        border-bottom: 2px solid black;
    }
    
    .period-btn.active {
        background: black;
        color: white;
    }
    
    html body button#btnNotificaciones.notification-center,
    #btnNotificaciones,
    .ai-header-button {
        border: 1px solid black !important;
    }
}

/* ===== REDUCIR MOVIMIENTO ===== */
@media (prefers-reduced-motion: reduce) {
    .page-title,
    .period-btn,
    .ai-header-button,
    .ai-insights i,
    html body button#btnNotificaciones.notification-center,
    #btnNotificaciones {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
    
    .executive-header::after,
    .ai-insights::before,
    .ai-header-button::before {
        animation: none !important;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .mobile-menu-toggle,
    html body button#btnNotificaciones.notification-center,
    #btnNotificaciones,
    .ai-header-button,
    .time-period-selector {
        display: none !important;
    }
    
    .executive-header {
        background: white !important;
        box-shadow: none !important;
        border-bottom: 1px solid black !important;
        position: static !important;
    }
    
    .page-title {
        color: black !important;
        background: none !important;
        -webkit-text-fill-color: initial !important;
    }
    
    .ai-insights {
        display: none !important;
    }
}

/* ===== THEMES DINÁMICOS ===== */
.executive-header[data-theme] {
    transition: all var(--transition-slow, 0.5s ease);
}

.executive-header[data-theme] .page-title {
    transition: all var(--transition-normal, 0.3s ease);
}

.executive-header[data-theme] .ai-insights {
    transition: all var(--transition-normal, 0.3s ease);
}

/* ===== FALLBACKS PARA VARIABLES CSS ===== */
@supports not (color: var(--gold-primary)) {
    html body button#btnNotificaciones.notification-center,
    #btnNotificaciones {
        background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%) !important;
    }
    
    .period-btn:hover,
    .period-btn.active {
        color: #d4af37 !important;
    }
    
    .page-title {
        background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%) !important;
        -webkit-background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
    }
}

/* ===== DEBUGGING HELPERS (comentar en producción) ===== */
/*
.notification-center {
    border: 2px solid red !important;
}

#btnNotificaciones {
    background: lime !important;
}
*/
/* FUERZA BRUTA FINAL */
[id="btnNotificaciones"] {
    background: #d4af37 !important;
    background-color: #d4af37 !important;
    background-image: linear-gradient(135deg, #d4af37 0%, #b8941f 100%) !important;
}
