/* ===== CSS OTIMIZADO - NAVBAR ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
}

body {
    background: #f0faff;
}

/* ===== NAVBAR ===== */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 200px;
    background: #2422b1;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
}

.nav,
.nav .nav-links {
    display: flex;
    align-items: center;
}

a {
    color: #fff;
    text-decoration: none;
}

/* ===== LOGO ===== */
.nav .logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-img {
    height: 50px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
}

/* ===== MENU LINKS ===== */
.nav .nav-links {
    column-gap: 25px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    justify-content: flex-start;
}

.nav .nav-links a {
    transition: all 0.2s linear;
    font-weight: 1rem;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
}

.nav .nav-links a:hover {
    color: #ff0084;
}

/* ===== PESQUISA ===== */
.nav .search-container {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Ícone mobile */
.nav .search-icon.mobile {
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s linear;
    padding: 8px;
    border-radius: 50%;
    display: none;
}

.nav .search-icon.mobile:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Caixa de pesquisa desktop */
.nav .search-box {
    position: relative;
    height: 45px;
    width: 350px;
    opacity: 1;
    pointer-events: auto;
    /* REMOVER display: block FIXO - será controlado por media queries */
}

.search-box .search-icon {
    display: none;
}

.search-box input {
    height: 100%;
    width: 100%;
    border: none;
    outline: none;
    border-radius: 12px;
    background-color: #fff;
    padding: 0 45px 0 15px;
    font-size: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.search-box input:focus {
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
}

/* Botão de pesquisa */
.search-box .search-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    background: transparent;
    color: #666;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.search-box .search-btn:hover {
    background: rgba(36, 34, 177, 0.1);
    color: #2422b1;
}

.search-box .search-btn:active {
    transform: translateY(-50%) scale(0.9);
}

/* Resultados da busca */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 6px;
    margin-top: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 1001;
    border: 1px solid #eee;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    color: #333;
    transition: background 0.3s ease;
}

.search-result-item:hover {
    background: #f5f5f5;
}

.search-result-item:last-child {
    border-bottom: none;
}

/* ===== BOTOES MOBILE ===== */
.nav .navOpenBtn,
.nav .navCloseBtn {
    display: none;
}

/* ===== MEGA MENU OTIMIZADO ===== */
.nav-links .mega-menu-item {
    position: static;
}

.mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1001;
    border-top: 1px solid #eee;
}

/* Mega Menu Content Compacto */
.mega-menu-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 40px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 25px;
}

.mega-menu-section h4 {
    color: #2422b1;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mega-menu-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-menu-section li {
    margin-bottom: 6px;
}

.mega-menu-section a {
    color: #333 !important;
    padding: 4px 0;
    display: block;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 13px;
    line-height: 1.3;
}

.mega-menu-section a:hover {
    color: #2422b1 !important;
    padding-left: 5px;
}

/* Mostrar mega menu */
.mega-menu-item:hover .mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mega-menu-toggle i {
    display: none !important;
}

/* ===== RESPONSIVO ===== */

