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

.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1002;
    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
   ============================================ */

/* Botão hambúrguer — oculto no desktop, visível no mobile */
.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: background 0.2s ease, color 0.2s ease;
}

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

.navbar-mobile-toggle svg {
    width: 20px;
    height: 20px;
}

/* Overlay escuro ao abrir o drawer */
.navbar-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* ============================================
   ESPAÇAMENTO DO CONTEÚDO
   ============================================ */
.top-navbar {
    height: 64px;
}

.main-content {
    padding-top: 64px;
    min-height: calc(100vh - 64px);
}

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

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

/* ============================================
   RESPONSIVE — MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {

    /* --- Container --- */
    .navbar-container {
        padding: 0 16px;
    }

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

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

    /* --- Mostrar botão hambúrguer --- */
    .navbar-mobile-toggle {
        display: flex;
    }

    /* --- Drawer: slide pela esquerda, fechado por padrão --- */
    .navbar-menu {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 300px;
        max-width: 85vw;
        background: #0f1628;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 5rem 1rem 2rem;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
        z-index: 1002;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
    }

    /* Drawer aberto pelo JS via .active */
    .navbar-menu.active {
        transform: translateX(0);
    }

    /* --- Itens do menu --- */
    .navbar-item {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 16px;
        border-radius: 8px;
        margin-bottom: 2px;
    }

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

    /* --- Dropdowns dentro do drawer — estáticos --- */
    .navbar-dropdown {
        width: 100%;
    }

    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: rgba(255, 255, 255, 0.04);
        border: none;
        border-left: 3px solid #60a5fa;
        border-radius: 6px;
        box-shadow: none;
        margin: 4px 0 8px 8px;
        padding: 4px 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .navbar-dropdown.active .dropdown-menu {
        max-height: 400px;
    }

    .dropdown-item {
        padding: 10px 16px;
        border-radius: 4px;
    }

    /* --- Perfil do usuário no final do drawer --- */
    .navbar-user {
        margin-top: auto;
        margin-left: 0;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        width: 100%;
    }

    /* Dentro do drawer, mostrar apenas avatar (sem texto inline no topo) */
    .navbar-user .user-info {
        display: none;
    }

    .navbar-user .dropdown-arrow-user {
        display: none;
    }

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

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

    /* --- Bloco de perfil clonado pelo JS dentro do drawer --- */
    .mobile-navbar-user {
        order: -1;
        margin-top: 0;
        margin-bottom: 1rem;
        align-self: stretch;
    }

    .mobile-navbar-user .user-profile {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        padding: 10px 12px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.06);
    }

    .mobile-navbar-user .user-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .mobile-navbar-user .user-name {
        color: #dbeafe;
        font-weight: 700;
        font-size: 0.96rem;
    }

    .mobile-navbar-user .user-role {
        color: rgba(219, 234, 254, 0.75);
        font-size: 0.82rem;
    }

    .mobile-navbar-user .user-avatar {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .mobile-navbar-user .dropdown-arrow-user {
        display: none;
    }

    /* --- Entrada de perfil fallback (.mobile-profile-entry) --- */
    .mobile-profile-entry {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 12px;
        background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
        border: 1px solid rgba(255, 255, 255, 0.05);
        box-shadow: 0 6px 18px rgba(2, 6, 23, 0.55);
        transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .mobile-profile-entry:hover,
    .mobile-profile-entry:focus-within {
        transform: translateY(-2px);
        box-shadow: 0 10px 28px rgba(2, 6, 23, 0.65);
        background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
        outline: none;
    }

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

    .mobile-profile-entry .user-avatar {
        width: 46px;
        height: 46px;
        min-width: 46px;
        border-radius: 50%;
        background: linear-gradient(135deg, #0ea5a8 0%, #3b82f6 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    }

    .mobile-profile-entry .mobile-profile-name {
        font-weight: 700;
        color: #dbeafe;
        font-size: 0.96rem;
        line-height: 1.1;
    }

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

    .page-container {
        padding: 1.5rem 1rem;
    }
}

/* ============================================
   RESPONSIVE — SMALL PHONES (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    .top-navbar {
        height: 56px;
    }

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

    .navbar-menu {
        padding-top: 4.5rem;
    }

    .navbar-user {
        margin-left: 6px;
    }
}

/* Keyframe usado internamente (não conflita com drawer) */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
