/**
 * ============================================================================
 * HEADER PROFISSIONAL MELHORADO - SISTEMA TMS
 * ============================================================================
 * Versão: 2.0
 * Data: 2026-02-07
 * Descrição: Estilos modernos e profissionais para o header do sistema
 * ============================================================================
 */

/* ===================================================================
   1. HEADER PRINCIPAL
   =================================================================== */

.tms-header-enhanced {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid #e2e8f0;
    padding-top: 1rem;
    padding-bottom: 1rem;
    padding-left: max(clamp(1rem, 3vw, 2rem), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(1rem, 3vw, 2rem), env(safe-area-inset-right, 0px));
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: visible;
}

.tms-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1920px;
    margin: 0 auto;
    gap: 2rem;
    overflow: visible;
}

/* ===================================================================
   2. SEÇÃO ESQUERDA - TÍTULO E BREADCRUMB
   =================================================================== */

.tms-header-left {
    flex: 1;
    min-width: 0; /* Para truncar texto se necessário */
}

.tms-header-title-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tms-mobile-menu-toggle {
    display: none !important;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid #dbe3ee;
    border-radius: 0.625rem;
    background: #ffffff;
    color: #1e3a8a;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.tms-mobile-menu-toggle i {
    font-size: 1rem;
}

/* Badge do Módulo */
.tms-module-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0369a1;
    padding: 0.375rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(3, 105, 161, 0.1);
    transition: all 0.3s ease;
}

.tms-module-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(3, 105, 161, 0.15);
}

.tms-module-badge i {
    font-size: 0.875rem;
}

