/* ============================================
   NAVBAR SUPERIOR MODERNO - ESTILO MICROSOFT
   Design Profissional e Clean
   ============================================ */

.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 64px;
}

.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    max-width: 100%;
    height: 100%;
    margin: 0 auto;
}

/* ============================================
   LOGO E MARCA - ESTILO MICROSOFT
   ============================================ */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #ffffff;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.navbar-brand:hover {
    opacity: 0.9;
}

.navbar-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-brand:hover .navbar-logo {
    transform: scale(1.05);
}

.navbar-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.015em;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   MENU PRINCIPAL - ESTILO MICROSOFT
   ============================================ */
.navbar-menu {
    display: flex;
    align-items: center;
    gap: 4px;
}

.navbar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.navbar-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.navbar-item.active {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
}

.navbar-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 2px;
    background: #60a5fa;
    border-radius: 2px 2px 0 0;
}

.navbar-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.9;
}

/* ============================================
   DROPDOWNS - ESTILO MICROSOFT
   ============================================ */
.navbar-dropdown {
    position: relative;
}

.dropdown-trigger {
    background: none;
    border: none;
    cursor: pointer;
    pointer-events: auto;
    z-index: 1;
    position: relative;
}

.dropdown-arrow {
    width: 16px;
    height: 16px;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    pointer-events: none; /* Não bloquear clique, passar para o botão pai */
}

.navbar-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* Área invisível que conecta o botão ao menu para manter hover ativo */
.navbar-dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: -10px;
    right: -10px;
    height: 30px;
    z-index: 1000;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: -10px;
    min-width: 240px;
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    padding: 8px;
    pointer-events: none;
}

.dropdown-menu-right {
    left: auto;
    right: -10px;
}

/* Manter dropdown aberto quando mouse está sobre ele */
.navbar-dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.dropdown-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}
.dropdown-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

.dropdown-item.text-red {
    color: #f87171;
}

.dropdown-item.text-red:hover {
    color: #ffffff;
    background: rgba(239, 68, 68, 0.1);
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 0;
}

/* ============================================
   MENU DO USUÁRIO - ESTILO MICROSOFT
   ============================================ */
.navbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 32px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #ffffff;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.user-profile:hover {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.35);
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.15);
}

.user-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0078d4 0%, #60a5fa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.4);
    flex-shrink: 0;
}

.user-avatar svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    min-width: 80px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.4;
    white-space: nowrap;
}

.user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.3;
    white-space: nowrap;
}

.dropdown-arrow-user {
    width: 16px;
    height: 16px;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    margin-left: 4px;
}

.navbar-dropdown:hover .dropdown-arrow-user {
    transform: rotate(180deg);
    opacity: 1;
}

/* ============================================
   MOBILE MENU - ESTILO MICROSOFT
   ============================================ */
.navbar-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-mobile-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}
    }

    /* Accept .active class from JS as alternative to .mobile-active */
    .navbar-menu.active {
        display: flex;
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: #1a1f36;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
        z-index: 1000;
        padding: 16px 0;
        animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);

.navbar-mobile-toggle svg {
    width: 20px;
    height: 20px;
}
.navbar-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   ESPAÇAMENTO DO CONTEÚDO
   ============================================ */
.main-content {
    padding-top: 64px; /* Altura do navbar */
}

.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ============================================
   RESPONSIVE - ESTILO MICROSOFT
   ============================================ */
@media (max-width: 1024px) {
    .navbar-container {
        padding: 0 20px;
    }
}

