/* ==========================================================================
   Header Premium (3 Tiers)
   ========================================================================== */

   :root {
    --hp-primary: var(--portal-primary-hex, #1351B4);
    --hp-primary-light: var(--portal-primary-hex, #1351B4);
    --hp-secondary: var(--portal-accent-hex, #0ea5e9);
    --hp-orange: #f97316;
    --hp-text-light: var(--portal-text-on-primary, #ffffff);
    --hp-text-dark: var(--portal-text-on-primary, #1e293b);
    --hp-bg-white: #ffffff;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 160px; /* Offset for the 3-tier header */
    overflow-x: clip; /* Conserta bug do scrollY sem gerar rolagem dupla */
}

@media screen and (max-width: 991px) {
    html {
        scroll-padding-top: 120px; /* Smaller offset on mobile */
    }
}

.header-premium {
    width: 100%;
    font-family: 'Inter', 'Roboto', sans-serif;
    color: var(--hp-text);
    position: sticky;
    top: 0;
    z-index: 99998;
    transition: all 0.3s ease;
    background-color: var(--hp-primary, #1351B4);
}

/* Ensure contents stay above any background */
.header-premium > * {
    position: relative;
}

/* Sticky Minimal State */
.header-premium.is-sticky {
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

   /* Adjust sticky position if WordPress Admin Bar is visible */
   .admin-bar .header-premium {
       top: 32px;
   }
   @media screen and (max-width: 782px) {
       .admin-bar .header-premium {
           top: 46px;
       }
   }
   @media screen and (max-width: 600px) {
       .admin-bar .header-premium {
           top: 0 !important;
       }
   }

   /* Esconde a barra do meio suavemente ao rolar, para ficar minimalista e não tremer */
    .hp-middlebar {
        height: 250px;
        overflow: hidden;
        transition: height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
        opacity: 1;
    }
    
    .header-premium.is-sticky .hp-middlebar {
        height: 0 !important;
       padding-top: 0 !important;
       padding-bottom: 0 !important;
       opacity: 0 !important;
       pointer-events: none;
   }

/* --- TIER 1: Topbar --- */
.hp-topbar {
    background: var(--hp-primary-light);
    color: var(--hp-text-light);
    font-size: 0.85rem;
    padding: 8px 0;
    z-index: 10; /* Alta prioridade para menus dropdown como Acessibilidade */
    position: relative;
}

.hp-topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.hp-topbar-left {
    font-weight: 500;
}

.hp-topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.hp-topbar-right a, .hp-search-toggle {
    color: var(--hp-text-light);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.hp-topbar-right a:hover, .hp-search-toggle:hover,
.hp-topbar-right a:focus, .hp-search-toggle:focus {
    opacity: 0.8;
    outline: none;
}
.hp-topbar-right a:focus-visible, .hp-search-toggle:focus-visible {
    outline: 2px dashed rgba(255,255,255,0.8);
    outline-offset: 4px;
}

.hp-social-icons {
    display: flex;
    gap: 10px;
    margin-left: 10px;
    border-left: 1px solid rgba(255,255,255,0.3);
    padding-left: 15px;
}

/* --- TIER 2: Middlebar (Logo & Seals) --- */
.hp-middlebar {
    background-color: transparent;
    padding: 30px 0;
    height: 250px;
    display: flex;
    align-items: center;
}

.hp-middlebar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

/* Logo da Instituição */
body #hp-logo-link img,
body [class*="custom-logo-link"],
body .hp-logo img,
body .hp-logo a img {
    height: 140px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.custom-logo-link, .hp-logo a {
    display: block;
    flex-shrink: 0;
}

.hp-logo-text {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--hp-primary);
    text-decoration: none;
}

.hp-seals {
    display: flex;
    gap: 20px;
}

.hp-seal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    padding: 8px 15px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--hp-text-dark);
    line-height: 1.2;
    text-decoration: none;
    transition: background 0.2s;
}

.hp-seal-item:hover {
    background: #e2e8f0;
}

/* --- TIER 3: Navbar --- */
.hp-navbar {
    background-color: var(--hp-primary);
}

.hp-main-navigation {
    display: flex;
    align-items: center;
    width: 100%;
}

.hp-home-link {
    color: var(--hp-text-light);
    font-size: 1.2rem;
    padding: 15px 20px;
    text-decoration: none;
    transition: background 0.2s;
    flex-shrink: 0;
}

.hp-home-link:hover {
    background: rgba(255,255,255,0.1);
}

.hp-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap; /* Permite quebrar linha se não couber, em vez de esmagar */
    width: 100%;
}

.hp-nav-list li {
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-block;
}

.hp-nav-list a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--hp-text-light);
    text-decoration: none;
    padding: 15px 20px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.hp-nav-list a i {
    font-size: 1rem;
}

.hp-nav-list a:hover,
.hp-nav-list a:focus {
    background: rgba(255,255,255,0.1);
    outline: none;
}
.hp-nav-list a:focus-visible {
    outline: 2px dashed rgba(255,255,255,0.8);
    outline-offset: -2px;
}

/* Dropdown */
.hp-nav-list li ul {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--hp-primary-light);
    list-style: none;
    padding: 0;
    margin: 0;
    min-width: 260px;
    max-width: 380px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.hp-nav-list li:hover > ul,
.hp-nav-list li:focus-within > ul {
    display: block;
}

.hp-nav-list li ul li {
    display: block;
    width: 100%;
    white-space: normal; /* Fix horizontal overflow */
}

.hp-nav-list li ul li a {
    display: block;
    width: 100%;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-sizing: border-box;
    white-space: normal; /* Ensure text wraps */
    line-height: 1.3;
}

/* Fix for Home Icon */
.hp-nav-list li.menu-item-home > a::before,
.hp-nav-list li a[href="/"]::before {
    content: "\f015";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 5px;
}

/* Mobile Toggle */
.hp-mobile-toggle {
    display: none;
    width: 100%;
    background: var(--hp-primary-light);
    color: white;
    border: none;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 991px) {
    .hp-topbar-inner {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 6px;
        padding: 4px 8px;
    }

    .hp-topbar-left {
        width: 100%;
        text-align: center;
        font-size: 0.82rem;
    }

    .hp-topbar-right {
        width: 100%;
        justify-content: center;
        font-size: 0.8rem;
        gap: 12px;
        flex-wrap: wrap;
    }

    .hp-social-icons {
        margin-left: 0;
        border-left: none;
        padding-left: 0;
        width: 100%;
        justify-content: center;
        gap: 14px;
    }

    .header-premium.is-sticky .hp-topbar {
        display: none !important;
    }

    .hp-middlebar {
        height: auto;
        min-height: 90px;
        padding: 14px 0;
        background-color: var(--hp-primary, #1351B4);
    }

    .header-premium.is-sticky .hp-middlebar {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
    }

    .hp-middlebar-inner {
        justify-content: center;
        text-align: center;
    }

    body #hp-logo-link img,
    body [class*="custom-logo-link"],
    body .hp-logo img,
    body .hp-logo a img {
        height: 65px;
    }

    .hp-logo {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        gap: 6px !important;
        width: 100%;
    }

    .hp-logo-name {
        font-size: 1.35rem !important;
    }

    .hp-logo-slogan {
        font-size: 0.85rem !important;
    }
    
    .hp-seals {
        display: none; /* Hide seals on mobile to save space */
    }
    
    .hp-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 18px;
        font-size: 1rem;
    }
    
    .hp-main-navigation {
        flex-direction: column;
        display: none; /* Hidden by default on mobile, handled by JS toggle */
    }
    
    .hp-main-navigation.active {
        display: flex;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .hp-nav-list {
        flex-direction: column;
        width: 100%;
    }

    .hp-nav-list > li > a {
        padding: 12px 18px;
        font-size: 0.95rem;
    }
    
    .hp-home-link {
        display: none;
    }
    
    .hp-nav-list li ul {
        position: static;
        display: none;
        background: rgba(0,0,0,0.1);
    }
    
    .hp-nav-list li.menu-item-has-children > a::after {
        content: '\f0d7';
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        float: right;
    }

    /* Proteção contra sobreposição do botão VLibras quando o menu mobile está aberto */
    body.mobile-menu-open [vw] [vw-access-button],
    body:has(.hp-main-navigation.active) [vw] [vw-access-button] {
        opacity: 0.15 !important;
        pointer-events: none !important;
        transition: opacity 0.2s ease;
    }
}

/* ==========================================================================
   WP Query Block Pagination Fixes (Estilo GovBR)
   ========================================================================== */
.wp-block-query-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 40px 0;
    padding: 0;
    list-style: none;
}

body .wp-block-query-pagination-numbers,
body .wp-block-query-pagination-next,
body .wp-block-query-pagination-previous {
    margin: 0;
}

body .wp-block-query-pagination a,
body .wp-block-query-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 15px;
    background-color: #f8fafc;
    color: var(--portal-primary-hex, #1351B4);
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.wp-block-query-pagination a:hover {
    background-color: var(--portal-primary-hex, #1351B4);
    color: #fff;
    border-color: var(--portal-primary-hex, #1351B4);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.wp-block-query-pagination .current {
    background-color: var(--portal-primary-hex, #1351B4);
    color: #fff;
    border-color: var(--portal-primary-hex, #1351B4);
}

/* Back to Top (Parent Theme Override) & VLibras Widget Overrides
   ========================================================================== */
/* VLibras: Força a visibilidade e o posicionamento ignorando o tema pai */
[vw].enabled {
    z-index: 99999 !important;
}
html body [vw].enabled [vw-access-button],
[vw] [vw-access-button] {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    position: fixed !important;
    right: 0 !important;
    left: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 999999 !important;
}

/* Força a cor do botão VLibras para a identidade do portal */
html body [vw].enabled [vw-access-button] .access-button,
html body [vw].enabled [vw-access-button] .vw-access-button,
html body [vw].enabled [vw-access-button] {
    background-color: var(--portal-primary-hex, #1351B4) !important;
    color: var(--portal-text-on-primary, #ffffff) !important;
}

/* Design System GovBR global button rules center content.
   Override para os botões e links dentro do dropdown de acessibilidade. */
.hp-dropdown-menu .premium-accessibility-link {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
    background: transparent;
    border: none;
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--portal-primary-hex, #1351B4) !important; /* Force color to override topbar white text */
    font-size: 0.95rem;
    text-decoration: none;
    box-sizing: border-box;
    transition: background 0.2s ease-in-out;
}

.hp-dropdown-menu .premium-accessibility-link:hover,
.hp-dropdown-menu .premium-accessibility-link:focus {
    background: #f8fafc;
    outline: none;
}
.hp-dropdown-menu .premium-accessibility-link:focus-visible {
    outline: 2px solid var(--portal-primary-hex, #1351B4);
    outline-offset: -2px;
}
/* ==========================================================================
   Botão Voltar ao Topo (Premium Nativo)
   ========================================================================== */
body .premium-btt {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 45px;
    height: 45px;
    background: var(--portal-primary-hex, #1351B4);
    color: var(--portal-text-on-primary, #ffffff);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.premium-btt.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.premium-btt:hover,
.premium-btt:focus {
    background: var(--hp-primary-light, #0c326f);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* Ajuste no mobile/tablet para o botão do VLibras e Voltar ao Topo */
@media screen and (max-width: 991px) {
    .premium-btt {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Reposiciona o botão do VLibras no mobile/tablet para a lateral inferior, acima do voltar ao topo */
    html body [vw].enabled [vw-access-button],
    [vw] [vw-access-button] {
        top: auto !important;
        bottom: 75px !important;
        transform: none !important;
        right: 15px !important;
        left: auto !important;
        border-radius: 8px !important;
    }
}