/* Título da Página */
.tms-page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tms-page-title-icon {
    font-size: 1.25rem;
    color: var(--tms-cor-botao, #1e40af);
    opacity: 0.9;
}

/* Breadcrumb */
.tms-breadcrumb {
    margin: 0;
}

.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-link {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: #64748b;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.breadcrumb-link:hover {
    color: var(--tms-cor-botao, #1e40af);
    background-color: #f1f5f9;
}

.breadcrumb-link i {
    font-size: 0.75rem;
}

.breadcrumb-separator {
    color: #cbd5e1;
    font-size: 0.625rem;
    display: flex;
    align-items: center;
}

.breadcrumb-item.active span {
    color: var(--tms-cor-botao, #1e40af);
    font-weight: 600;
    font-size: 0.875rem;
}

/* ===================================================================
   3. SEÇÃO DIREITA - NOTIFICAÇÕES E PERFIL
   =================================================================== */

.tms-header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    overflow: visible;
}

/* Botão de Notificações */
.tms-notification-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    overflow: visible;
    z-index: 5;
}

.tms-notification-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.tms-notification-btn i {
    color: #64748b;
    font-size: 1.125rem;
    transition: color 0.3s ease;
}

.tms-notification-btn:hover i {
    color: var(--tms-cor-botao, #1e40af);
}

/* Badge de Notificação - canto superior direito, fora da área do sininho */
.tms-notification-btn .notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    left: auto;
    z-index: 10;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.15rem 0.35rem;
    border-radius: 999px;
    border: 2px solid #ffffff;
    min-width: 1.25rem;
    height: 1.25rem;
    text-align: center;
    line-height: 0.85;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: none;
}

/* Pulse - mesma posição do badge */
.tms-notification-btn .notification-pulse {
    position: absolute;
    top: -6px;
    right: -6px;
    left: auto;
    z-index: 1;
    width: 1.25rem;
    height: 1.25rem;
    background: #ef4444;
    border-radius: 999px;
    opacity: 0.6;
    animation: pulse-notification 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    pointer-events: none;
}

@keyframes pulse-notification {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ===================================================================
   4. PERFIL DO USUÁRIO (cores do menu lateral)
   =================================================================== */

.tms-user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.875rem;
    background: var(--tms-cor-primaria, #1e3a8a);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tms-user-profile:hover {
    background: var(--tms-cor-botao-hover, #2563eb);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Avatar do Usuário */
.tms-user-avatar {
    position: relative;
    flex-shrink: 0;
}

.tms-user-profile .avatar-image {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    object-fit: cover;
    border: 2px solid #fbbf24;
}

.avatar-image {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    object-fit: cover;
    border: 2px solid #e2e8f0;
}

.tms-user-profile .avatar-initials {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    border: 2px solid #fbbf24;
}

.avatar-initials {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    background: linear-gradient(135deg, var(--tms-cor-botao, #1e40af) 0%, var(--tms-cor-primaria, #1e3a8a) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    border: 2px solid #e2e8f0;
}

/* Status Online */
.avatar-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 999px;
    border: 2px solid #ffffff;
}

.avatar-status.online {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.avatar-status.offline {
    background: #94a3b8;
}

.avatar-status.away {
    background: #f59e0b;
}

/* Informações do Usuário */
.tms-user-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.tms-user-profile .user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    line-height: 1;
}

/* Tag do tipo de usuário: amarela no card do perfil */
.tms-user-profile .role-badge {
    display: inline-flex;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
    color: #1e293b !important;
}

/* Badges de Tipo de Usuário (outros contextos) */
.role-badge {
    display: inline-flex;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-master {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
}

.badge-admin {
    background: linear-gradient(135deg, var(--tms-cor-botao-hover, #2563eb) 0%, var(--tms-cor-botao, #1e40af) 100%);
    color: white;
}

.badge-comercial {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.badge-operacional {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.badge-financeiro {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
}

.badge-parceiro {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
}

.badge-motorista {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: white;
}

.badge-cliente {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    color: white;
}

/* Ícone de Dropdown */
.tms-user-profile .dropdown-icon {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    transition: transform 0.3s ease;
}

.dropdown-icon {
    font-size: 0.75rem;
    color: #64748b;
    transition: transform 0.3s ease;
}

.tms-user-profile[aria-expanded="true"] .dropdown-icon {
    transform: rotate(180deg);
    color: #fff;
}

/* ===================================================================
   5. DROPDOWN DE NOTIFICAÇÕES (sempre à esquerda do sininho)
   =================================================================== */

.notification-dropdown {
    min-width: 340px;
    max-width: 380px;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.02);
    padding: 0;
    margin-top: 0.375rem;
}

/* Dropdown à esquerda do sininho: pequeno afastamento */
.notification-dropdown-left {
    margin-right: 0.5rem;
}

.notification-header {
    padding: 0.875rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.notification-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #1e293b;
}

.notification-count {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
}

/* Lista com altura máxima e scroll suave */
#notificationListContainer {
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
}

#notificationListContainer::-webkit-scrollbar {
    width: 5px;
}

#notificationListContainer::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
}

.notification-list-placeholder {
    font-size: 0.8125rem;
    color: #94a3b8;
}

.notification-item {
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border-left: 3px solid transparent;
    border-bottom: 1px solid #f1f5f9;
}

.notification-item:last-of-type {
    border-bottom: none;
}

.notification-item:hover {
    background: #f8fafc;
}

.notification-item.unread {
    background: #f0f9ff;
    border-left-color: #0ea5e9;
}

.notification-item.unread:hover {
    background: #e0f2fe;
}

.notification-item a.notification-item-link {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    width: 100%;
    text-decoration: none;
    color: inherit;
}

.notification-icon {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.notification-success {
    background: #dcfce7;
    color: #16a34a;
}

.notification-warning {
    background: #fef3c7;
    color: #d97706;
}

.notification-danger {
    background: #fee2e2;
    color: #dc2626;
}

.notification-info {
    background: #e0f2fe;
    color: #0284c7;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-text {
    font-size: 0.8125rem;
    color: #1e293b;
    font-weight: 500;
    line-height: 1.35;
    margin-bottom: 0.15rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-time {
    font-size: 0.6875rem;
    color: #94a3b8;
}

.notification-footer {
    padding: 0.625rem 1rem;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
}

.notification-link {
    display: block;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--tms-cor-botao, #1e40af);
    text-decoration: none;
    padding: 0.375rem 0;
    transition: color 0.2s ease;
}

.notification-link:hover {
    color: var(--tms-cor-primaria, #1e3a8a);
}

/* ===================================================================
   6. DROPDOWN DE PERFIL (mesma cor do menu lateral)
   =================================================================== */

.user-dropdown {
    min-width: 240px;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 8px 24px rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    background: var(--tms-cor-primaria, #1e3a8a) !important;
}

.user-dropdown .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.12);
    margin: 0.25rem 0;
}

.user-dropdown .dropdown-item {
    padding: 0.625rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
    border-radius: 0.375rem;
    margin: 0 0.25rem;
}

.user-dropdown .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.user-dropdown .dropdown-item i {
    width: 1.25rem;
    text-align: center;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
}

.user-dropdown .dropdown-item:hover i {
    color: #fff;
}

.user-dropdown .dropdown-item span {
    flex: 1;
}

.user-dropdown .menu-badge {
    background: #ef4444;
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 999px;
    min-width: 1.25rem;
    text-align: center;
}

.user-dropdown .logout-item {
    color: rgba(254, 202, 202, 0.95) !important;
}

.user-dropdown .logout-item:hover {
    background: rgba(220, 38, 38, 0.25) !important;
    color: #fff !important;
}

.logout-item i {
    color: #dc2626 !important;
}

.logout-item:hover i {
    color: #b91c1c !important;
}

/* ===================================================================
   7. RESPONSIVIDADE
   =================================================================== */

@media (max-width: 1200px) {
    .tms-page-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 992px) {
    .tms-header-enhanced {
        padding-top: 1rem;
        padding-bottom: 1rem;
        padding-left: max(clamp(1rem, 2.8vw, 1.75rem), env(safe-area-inset-left, 0px));
        padding-right: max(clamp(1rem, 2.8vw, 1.75rem), env(safe-area-inset-right, 0px));
    }
}

@media (max-width: 768px) {
    .tms-header-container {
        flex-wrap: wrap;
    }
    
    .tms-header-left {
        width: 100%;
        order: 2;
    }

    .tms-header-title-section {
        gap: 0.45rem;
    }

    .tms-mobile-menu-toggle {
        display: inline-flex !important;
    }
    
    .tms-header-right {
        width: 100%;
        order: 1;
        justify-content: flex-end;
        margin-bottom: 1rem;
    }
    
    .tms-page-title {
        font-size: 1.25rem;
    }
    
    .tms-user-info {
        display: none;
    }
    
    .dropdown-icon {
        display: none;
    }
}

@media (max-width: 480px) {
    .tms-header-enhanced {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
        padding-left: max(clamp(0.85rem, 4vw, 1.15rem), env(safe-area-inset-left, 0px));
        padding-right: max(clamp(0.85rem, 4vw, 1.15rem), env(safe-area-inset-right, 0px));
    }
    
    .tms-module-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.625rem;
    }
    
    .tms-page-title {
        font-size: 1.125rem;
    }
    
    .breadcrumb-list {
        font-size: 0.8125rem;
    }
    
    .notification-dropdown {
        min-width: 320px;
    }
}

