/* Header Governamental - Estilo ICEPI */

/* Cores ESP */
:root {
    --vermelho-esp: #E31E24;
    --azul-claro-esp: #00A9E0;
    --azul-esp: #1351B4;
    --laranja-esp: #F7941D;
}

/* Barra Colorida Superior */
.top-color-bar {
    height: 8px;
    background: linear-gradient(90deg, 
        #E31E24 0%,      /* Vermelho ESP */
        #E31E24 25%, 
        #00A9E0 25%,     /* Azul Claro ESP */
        #00A9E0 50%, 
        #1351B4 50%,     /* Azul ESP */
        #1351B4 75%,
        #F7941D 75%,     /* Laranja */
        #F7941D 100%
    );
}

/* Header Principal */
.main-header {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

/* Header Main */
.header-main {
    width: 100%;
    padding: 15px 0;
}

.header-content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 40px;
}

/* Logo Principal (sempre visível) - 1/4 do espaço */
.header-logo-primary {
    display: flex;
    align-items: center;
    flex: 0 0 25%;
    max-width: 25%;
}

.header-logo-primary img {
    display: block;
}

.logo-text-fallback {
    display: flex;
    flex-direction: column;
}

.logo-text-fallback .logo-main {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--vermelho-esp);
    line-height: 1;
}

.logo-text-fallback .logo-sub {
    font-size: 0.85rem;
    color: #666;
    margin-top: 4px;
}

.esp-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--vermelho-esp) 0%, var(--azul-esp) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(227, 30, 36, 0.2);
}

.logo-icon img {
    max-width: 100%;
    max-height: 100%;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-main {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--vermelho-esp);
    line-height: 1;
}

.logo-sub {
    font-size: 0.85rem;
    color: #666;
    margin-top: 4px;
}

.sergipe-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 30px;
    border-left: 1px solid #ddd;
}

.sergipe-brasao {
    width: 50px;
    height: 50px;
}

.sergipe-text {
    display: flex;
    flex-direction: column;
}

