/* Configuração geral */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--bg-primary);
    box-shadow: var(--box-shadow);
    z-index: 999;
}

nav .nav-bar {
    height: 100%;
    max-width: 1250px;
    width: 100%;
    margin: auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    /* Importante para posicionamento absoluto do logo no mobile */
}

/* --- LOGO --- */
.nav-bar .logo {
    display: flex;
    align-items: center;
    z-index: 1000;
    /* Garante que fique acima de outros elementos se necessário */
    transition: all 0.3s ease;
}

.nav-bar .logo a img {
    height: 45px;
    width: auto;
    display: block;
    cursor: pointer;
}

/* --- ÁREA PRINCIPAL (LINKS + BOTÕES) --- */
.nav-bar .nav-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-left: 40px;
    /* Espaço entre logo e links */
}

/* --- LINKS DE NAVEGAÇÃO --- */
.nav-bar .links {
    display: flex;
    gap: 25px;
    /* Espaço entre os links */
    margin: 0 auto;
    /* ISSO CENTRALIZA OS LINKS NO DESKTOP */
}

.nav-bar .links li {
    position: relative;
    list-style: none;
    display: flex;
    align-items: center;
}

.nav-bar .links li a {
    font-weight: 500;
    letter-spacing: 0.1rem;
    font-size: 1rem;
    color: var(--text-secondary);
    /* Usa cor do tema */
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    /* Espaço entre texto e ícone chevron */
    transition: color 0.3s ease;

    &:hover {
        color: var(--hover-color);
    }
}

.nav-bar .links li .chevron-down-icon {
    background-color: var(--text-secondary);
    /* Cor padrão da seta */
}

/* Ícone da seta (Chevron) gira no hover */
.nav-bar .links .has-submenu a:hover .chevron-down-icon {
    transform: rotate(180deg);
    background-color: var(--hover-color);
    /* Muda cor da seta no hover */
    transition: background-color 0.3s, transform 0.3s;
}

/* --- SUB-MENU (Dropdown) --- */
.sub-menu {
    position: absolute;
    /* Começa logo abaixo do pai */
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px var(--shadow);
    border-radius: var(--border-radius-base);
    padding: 10px;
    min-width: 400px;

    /* Configuração de animação */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* Adicionamos margin-top para criar o espaço visual inicial */
    /* margin-top: 10px;  */
    transition: all 0.3s ease;

    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* --- A PONTE INVISÍVEL --- */
.sub-menu::before {
    content: "";
    position: absolute;
    top: -25px;
    /* Sobe para cobrir o buraco */
    width: 30%;
    height: 30px;
    /* Altura suficiente para conectar ao pai */
    background: transparent;
    /* Invisível */
    left: 50%;
    transform: translateX(-50%);
}

/* Mostra sub-menu no hover (Desktop) ou com classe .open (JS) */
.links li:hover .sub-menu,
.links li.open .sub-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    margin-top: 15px;
    /* Pequeno movimento suave para cima */
}

.sub-menu li a {
    padding: 8px 12px;
    display: block;
    width: 100%;
    min-height: 50px;
    border-radius: var(--border-radius-btn);
    transition: all 0.3s ease;
}

.sub-menu li a:hover {
    background-color: var(--bg-primary);
}

/* --- GRUPO DA DIREITA (LOGIN + TEMAS) --- */
.nav-right-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.login-button {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1rem;
    border: none;
    padding: 6px 16px;
    border-radius: var(--border-radius-btn);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 4px 1px var(--hover-color);
    transition: all 0.3s ease;

    &:hover {
        background-color: var(--hover-color);
        color: var(--text-btn);
        box-shadow: none;
    }

    .login-icon {
        background-color: var(--text-primary);
        transition: all 0.3s ease;
    }

    &:hover .login-icon {
        background-color: var(--text-btn);
    }
}

.login-button:active,
.login-button.active {
    transform: scale(0.95);
}

/* --- BOTÃO HAMBURGUER & SIDEBAR HEADER (Escondidos no Desktop) --- */
.open-button-menu,
.sidebar-header {
    display: none;
}

