/* ===== ESTRUTURA PRINCIPAL ===== */
.navbar {
    display: flex;
    height: var(--header-height);
    background-color: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
}

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

/* ===== BRAND ===== */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: all 0.3s ease;
    flex-shrink: 0; /* Não deixa encolher */
}

.brand-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.navbar-brand:hover .brand-icon {
    transform: scale(1.1);
    filter: brightness(1.1);
}

/* Garantir que o logo wrapper funcione bem com o ícone */
.navbar-brand .logo-wrapper {
    display: inline-flex !important;
    white-space: nowrap !important;
    align-items: baseline !important;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: lowercase;
}

/* ===== MENU STRUCTURE ===== */
.navbar-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-grow: 1;
    margin-left: 2rem;
    min-width: 0; /* Importante para flex */
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-shrink: 1; /* Pode encolher se necessário */
}

/* ===== NAVBAR-END - CORRIGIDO ===== */
.navbar-end {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0; /* Nunca encolhe */
    min-width: 0;
}

/* ===== NAVBAR-ACTIONS (alias para navbar-end) ===== */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    min-width: 0;
}

/* ===== THEME SWITCH ===== */
.theme-switch {
    width: 52px;
    height: 26px;
    min-width: 52px;
    min-height: 26px;
    margin: 0;
    flex-shrink: 0;
}

/* ===== LANGUAGE SELECTOR ===== */
.language-selector {
    position: relative;
    z-index: 1002;
    flex-shrink: 0;
}

.language-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
    font-size: 1rem;
}

.language-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-color);
}

.language-btn .current-lang-flag {
    font-size: 1.2rem;
    line-height: 1;
}

.language-btn i {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.language-selector.open .language-btn i {
    transform: rotate(180deg);
}

.language-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card-bg, #1a1a2e);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    min-width: 140px;
    overflow: hidden;
}

.language-selector.open .language-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.language-option:hover {
    background: rgba(var(--primary-rgb), 0.15);
}

.language-option.active {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary-color);
}

.language-option .flag {
    font-size: 1.2rem;
    line-height: 1;
}

.language-option .lang-name {
    font-weight: 500;
}

/* ===== USER DROPDOWN ===== */
.user-dropdown {
    position: relative;
    z-index: 1001;
    flex-shrink: 0;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    color: var(--text-color);
    text-decoration: none;
    white-space: nowrap;
}

.dropdown-trigger:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid transparent;
    flex-shrink: 0;
}

/* ===== NAVBAR AUTH ===== */
.navbar-auth {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* ===== DROPDOWN MENU ===== */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0; /* Alinhar à direita */
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    min-width: 200px;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1002;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ===== MOBILE TOGGLE ===== */
.navbar-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-color);
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 1024px) {
    .navbar-nav {
        gap: 1.5rem;
    }
    
    .navbar-end,
    .navbar-actions {
        gap: 0.75rem;
    }
}

@media (max-width: 768px) {
    .navbar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .navbar-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card-bg);
        border-top: 1px solid var(--border-color);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 1rem;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        margin-left: 0;
    }
    
    .navbar-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .navbar-nav {
        flex-direction: column;
        gap: 0;
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .navbar-end,
    .navbar-actions {
        justify-content: center;
        width: 100%;
    }
    
    .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: rgba(138, 43, 226, 0.05);
        margin-top: 0.5rem;
        opacity: 1;
        visibility: visible;
        transform: none;
    }
}

@media (max-width: 600px) {
    .navbar {
        padding: 0 1rem;
    }
    
    .navbar-end .theme-switch,
    .navbar-actions .theme-switch {
        width: 44px;
        height: 24px;
        min-width: 44px;
    }
    
    .navbar-end .avatar,
    .navbar-actions .avatar {
        width: 28px;
        height: 28px;
    }
    
    .dropdown-trigger span {
        display: none; /* Esconder nome do usuário em telas pequenas */
    }
    
    /* Language selector mobile */
    .language-btn {
        padding: 0.35rem 0.5rem;
    }
    
    .language-btn .current-lang-flag {
        font-size: 1.1rem;
    }
    
    .language-btn i {
        font-size: 0.8rem;
    }
    
    .language-dropdown {
        min-width: 130px;
    }
    
    .language-option {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* ========== OTIMIZAÇÕES DE PERFORMANCE MOBILE ========== */
@media (max-width: 768px) {
    /* Remover backdrop-filter pesado em mobile */
    .navbar {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background-color: rgba(18, 18, 18, 0.98);
    }
}

/* Respeitar preferência de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    .navbar,
    .navbar-brand,
    .brand-icon,
    .navbar-link {
        transition: none !important;
    }
}