/**
 * Header Unificado - DigiTech ITSM v2.9.2
 * Estilos modernos y profesionales para todos los módulos
 */

/* Header Container - Glassmorphism Mejorado */
#main-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(249, 250, 251, 0.95));
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid transparent;
    border-image: linear-gradient(90deg, rgba(139, 92, 246, 0.2), rgba(168, 85, 247, 0.3), rgba(192, 132, 252, 0.2)) 1;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#main-header:hover {
    box-shadow: 0 6px 32px rgba(139, 92, 246, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.dark #main-header {
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.98), rgba(31, 41, 55, 0.95));
    border-image: linear-gradient(90deg, rgba(168, 85, 247, 0.3), rgba(192, 132, 252, 0.4), rgba(168, 85, 247, 0.3)) 1;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.5);
}

.dark #main-header:hover {
    box-shadow: 0 6px 32px rgba(168, 85, 247, 0.2), 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Unified Header Layout */
.unified-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    min-height: 5rem;
    gap: 1.5rem;
}

/* Header Left: Mobile Toggle + Module Title */
.header-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-width: 0;
    flex: 1;
}

.mobile-toggle {
    padding: 0.625rem;
    color: #6b7280;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(168, 85, 247, 0.08));
    border: 1px solid rgba(139, 92, 246, 0.1);
    border-radius: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.05);
}

.mobile-toggle:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(168, 85, 247, 0.15));
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
    transform: translateY(-1px);
}

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

.dark .mobile-toggle {
    color: #9ca3af;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(192, 132, 252, 0.08));
    border-color: rgba(168, 85, 247, 0.2);
}

.dark .mobile-toggle:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(192, 132, 252, 0.15));
    color: #c084fc;
    border-color: rgba(192, 132, 252, 0.4);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.2);
}

/* Module Title Section - Integrado en Header */
.module-title-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    flex: 1;
}

.module-icon-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.module-icon-badge:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.dark .module-icon-badge {
    background: linear-gradient(135deg, #a855f7, #c084fc);
}

.module-icon-badge span {
    font-size: 1.75rem;
}

.module-title-content {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}

.module-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, #8b5cf6, #6366f1, #8b5cf6);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.dark .module-title {
    background: linear-gradient(135deg, #c084fc, #a78bfa, #c084fc);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.module-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(99, 102, 241, 0.08));
    color: #7c3aed;
    border: 1px solid rgba(139, 92, 246, 0.2);
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.module-badge:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(99, 102, 241, 0.12));
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateX(2px);
}

.dark .module-badge {
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.15), rgba(167, 139, 250, 0.1));
    color: #c084fc;
    border-color: rgba(192, 132, 252, 0.3);
}

.dark .module-badge:hover {
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.2), rgba(167, 139, 250, 0.15));
    border-color: rgba(192, 132, 252, 0.4);
}

.module-badge svg {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
}

/* Header Center: Module Actions */
.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 2;
}

.module-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.module-action-btn {
    display: inline-flex;
    align-items: center;
    border: none;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    white-space: nowrap;
}

.module-action-btn:hover {
    transform: translateY(-1px);
}

.module-action-btn:active {
    transform: translateY(0);
}

/* Header Right: Universal Elements */
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    justify-content: flex-end;
}

.user-info {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(168, 85, 247, 0.05));
    border-radius: 0.75rem;
    border: 1px solid rgba(139, 92, 246, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-info:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(168, 85, 247, 0.08));
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.1);
}

.dark .user-info {
    color: #e5e7eb;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(192, 132, 252, 0.1));
    border-color: rgba(168, 85, 247, 0.25);
}

.dark .user-info:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(192, 132, 252, 0.15));
    border-color: rgba(192, 132, 252, 0.35);
    box-shadow: 0 2px 12px rgba(168, 85, 247, 0.15);
}

.theme-toggle {
    padding: 0.625rem;
    color: #6b7280;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(245, 158, 11, 0.08));
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.15);
}

.theme-toggle:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.15));
    color: #f59e0b;
    border-color: rgba(251, 191, 36, 0.4);
    transform: rotate(180deg) scale(1.05);
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.25);
}

.theme-toggle:active {
    transform: rotate(180deg) scale(0.95);
}

.dark .theme-toggle {
    color: #fbbf24;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(168, 85, 247, 0.1));
    border-color: rgba(168, 85, 247, 0.3);
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.2);
}

.dark .theme-toggle:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(192, 132, 252, 0.2));
    color: #c084fc;
    border-color: rgba(192, 132, 252, 0.5);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3), 0 0 0 0 rgba(239, 68, 68, 0.5);
    position: relative;
    overflow: hidden;
}

.logout-btn::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;
}

.logout-btn:hover::before {
    left: 100%;
}

.logout-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4), 0 0 0 4px rgba(239, 68, 68, 0.1);
    transform: translateY(-2px);
    border-color: rgba(185, 28, 28, 0.5);
}

.logout-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Responsive Design - Mejorado */
@media (max-width: 1024px) {
    .unified-header {
        gap: 1rem;
        padding: 1rem 1.25rem;
    }

    .header-left {
        gap: 1rem;
    }

    .module-icon-badge {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 0.875rem;
    }

    .module-icon-badge span {
        font-size: 1.5rem;
    }

    .module-title {
        font-size: 1.25rem;
    }

    .module-badge {
        font-size: 0.6875rem;
        padding: 0.1875rem 0.625rem;
    }

    .user-info {
        max-width: 150px;
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
    }

    .theme-toggle {
        width: 2.25rem;
        height: 2.25rem;
    }

    .logout-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 640px) {
    #main-header {
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    }

    .unified-header {
        padding: 0.875rem 1rem;
        gap: 0.75rem;
        min-height: 4rem;
    }

    .header-left {
        gap: 0.75rem;
    }

    .module-icon-badge {
        width: 2.25rem;
        height: 2.25rem;
        border-radius: 0.75rem;
    }

    .module-icon-badge span {
        font-size: 1.25rem;
    }

    .module-title {
        font-size: 1.125rem;
    }

    .module-badge {
        display: none; /* Ocultar badge en móvil */
    }

    .user-info {
        display: none;
    }

    .theme-toggle {
        width: 2rem;
        height: 2rem;
        padding: 0.5rem;
    }

    .logout-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.75rem;
        gap: 0.25rem;
    }

    .logout-btn svg {
        width: 0.875rem;
        height: 0.875rem;
    }

    .mobile-toggle {
        padding: 0.5rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loading State */
.header-loading .user-info::after {
    content: '...';
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0%, 66% { content: '...'; }
    33% { content: '..'; }
    66% { content: '.'; }
}

/* Focus States for Accessibility */
.module-action-btn:focus,
.theme-toggle:focus,
.logout-btn:focus,
.mobile-toggle:focus {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .header-title {
        background: none;
        color: #000;
    }

    .dark .header-title {
        background: none;
        color: #fff;
    }

    .module-action-btn,
    .theme-toggle,
    .logout-btn {
        border: 2px solid currentColor;
    }
}

/* Print Styles */
@media print {
    #main-header {
        position: static;
        background: white;
        border-bottom: 1px solid #000;
        backdrop-filter: none;
    }

    .theme-toggle,
    .logout-btn,
    .mobile-toggle {
        display: none;
    }

    .header-title {
        background: none;
        color: #000;
    }
}