.sergipe-main {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

.sergipe-sub {
    font-size: 0.75rem;
    color: #666;
    margin-top: 2px;
}

/* Menu Navigation - 2/4 do espaço */
.main-nav {
    flex: 0 0 50%;
    max-width: 50%;
    display: flex;
    justify-content: center;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    flex-direction: column;
    gap: 4px;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: #333;
    transition: all 0.3s;
}

.menu-list {
    display: flex;
    list-style: none;
    gap: 0;
    margin: 0;
    padding: 0;
    align-items: center;
}

.menu-list li {
    margin: 0;
}

.menu-list > li > a {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.menu-list > li > a:hover {
    color: var(--vermelho-esp);
    border-bottom-color: var(--vermelho-esp);
}

.menu-list > li > a.active {
    color: var(--vermelho-esp);
    border-bottom-color: var(--vermelho-esp);
    font-weight: 600;
}

/* Ações: Busca + Login - 1/4 do espaço */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 0 0 25%;
    max-width: 25%;
    justify-content: flex-end;
}

/* Dropdown / Submenu */
.menu-list li.has-dropdown {
    position: relative;
}

.menu-list li.has-dropdown > a {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.menu-list li.has-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-top: 3px solid var(--vermelho-esp);
    list-style: none;
    margin: 0;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1000;
}

.menu-list li.has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu li {
    margin: 0;
}

.dropdown-menu a {
    padding: 12px 20px;
    display: block;
    color: var(--submenu-text, #FFFFFF);
    background: var(--submenu-bg, var(--vermelho-esp));
    text-decoration: none;
    font-weight: 400;
    font-size: 0.9rem;
    border-bottom: none;
    transition: all 0.2s;
}

.dropdown-menu a:hover {
    background: var(--submenu-bg, var(--vermelho-esp));
    color: var(--submenu-text, #FFFFFF);
    padding-left: 25px;
    opacity: 0.9;
}

.dropdown-menu a.active {
    background: var(--submenu-bg, var(--vermelho-esp));
    color: var(--submenu-text, #FFFFFF);
    font-weight: 600;
    padding-left: 25px;
    opacity: 0.95;
}

/* Submenu de Nível 3 (lateral) */
.dropdown-menu .has-submenu {
    position: relative;
}

.dropdown-menu .has-submenu > a .dropdown-arrow {
    float: right;
    margin-left: 10px;
}

.dropdown-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: white;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-top: 3px solid var(--vermelho-esp);
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    transition: all 0.3s;
    z-index: 1001;
}

.dropdown-menu .has-submenu:hover > .dropdown-submenu {
    display: block;
    animation: fadeInRight 0.3s;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive */
@media (max-width: 992px) {
    .header-logos {
        gap: 15px;
    }
    
    .sergipe-logo {
        padding-left: 15px;
    }
    
    .logo-main {
        font-size: 1.5rem;
    }
    
    .menu-list {
        gap: 5px;
    }
    
    .menu-list a {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .gov-bar {
        font-size: 0.75rem;
    }
    
    .header-content {
        flex-wrap: wrap;
        padding: 15px 0;
    }
    
    .header-logos {
        width: 100%;
        justify-content: space-between;
    }
    
    .sergipe-logo {
        border-left: none;
        padding-left: 0;
    }
    
    .sergipe-text {
        display: none;
    }
    
    .logo-sub {
        font-size: 0.75rem;
    }
    
    .menu-toggle {
        display: flex;
        flex-direction: column;
        gap: 4px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 5px;
    }
    
    .menu-toggle span {
        width: 25px;
        height: 3px;
        background: var(--azul-principal);
        border-radius: 2px;
        transition: 0.3s;
    }
    
    .main-nav {
        width: 100%;
        position: relative;
    }
    
    .menu-list {
        position: absolute;
        top: 100%;
        right: 0;
        background: white;
        flex-direction: column;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        border-radius: 8px;
        min-width: 200px;
        display: none;
        z-index: 1000;
    }
    
    .main-nav.active .menu-list {
        display: flex;
    }
    
    .menu-list a {
        border-bottom: none;
        border-left: 3px solid transparent;
    }
    
    .menu-list a:hover,
    .menu-list a.active {
        border-left-color: var(--azul-principal);
        border-bottom: none;
    }
    
    /* Dropdowns mobile */
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border-top: none;
        border-left: 3px solid var(--vermelho-esp);
        margin-left: 20px;
        margin-top: 5px;
        margin-bottom: 5px;
        display: none;
    }
    
    .menu-list li.has-dropdown.active .dropdown-menu {
        display: block;
    }
    
    .dropdown-menu a {
        font-size: 0.85rem;
        padding: 10px 15px;
    }
    
    .dropdown-menu a:hover {
        padding-left: 20px;
    }
    
    /* Submenu de nível 3 mobile */
    .dropdown-submenu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border-top: none;
        border-left: 3px solid var(--submenu-bg, var(--vermelho-esp));
        margin-left: 20px;
        margin-top: 5px;
        margin-bottom: 5px;
        display: none;
    }
    
    .dropdown-menu .has-submenu.active .dropdown-submenu {
        display: block;
    }
    
    .dropdown-submenu a {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
}

/* Campo de Busca */
.search-box {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border-radius: 20px;
    padding: 5px 15px;
    transition: all 0.3s;
    border: 1px solid #e0e0e0;
}

.search-box:focus-within {
    background: white;
    border-color: var(--vermelho-esp);
    box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.1);
}

.search-box input {
    border: none;
    background: transparent;
    padding: 5px;
    width: 180px;
    outline: none;
    font-size: 0.9rem;
    color: #333;
}

.search-box input::placeholder {
    color: #999;
}

.search-box button {
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    transition: color 0.3s;
}

.search-box button:hover {
    color: var(--vermelho-esp);
}

/* Botão de Login */
.login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--vermelho-esp);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
    white-space: nowrap;
}

.login-btn:hover {
    background: var(--azul-esp);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(19, 81, 180, 0.3);
}

.login-btn i {
    font-size: 1rem;
}

/* Logos Dinâmicas - Remove espaço se não existir */
.hidden-logo {
    display: none !important;
}

/* Animação do Triângulo nos Submenus */
.dropdown-menu .has-submenu > a::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 5px 0 5px 6px;
    border-color: transparent transparent transparent currentColor;
    transition: transform 0.3s;
}

.dropdown-menu .has-submenu.active > a::after {
    transform: translateY(-50%) rotate(90deg);
}

/* Responsive - Mobile */
@media (max-width: 968px) {
    .header-content-wrapper {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .header-logo-primary {
        order: 1;
    }
    
    .header-logo-secondary {
        order: 2;
        padding-left: 15px;
    }
    
    .header-actions {
        order: 3;
        margin-left: auto;
    }
    
    .main-nav {
        order: 4;
        width: 100%;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .main-nav.active .menu-toggle span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .main-nav.active .menu-toggle span:nth-child(2) {
        opacity: 0;
    }
    
    .main-nav.active .menu-toggle span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    .menu-list {
        display: none;
        flex-direction: column;
        width: 100%;
        background: white;
        position: absolute;
        top: 100%;
        left: 0;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        z-index: 100;
    }
    
    .main-nav.active .menu-list {
        display: flex;
    }
    
    .menu-list li {
        width: 100%;
    }
    
    .menu-list > li > a {
        padding: 15px 20px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .search-box input {
        width: 120px;
    }
    
    .login-btn span {
        display: none;
    }
}

@media (max-width: 480px) {
    .header-logo-secondary {
        width: 100%;
        order: 2;
        padding-left: 0;
        border-left: none;
        padding-top: 10px;
        border-top: 1px solid #e0e0e0;
        justify-content: center;
    }
}
