/* Smart Header - Fixado no topo */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), 
                background 0.3s ease,
                padding 0.3s ease,
                box-shadow 0.3s ease;
    transform: translateY(0);
    will-change: transform, padding, background;
    
    /* REFINED GLASSMORPHISM LIGHT */
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

@supports not (backdrop-filter: blur(1px)) {
    .site-header {
        background: rgba(255, 255, 255, 0.95);
    }
}

/* Compensa o header fixo apenas quando necessário via classe adicionada por JS */
body.has-header-offset main {
    padding-top: var(--header-height, 80px);
}

.dark .site-header {
    /* REFINED GLASSMORPHISM DARK */
    background: rgba(20, 20, 20, 0.75);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

@supports not (backdrop-filter: blur(1px)) {
    .dark .site-header {
        background: rgba(20, 14, 30, 0.98);
    }
}

/* Scroll-Aware: Compact Header */
.site-header.header-scrolled {
    padding-top: 2px;
    padding-bottom: 2px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.8);
}

.dark .site-header.header-scrolled {
    background: rgba(15, 10, 22, 0.85);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.site-header.header-hidden {
    transform: translateY(-100%);
}

.site-header:not(.header-hidden) {
    transform: translateY(0) !important;
}

/* ========================================
   MOBILE MENU - NATIVE FEEL
   ======================================== */

#mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 320px;
    height: 100vh;
    /* Elevado acima do FAB (fab-container z-index: 9999) */
    z-index: 10002;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s ease;
    opacity: 0;
    display: flex !important; /* Always flex, but hidden via transform */
    flex-direction: column;
    pointer-events: none;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    /* Garante que o painel do menu seja opaco (não fica borrado pelo backdrop) */
    background: rgba(255, 255, 255, 0.98);
    color: #0f172a;
}

/* Dark variant para o painel mobile */
.dark #mobile-menu {
    background: rgba(10, 10, 12, 0.96);
    color: #fff;
}

#mobile-menu.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* Backdrop for mobile menu */
.menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    /* Backdrop fica abaixo do menu, mas acima do FAB */
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   RESILLIENT QUICK LINKS GRID
   ======================================== */
.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

/* ========================================
   MOBILE SERVICES ACCORDION
   ======================================== */

.mobile-services-accordion.open .accordion-arrow {
    transform: rotate(180deg);
}

.mobile-services-accordion.open .mobile-services-content {
    display: block;
    animation: accordionSlideDown 0.3s ease-out;
}

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

/* ========================================
   DESKTOP SERVICES DROPDOWN
   ======================================== */

.group:hover > .absolute {
    opacity: 1 !important;
    visibility: visible !important;
}

.group .absolute {
    pointer-events: auto;
}

.group .absolute > div {
    transform-origin: top center;
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s ease;
    transform: translateY(10px);
    opacity: 0;
}

.group:hover .absolute > div {
    transform: translateY(0);
    opacity: 1;
}

/* ========================================
   ACCESSIBILITY & UTILS
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.touch-target {
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* Fix: make certain absolute containers visible by default (e.g., stats overlay) */
.absolute.always-visible > div {
    opacity: 1 !important;
    transform: none !important;
}