/* ======================================================================================== */
/* RESPONSIVIDADE (MOBILE - TUDO DENTRO DA GAVETA)                                          */
/* ======================================================================================== */
@media (max-width: 960px) {

    nav .nav-bar .logo {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
    }

    .nav-bar .logo a img {
        height: 35px;
    }

    .sidebar-header {
        width: 100%;
        height: 60px;
        background-color: var(--bg-secondary);
        display: flex;
        align-items: center;
        justify-content: flex-end;
        /* Botão de fechar fica na direita */
        padding: 0 20px;
        border-bottom: 1px solid var(--border);
    }

    .open-button-menu {
        width: 40px;
        height: 40px;
        padding: 5px 5px;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        display: block;
        margin-left: auto;
        /* Empurra para direita */
        background: none;
        border: none;
        border-radius: var(--border-radius-btn);
        cursor: pointer;
        background-color: transparent;
        box-shadow: 0 0 4px 1px var(--hover-color);
        transition: all 0.3s ease;

        &:hover {
            background-color: var(--hover-color);
            box-shadow: none;
        }
    }

    .open-button-menu .open-menu-icon {
        background-color: var(--text-primary);
    }

    .open-button-menu:active,
    .open-button-menu.active {
        background-color: var(--hover-color);
        transform: scale(0.95);
    }

    .open-button-menu .open-menu-icon {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 28px;
        height: 28px;
    }

    /* 2. O Sidebar (Menu Lateral) */
    .nav-bar .nav-links {
        margin: 0;
        padding: 0 0 50px 0;
        position: fixed;
        top: 0;
        right: -100%;
        /* Escondido para a direita */
        height: 100vh;
        width: 100%;
        /* Largura do menu */
        background-color: var(--bg-tertiary);
        box-shadow: -5px 0 15px var(--shadow);
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        /* Alinha tudo a esquerda dentro do menu */
        justify-content: flex-start;
        transition: right 0.4s ease;
        /* Animação suave */
        z-index: 1000;
        overflow-y: auto;
        /* Scroll se a tela for pequena */
        overflow-x: hidden;
        /* Nunca deixa barra de rolagem horizontal */
    }

    /* Classe ativa via JS para abrir o menu */
    .nav-bar .nav-links.mobile-active {
        right: 0;
    }

    /* 3. Header do Sidebar */
    .sidebar-logo {
        width: 100%;
        height: 60px;
        background-color: var(--bg-secondary);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
        position: relative;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-logo .logo a img {
        height: 35px;
        /* Ajuste conforme necessário */
        width: auto;
        display: block;
        cursor: pointer;
    }

    .close-button-menu {
        width: 40px;
        height: 40px;
        padding: 5px 5px;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        display: block;
        margin-left: auto;
        /* Empurra para direita */
        background: none;
        border: none;
        border-radius: var(--border-radius-btn);
        cursor: pointer;
        background-color: transparent;
        box-shadow: 0 0 4px 1px var(--hover-color);
        transition: all 0.3s ease;

        &:hover {
            background-color: var(--hover-color);
            box-shadow: none;
        }
    }

    .close-button-menu .close-menu-icon {
        background-color: var(--text-primary);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 28px;
        height: 28px;
    }

    .close-button-menu:active,
    .close-button-menu.active {
        background-color: var(--hover-color);
        transform: scale(0.95);
    }

    /* 4. Links no Mobile */
    .nav-bar .links {
        flex-direction: column;
        padding: 0 20px;
        width: 100%;
        gap: 0;
        margin: 0;
    }

    .nav-bar .links li {
        width: 100%;
        flex-wrap: wrap;
        /* Permite sub-menu quebrar linha */
    }

    .nav-bar .links li a {
        width: 100%;
        padding: 15px;
        justify-content: space-between;
        /* Texto na esquerda, seta na direita */
        font-size: 1rem;
        border-bottom: 1px solid var(--text-tertiary);
        border-radius: 0;
    }

    .nav-bar .links li a:hover {
        background-color: var(--bg-tertiary);
    }

    /* Sub-menu Mobile (Estático, empurra conteúdo) */
    .sub-menu {
        position: static;
        /* Remove posição absoluta */
        transform: none;
        width: 100%;
        opacity: 1;
        visibility: visible;
        display: none;
        /* Escondido por padrão */
        box-shadow: none;
        border: none;
        background-color: var(--bg-secondary);
        margin-bottom: 10px;
    }

    /* JS adiciona classe .open no LI pai para mostrar */
    .links li.open .sub-menu {
        display: flex;
    }

    /* 5. Botões (Login/Tema) no fim do menu mobile */
    .nav-right-group {
        flex-direction: column-reverse;
        /* Login em baixo dos temas */
        width: 100%;
        margin-top: auto;
        /* Empurra para o fundo se sobrar espaço */
        padding: 20px;
        align-items: center;
    }

    .login-button {
        width: 90%;
        /* Botão full width no mobile */
        font-size: 16px;
        justify-content: center;
        padding: 10px;
    }

    .btns-theme {
        gap: 15px;
    }
}

/* ======================================================================================== */
/*  Conteiner Thema Dark/Light e Color                                                      */
/* ======================================================================================== */
.btns-theme {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-theme {
    display: none;
    /* Esconde o checkbox mas mantém funcionalidade */
}

.label-theme {
    /* Estilo do container do toggle */
    position: relative;
    display: inline-block;
    display: flex;
    width: 74px;
    height: 36px;
    background: var(--bg-primary);
    box-shadow: 0 0 4px 1px var(--hover-color);
    border-radius: 50px;
    cursor: pointer;
}

.label-theme .ball {
    /* Ball - o círculo que se move */
    position: absolute;
    top: 2px;
    left: 2px;
    width: 32px;
    height: 32px;
    background-color: var(--accent-color);
    /* Cor inicial quando desativado */
    border-radius: 50%;
    transition: all .3s linear;
    /* Adicionado 'all' para transição de cor também */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    overflow: hidden;
}

.label-theme .ball:hover {
    background-color: var(--hover-color);
}

.label-theme>.icone {
    /* Ícones estáticos no fundo (fora do ball) inicialmente escondidos */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    z-index: 1;
    background-color: var(--text-tertiary);
    /* Cor cinza para os ícones */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    /* Inicialmente invisíveis */
    transition: opacity .3s ease;
}

/* --- Posicionamento dos ícones no fundo --- */
.paint-roller-icon {
    left: 8px;
}

.paintbrush-vertical-icon {
    right: 8px;
}

.moon-icon {
    left: 8px;
}

.sun-icon {
    right: 8px;
}

/* --- TOGGLE DE CORES (#chkColor) - ÍCONES NO FUNDO ---*/
#chkColor:not(:checked)+.label-theme>.icone.paintbrush-vertical-icon {
    opacity: 1;
    /* Torna visível */
}

#chkColor:checked+.label-theme>.icone.paint-roller-icon {
    opacity: 1;
    /* Torna visível */
}