/* Desktop (1025px+) */
@media screen and (min-width: 1025px) {
    .nav {
        padding: 15px 200px;
        justify-content: space-between;
    }
    
    .nav .nav-links {
        flex: 0 1 auto;
        justify-content: center;
        margin: 0 auto;
    }
    
    .nav .search-container {
        flex-shrink: 0;
    }
    
    /* DESKTOP: Caixa de pesquisa sempre visível */
    .nav .search-box {
        display: block;
        width: 300px;
        position: relative;
        height: 45px;
        opacity: 1;
        pointer-events: auto;
    }
    
    .nav .search-icon.mobile {
        display: none;
    }
    
    .nav.openSearch .nav-links a {
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Mega menu desktop compacto */
    .mega-menu-content {
        padding: 15px 30px;
        gap: 20px;
    }
}

/* Tablets e Mobile (até 1024px) */
@media screen and (max-width: 1024px) {
    .nav {
        padding: 12px 20px;
    }
    
    .mega-menu-content {
        grid-template-columns: repeat(4, 1fr);
        padding: 15px 20px;
        gap: 20px;
        max-width: 90%;
    }
    
    .mega-menu-section h4 {
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .mega-menu-section a {
        font-size: 12px;
    }
    
    /* MOBILE: Caixa de pesquisa oculta por padrão */
    .nav .search-box {
        display: none;
        position: absolute;
        top: 100%;
        left: 20px;
        right: 20px;
        width: auto;
        margin-top: 10px;
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s ease;
        height: 45px;
    }
    
    /* MOBILE: Quando aberta via JavaScript */
    .nav.openSearch .search-box {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
    
    /* MOBILE: Ícone de pesquisa visível */
    .nav .search-icon.mobile {
        display: block;
    }
    
    .nav .nav-links {
        position: fixed;
        top: 0;
        left: -100%;
        height: 100%;
        max-width: 280px;
        width: 100%;
        padding-top: 60px;
        row-gap: 12px;
        flex-direction: column;
        background-color: #ffffff;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        transition: all 0.3s ease;
        z-index: 100;
    }

    .nav.openNav .nav-links {
        left: 0;
    }

    .nav .navOpenBtn,
    .nav .navCloseBtn {
        display: block;
    }

    .nav .navOpenBtn {
        color: #fff;
        font-size: 25px;
        cursor: pointer;
    }

    .nav .navCloseBtn {
        position: absolute;
        top: 15px;
        right: 15px;
        color: #000000;
        font-size: 25px;
        cursor: pointer;
    }

    .nav .nav-links a {
        color: #112170;
        font-weight: 500;
        font-size: 13px;
        padding: 6px 12px;
    }

    .logo-img {
        height: 35px;
        max-width: 100px;
    }

    .mega-menu {
        display: none;
    }
    
    /* MOBILE: Esconder links quando pesquisa aberta */
    .nav.openSearch .nav-links a {
        opacity: 0;
        pointer-events: none;
    }

     .nav .navOpenBtn {
        font-size: 25px;
    }
}

/* Tablets portrait (768px) */
@media screen and (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .nav .nav-links {
        max-width: 300px;
        padding-top: 70px;
        row-gap: 15px;
    }

    .nav .nav-links a {
        font-size: 14px;
        padding: 8px 15px;
    }

    .logo-img {
        height: 40px;
        max-width: 120px;
    }

    .nav {
        padding: 12px 25px;
    }
    
    .mega-menu-content {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
    }

     .nav .navOpenBtn {
        font-size: 25px;
    }
}

/* Mobile (481px - 767px) */
@media screen and (max-width: 767px) {
    .nav {
        padding: 10px 15px;
        gap: 20px;
    }
    
    .logo-img {
        height: 32px;
        max-width: 90px;
    }
    
    .nav .search-box {
        left: 15px;
        right: 15px;
    }
    
    .mega-menu-content {
        grid-template-columns: repeat(2, 1fr);
        padding: 15px;
        gap: 15px;
        max-width: 95%;
    }
    
    .mega-menu-section h4 {
        font-size: 12px;
        margin-bottom: 8px;
    }
    
    .mega-menu-section a {
        font-size: 11px;
    }
    
    .nav .nav-links {
        max-width: 250px;
        padding-top: 50px;
        row-gap: 10px;
    }
    
    .nav .nav-links a {
        font-size: 12px;
        padding: 5px 10px;
    }

    .nav .navOpenBtn {
        font-size: 25px;
    }
}

/* Mobile pequeno (até 480px) */
@media screen and (max-width: 480px) {
    .nav {
        padding: 8px 12px;
        gap: 15px;
    }
    
    .logo-img {
        height: 30px;
        max-width: 80px;
    }
    
    .mega-menu-content {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }
    
    .mega-menu-section {
        margin-bottom: 10px;
    }
    
    .mega-menu-section:last-child {
        margin-bottom: 0;
    }
    
    .nav .nav-links {
        max-width: 220px;
        padding-top: 45px;
    }
    
    .nav .navOpenBtn {
        font-size: 25px;
    }
    
    .nav .navCloseBtn {
        font-size: 25px;
        top: 12px;
        right: 12px;
    }
    
    /* Ajustes para mobile pequeno */
    .nav .search-box {
        left: 12px;
        right: 12px;
    }
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
    .nav .nav-links a,
    .search-box .search-btn,
    .mega-menu,
    .mega-menu-section a,
    .search-result-item {
        transition: none !important;
    }
    
    .mega-menu {
        transition: none !important;
    }
}

/* Touch devices optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav .nav-links a:hover {
        color: inherit;
    }
    
    .mega-menu-section a:hover {
        padding-left: 0;
    }
}