@media (max-width: 768px) {
    .navbar-container {
        padding: 0 16px;
    }

    .navbar-logo {
        height: 40px;
        width: auto;
    }

    .navbar-title {
        font-size: 20px;
    }

    .navbar-menu {
        display: none;
    }

    .navbar-mobile-toggle {
        display: flex;
    }

    .navbar-menu.mobile-active {
        display: flex;
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: #1a1f36;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
        z-index: 1000;
        padding: 16px 0;
        animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .navbar-item {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 24px;
        border-radius: 0;
    }

    .navbar-item:hover {
        background: rgba(96, 165, 250, 0.08);
    }

    .user-menu {
        width: 100%;
        padding: 12px 24px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        margin-top: 8px;
    }

    .dropdown-menu {
        position: static;
        box-shadow: none;
        border-left: 3px solid #60a5fa;
        border-radius: 0;
        margin: 0;
        padding: 8px 0;
    }
}

/* Mobile profile entry fallback styling */
@media (max-width: 768px) {
    .mobile-profile-entry {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        border-radius: 12px;
        background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
        border: 1px solid rgba(255,255,255,0.04);
        margin-bottom: 0.75rem;
        box-shadow: 0 6px 18px rgba(2,6,23,0.6);
        transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    }

    .mobile-profile-entry:focus-within,
    .mobile-profile-entry:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 30px rgba(2,6,23,0.7);
        background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    }

    .mobile-profile-entry .mobile-profile-link {
        display: flex;
        align-items: center;
        gap: 12px;
        color: #cfe8ff;
        text-decoration: none;
        width: 100%;
        outline: none;
    }

    .mobile-profile-entry .mobile-profile-name {
        font-weight: 700;
        color: #dbeafe;
        font-size: 0.98rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-profile-entry .mobile-profile-sub {
        display: block;
        font-size: 0.78rem;
        color: rgba(219,234,254,0.7);
        margin-top: 2px;
    }

    .mobile-profile-entry .user-avatar {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        border-radius: 50% !important;
        background: linear-gradient(135deg, #0ea5a8 0%, #3b82f6 100%) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #fff !important;
        box-shadow: 0 4px 12px rgba(59,130,246,0.12) inset, 0 6px 18px rgba(2,6,23,0.5);
    }

    .mobile-profile-entry .user-avatar svg {
        width: 18px !important;
        height: 18px !important;
    }

    .mobile-profile-entry:focus-within .mobile-profile-link,
    .mobile-profile-entry:hover .mobile-profile-link {
        color: #e6f3ff;
    }
    /* place the profile entry at the bottom of the drawer */
    .navbar-menu {
        display: flex;
        flex-direction: column;
    }

    .mobile-profile-entry {
        margin-top: auto !important;
    }
}

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

@media (max-width: 768px) {
    .navbar-container {
        padding: 0.25rem 1rem;
    }
    
    .navbar-menu {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 300px;
        background: rgba(0, 0, 0, 0.98);
        backdrop-filter: blur(20px);
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: 5rem 1.5rem 2rem;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .navbar-menu.active {
        transform: translateX(0);
    }
    
    .navbar-item {
        width: 100%;
        padding: 1rem 0.75rem;
        border-radius: 8px;
        margin-bottom: 0.25rem;
    }
    
    .navbar-dropdown {
        width: 100%;
    }
    
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: rgba(255, 255, 255, 0.05);
        border: none;
        border-radius: 8px;
        box-shadow: none;
        margin-top: 0.5rem;
        margin-bottom: 1rem;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .navbar-dropdown.active .dropdown-menu {
        max-height: 200px;
    }
    
    .navbar-user {
        margin-left: 0;
        margin-top: auto;
        padding-top: 1.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        width: 100%;
    }
    
    .user-profile {
        width: 100%;
        justify-content: flex-start;
        padding: 1rem 0.75rem;
    }
    
    .navbar-mobile-toggle {
        display: flex;
    }
}

/* ============================================
   LAYOUT ADJUSTMENTS
   ============================================ */
.main-content {
    margin-top: 50px;
    min-height: calc(100vh - 50px);
}

.page-container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .page-container {
        padding: 1.5rem 1rem;
    }
}

/* ==================================================
   Correções de responsividade e prevenção de sobreposição
   Aplicadas no final para sobrescrever regras conflitantes
   ================================================== */

/* Força altura consistente do navbar e espaço no conteúdo */
.top-navbar {
    height: 64px !important;
}

.main-content {
    padding-top: 64px !important; /* garante espaço suficiente abaixo do navbar */
}

/* Mobile: esconder texto do perfil para evitar overlap e reduzir avatar */
@media (max-width: 768px) {
    .user-info {
        display: none !important;
    }

    .user-avatar {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    .user-profile {
        padding: 6px !important;
        border-radius: 999px !important;
        background: rgba(255,255,255,0.03) !important;
    }

    /* garante que o menu móvel não fique atrás do conteúdo */
    .navbar-menu.active,
    .navbar-menu.mobile-active {
        top: 64px !important;
    }
}

/* Pequenas telas: reduzir ainda mais e ajustar espaçamentos */
@media (max-width: 480px) {
    .top-navbar {
        height: 56px !important;
    }

    .main-content {
        padding-top: 56px !important;
    }

    .navbar-user {
        margin-left: 8px !important;
    }

    .navbar-mobile-toggle {
        display: flex !important;
    }
}

/* Additional strong overrides to guarantee consistent mobile behavior across pages */
@media (max-width: 768px) {
    /* Hide the original profile block when script sets aria-hidden */
    .navbar-user[aria-hidden="true"] {
        display: none !important;
    }

    /* Make mobile menu a stable left-side drawer (consistent slide-in) */
    .navbar-menu {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        width: 320px !important;
        max-width: 85% !important;
        background: rgba(0, 0, 0, 0.98) !important;
        transform: translateX(-100%) !important;
        transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 3.5rem 1.25rem 2rem !important;
        z-index: 1002 !important;
        box-shadow: 0 8px 24px rgba(0,0,0,0.6) !important;
    }

    .navbar-menu.active {
        transform: translateX(0) !important;
    }

    /* Overlay z-index should be below the drawer so clicks still close drawer */
    .navbar-mobile-overlay {
        z-index: 1001 !important;
    }

    .mobile-navbar-user {
        margin-bottom: 1rem !important;
    }

    .mobile-navbar-user .user-profile {
        width: 100% !important;
    }
}

/* Ensure compact profile pill on all pages at small screens: show only avatar, remove long rounded bar */
@media (max-width: 768px) {
    .user-profile {
        padding: 4px !important;
        border-radius: 999px !important;
        background: transparent !important;
        border: none !important;
        min-width: 0 !important;
        width: auto !important;
    }

    .user-info {
        display: none !important;
    }

    .dropdown-arrow-user {
        display: none !important;
    }

    .user-avatar {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    /* remove any full-width visual pill for the user-profile */
    .top-navbar .user-profile::before,
    .top-navbar .user-profile::after {
        display: none !important;
    }
}
/* Ensure user information (name + role) is visible inside the mobile drawer
   for both the cloned `.mobile-navbar-user` and the `.mobile-profile-entry` fallback. */
@media (max-width: 768px) {
    .navbar-menu .mobile-navbar-user .user-info,
    .navbar-menu .mobile-profile-entry .user-info {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0 !important;
        margin-left: 8px !important;
    }

    .navbar-menu .mobile-navbar-user .user-name,
    .navbar-menu .mobile-profile-entry .mobile-profile-name {
        color: #dbeafe !important;
        font-weight: 700 !important;
        font-size: 1rem !important;
        line-height: 1.1 !important;
    }

    .navbar-menu .mobile-navbar-user .user-role,
    .navbar-menu .mobile-profile-entry .mobile-profile-sub {
        color: rgba(219,234,254,0.85) !important;
        font-size: 0.86rem !important;
        margin-top: 2px !important;
    }

    .navbar-menu .mobile-navbar-user .user-profile,
    .navbar-menu .mobile-profile-entry .mobile-profile-link {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        width: 100% !important;
    }

    /* Slightly increase avatar inside drawer for clarity */
    .navbar-menu .mobile-navbar-user .user-avatar,
    .navbar-menu .mobile-profile-entry .user-avatar {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
    }
}
    /* Force cloned user to stay at top of drawer (override margin-top:auto from .navbar-user) */
    .mobile-navbar-user {
        margin-top: 0 !important;
        order: -1 !important;
        align-self: flex-start !important;
        display: block !important;
    }
    .mobile-navbar-user .user-profile {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
    }

    /* Note: original behavior hid the top `.navbar-user` for mobile only.
       Removed the global hide rule so the profile remains visible on desktop.
       Mobile hiding is already handled by the @media (max-width: 768px) rules above. */
}

    /* Professional styling for mobile profile entry (clone + fallback)
       - clean card, subtle gradient, avatar ring, readable name/role, chevron
    */
    @media (max-width: 768px) {
        .mobile-profile-entry {
            display: flex !important;
            align-items: center !important;
            gap: 12px !important;
            padding: 12px 14px !important;
            border-radius: 12px !important;
            background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)) !important;
            border: 1px solid rgba(255,255,255,0.04) !important;
            box-shadow: 0 6px 18px rgba(2,6,23,0.55) !important;
            transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease !important;
            width: calc(100% - 8px) !important;
            margin: 0.5rem 4px !important;
        }

        .mobile-profile-entry .user-avatar {
            width: 48px !important;
            height: 48px !important;
            min-width: 48px !important;
            border-radius: 50% !important;
            background: linear-gradient(135deg, #0ea5a8 0%, #3b82f6 100%) !important;
            box-shadow: 0 4px 12px rgba(59,130,246,0.12), 0 8px 20px rgba(2,6,23,0.5) inset !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
        }

        .mobile-profile-entry .mobile-profile-name {
            font-size: 1rem !important;
            color: #dbeafe !important;
            font-weight: 700 !important;
            margin: 0 !important;
            line-height: 1.05 !important;
        }

        .mobile-profile-entry .mobile-profile-sub {
            font-size: 0.85rem !important;
            color: rgba(219,234,254,0.85) !important;
            margin-top: 2px !important;
            line-height: 1 !important;
        }

        .mobile-profile-entry .mobile-profile-link {
            display: flex !important;
            align-items: center !important;
            gap: 12px !important;
            width: 100% !important;
            text-decoration: none !important;
        }

        .mobile-profile-entry:focus-within,
        .mobile-profile-entry:hover {
            transform: translateY(-3px) !important;
            box-shadow: 0 12px 36px rgba(2,6,23,0.7) !important;
            background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015)) !important;
        }

        /* optional chevron aligned right inside the entry */
        .mobile-profile-entry .mobile-profile-link::after {
            content: '\25B6';
            margin-left: auto !important;
            color: rgba(219,234,254,0.6) !important;
            font-size: 0.9rem !important;
            transform: translateX(2px) !important;
        }

        /* focus outline for keyboard accessibility */
        .mobile-profile-entry:focus-within {
            outline: 3px solid rgba(96,165,250,0.12) !important;
            outline-offset: 2px !important;
        }
    }