#chkColor:checked+.label-theme>.icone.paintbrush-vertical-icon,
#chkColor:not(:checked)+.label-theme>.icone.paint-roller-icon {
    opacity: 0;
    /* Esconde o ícone oposto no fundo */
}

/* --- TOGGLE DARK/LIGHT (#chkSunMoon) - ÍCONES NO FUNDO --- */
#chkSunMoon:not(:checked)+.label-theme>.icone.sun-icon {
    opacity: 1;
    /* Torna visível */
}

#chkSunMoon:checked+.label-theme>.icone.moon-icon {
    opacity: 1;
    /* Torna visível */
}

#chkSunMoon:checked+.label-theme>.icone.sun-icon,
#chkSunMoon:not(:checked)+.label-theme>.icone.moon-icon {
    opacity: 0;
    /* Esconde o ícone oposto no fundo */
}

/* --- ÍCONES DENTRO DO BALL --- */
.label-theme .ball .icone {
    /* Ícones dentro do ball - inicialmente escondidos */
    display: none;
    position: static;
    /* Remove o posicionamento absoluto */
    transform: none;
    /* Remove o translateY */
}

/* --- TOGGLE DE CORES - ÍCONES NO BALL --- */
#chkColor:not(:checked)+.label-theme .ball .icone.paint-roller-icon {
    display: block;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chkColor:checked+.label-theme .ball .icone.paintbrush-vertical-icon {
    display: block;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- TOGGLE DARK/LIGHT - ÍCONES NO BALL --- */
#chkSunMoon:not(:checked)+.label-theme .ball .icone.moon-icon {
    display: block;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chkSunMoon:checked+.label-theme .ball .icone.sun-icon {
    display: block;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- ANIMAÇÃO DO BALL E ESTILOS ADICIONAIS --- */
.checkbox-theme:checked+.label-theme .ball {
    transform: translateX(38px);
    /* Movimento do ball quando marcado */
}