/* ===================================
   ENHANCED HEADER STYLES
   Cross-browser compatible header system
   =================================== */

/* CSS Custom Properties for Header */
:root {
    --header-height: 80px;
    --header-height-mobile: 70px;
    --header-z-index: 1000;
    --header-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --header-backdrop-blur: blur(10px);
    --header-box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    --header-border-radius: 0;
    --mobile-menu-width: 100%;
    --mobile-menu-height: 100vh;
}

/* ===================================
   BROWSER-SPECIFIC RESETS
   =================================== */

/* Chrome & Safari backdrop-filter support */
.browser-chrome .site-header,
.browser-safari .site-header {
    -webkit-backdrop-filter: var(--header-backdrop-blur);
    backdrop-filter: var(--header-backdrop-blur);
}

/* Firefox fallback (no backdrop-filter support) */
.browser-firefox .header-transparency-transparent {
    background: rgba(255, 255, 255, 0.98) !important;
}

/* Edge specific fixes */
.browser-edge .site-header .header-inner {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-align: center;
    align-items: center;
}

/* Internet Explorer 11 fallbacks */
.ie .site-header {
    background: #ffffff !important;
}

.ie .mobile-menu-overlay {
    display: none; /* Use simple dropdown for IE */
}

/* ===================================
   BASE HEADER STRUCTURE
   =================================== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--header-height);
    z-index: var(--header-z-index);
    transition: var(--header-transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--header-box-shadow);
}

.header-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    position: relative;
    gap: 2rem;
}

/* ===================================
   HEADER STYLE VARIATIONS
   =================================== */

/* Transparent Header */
/* Fix 1: Override transparent header with solid background */
.header-transparency-transparent {
    background: #ffffff !important; /* Solid white instead of rgba */
    backdrop-filter: none; /* Remove backdrop blur that can cause transparency issues */
    -webkit-backdrop-filter: none;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15) !important; /* Stronger shadow for definition */
}


/* Solid White Header */
.header-transparency-solid {
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Gradient Header */
.header-style-gradient {
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
    border-bottom: none;
}

.header-style-gradient .site-title,
.header-style-gradient .nav-menu a,
.header-style-gradient .header-phone a {
    color: white !important;
}

/* Dark Header */
.header-style-dark {
    background: #1f2937;
    border-bottom: 1px solid #374151;
}

.header-style-dark .site-title,
.header-style-dark .nav-menu a,
.header-style-dark .header-phone a {
    color: white !important;
}

/* Light Header */
.header-style-light {
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.header-style-light .site-title,
.header-style-light .nav-menu a {
    color: #1f2937 !important;
}

/* ===================================
   PAGE-SPECIFIC HEADER STYLES
   =================================== */

/* Home Page Header */
.header-context-home {
    position: absolute;
    background: transparent;
    box-shadow: none;
    border-bottom: none;
}

/* Fix 2: Ensure scrolled header is fully opaque */
.header-context-home.scrolled {
    position: fixed;
    background: #ffffff !important; /* Solid white background */
    backdrop-filter: none; /* Remove backdrop filter */
    -webkit-backdrop-filter: none;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15) !important; /* Darker border */
}

/* Services Page Header */
.header-context-services {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* Process Page Header */
.header-context-process {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Certifications Page Header */
.header-context-certifications {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

/* Contact Page Header */
.header-context-contact {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* Fix 3: Strengthen text contrast for all header text */
.site-header .site-title {
    color: #111827 !important; /* Darker text */
    font-weight: 900 !important; /* Bolder weight */
}

.site-header .nav-menu a {
    color: #111827 !important; /* Darker text */
    font-weight: 700 !important; /* Bolder weight */
}

.site-header .phone-link {
    color: #111827 !important; /* Darker text */
    font-weight: 700 !important;
}

/* Fix 4: Ensure hamburger is visible on all backgrounds */
.site-header .hamburger-line {
    background: #111827 !important; /* Dark hamburger lines */
    height: 3px; /* Slightly thicker lines */
}

/* Fix 5: Override any gradient/dark header conflicts */
.site-header:not(.header-style-gradient):not(.header-style-dark) .site-title,
.site-header:not(.header-style-gradient):not(.header-style-dark) .nav-menu a,
.site-header:not(.header-style-gradient):not(.header-style-dark) .phone-link,
.site-header:not(.header-style-gradient):not(.header-style-dark) .hamburger-line {
    color: #111827 !important;
}

/* Fix 6: Firefox specific fallback (enhanced) */
.browser-firefox .header-transparency-transparent,
.browser-firefox .header-context-home.scrolled {
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ===================================
   SITE BRANDING
   =================================== */

.site-branding {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    z-index: 2;
}

.site-logo {
    display: flex;
    align-items: center;
}

.site-title {
    font-size: 1.75rem;
    font-weight: 800;
    text-decoration: none;
    color: #1f2937;
    transition: var(--header-transition);
    line-height: 1;
    white-space: nowrap;
}

.custom-logo {
    max-height: 50px;
    width: auto;
    transition: var(--header-transition);
}

.site-tagline {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
    margin-left: 0.5rem;
    display: none; /* Hidden by default, can be enabled in customizer */
}

/* ===================================
   MAIN NAVIGATION
   =================================== */

.main-navigation {
    display: flex;
    align-items: center;
    flex-grow: 1;
    justify-content: center;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    display: block;
    padding: 1rem 1.25rem;
    color: #1f2937;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--header-transition);
    border-radius: 25px;
    position: relative;
    white-space: nowrap;
}

.nav-menu a:hover,
.nav-menu .current-menu-item > a {
    color: #1e40af;
    background: rgba(30, 64, 175, 0.1);
    transform: translateY(-2px);
}

/* Dropdown Menu Styles */
.nav-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 1rem 0;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--header-transition);
    z-index: 999;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.nav-menu li:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-menu .sub-menu a {
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    background: transparent;
    color: #374151;
}

.nav-menu .sub-menu a:hover {
    background: #f3f4f6;
    color: #1e40af;
    transform: none;
}

/* ===================================
   HEADER CTA BUTTON
   =================================== */

.header-cta {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-cta-button {
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--header-transition);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 2px solid transparent;
}

.header-cta-button.cta-primary {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
}

.header-cta-button.cta-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(30, 64, 175, 0.3);
}

.header-cta-button.cta-outline {
    background: transparent;
    color: #1e40af;
    border-color: #1e40af;
}

.header-cta-button.cta-outline:hover {
    background: #1e40af;
    color: white;
    transform: translateY(-2px);
}

.header-cta-button.cta-ghost {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.header-cta-button.cta-ghost:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Fix 8: Ensure CTA button is visible */
.site-header .header-cta-button.cta-primary {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%) !important;
    color: white !important;
    font-weight: 700 !important;
}

/* Fix 9: Mobile menu toggle contrast */
@media (max-width: 768px) {
    .site-header .mobile-menu-toggle:hover {
        background: rgba(17, 24, 39, 0.1) !important; /* Darker hover state */
    }
}

/* ===================================
   HEADER PHONE
   =================================== */

.header-phone {
    display: flex;
    align-items: center;
    margin-left: 1rem;
}

.phone-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #1f2937;
    text-decoration: none;
    font-weight: 600;
    transition: var(--header-transition);
    padding: 0.5rem;
    border-radius: 8px;
}

.phone-link:hover {
    color: #1e40af;
    background: rgba(30, 64, 175, 0.1);
}

.phone-icon {
    font-size: 1.2rem;
}

.phone-text {
    font-size: 0.95rem;
    white-space: nowrap;
}

/* ===================================
   MOBILE MENU TOGGLE
   =================================== */

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 8px;
    transition: var(--header-transition);
    z-index: 1001;
    position: relative;
}

.mobile-menu-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    width: 24px;
    height: 18px;
    justify-content: space-between;
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background: #1f2937;
    border-radius: 2px;
    transition: var(--header-transition);
    transform-origin: center;
}

/* Gradient/Dark header hamburger lines */
.header-style-gradient .hamburger-line,
.header-style-dark .hamburger-line {
    background: white;
}

/* Mobile menu active state */
.mobile-menu-active .hamburger-line:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.mobile-menu-active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-active .hamburger-line:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* ===================================
   MOBILE MENU OVERLAY
   =================================== */

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-content {
    width: 100%;
    height: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-site-branding {
    color: white;
}

.mobile-site-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 800;
    text-decoration: none;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--header-transition);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-navigation {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mobile-nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-nav-menu li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-nav-menu a {
    display: block;
    padding: 1.25rem 0;
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
    transition: var(--header-transition);
    position: relative;
    padding-left: 1rem;
}

.mobile-nav-menu a:before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
    background: #10b981;
    transition: var(--header-transition);
    border-radius: 2px;
}

.mobile-nav-menu a:hover:before,
.mobile-nav-menu .current-menu-item a:before {
    height: 30px;
}

.mobile-nav-menu a:hover {
    color: #10b981;
    padding-left: 1.5rem;
}

.mobile-menu-cta {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-cta-button {
    display: block;
    width: 100%;
    padding: 1rem;
    text-align: center;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 12px;
    transition: var(--header-transition);
}

.mobile-cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3);
}

.mobile-menu-phone {
    margin-top: 1rem;
}

.mobile-phone-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    transition: var(--header-transition);
}

.mobile-phone-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* ===================================
   BREADCRUMBS
   =================================== */

.breadcrumbs-container {
    background: #f8fafc;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.breadcrumbs {
    font-size: 0.875rem;
    color: #6b7280;
}

.breadcrumbs a {
    color: #1e40af;
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumbs a:hover {
    color: #1d4ed8;
}

.breadcrumb-separator {
    margin: 0 0.5rem;
    color: #9ca3af;
}

.current-page {
    color: #374151;
    font-weight: 500;
}

/* ===================================
   PAGE HEADER
   =================================== */

.page-header {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 3rem 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.page-header:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><radialGradient id="page-bg" cx="50%" cy="50%"><stop offset="0%" stop-color="rgba(30,64,175,0.05)"/><stop offset="100%" stop-color="transparent"/></radialGradient></defs><circle cx="200" cy="200" r="100" fill="url(%23page-bg)"/><circle cx="800" cy="800" r="150" fill="url(%23page-bg)"/></svg>');
    opacity: 0.5;
}

.page-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    color: #1f2937;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
}

.page-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 0.95rem;
    color: #6b7280;
    position: relative;
    z-index: 2;
}

.page-excerpt {
    font-size: 1.1rem;
    color: #6b7280;
    max-width: 600px;
    margin: 1rem auto 0;
    position: relative;
    z-index: 2;
}

.archive-description {
    font-size: 1rem;
    color: #6b7280;
    max-width: 800px;
    margin: 1rem auto 0;
    position: relative;
    z-index: 2;
}

/* ===================================
   HEADER LOADING STATE
   =================================== */

.header-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 1024px) {
    .header-container {
        padding: 0 30px;
    }
    
    .nav-menu {
        gap: 0.25rem;
    }
    
    .nav-menu a {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    .site-tagline {
        display: none;
    }
    
    .header-phone .phone-text {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: var(--header-height-mobile);
    }
    
    .main-navigation {
        display: none;
    }
    
    .header-cta {
        display: none;
    }
    
    .header-phone {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .site-title {
        font-size: 1.5rem;
    }
    
    .custom-logo {
        max-height: 40px;
    }
    
    .header-inner {
        gap: 1rem;
    }
    
    .breadcrumbs-container {
        padding: 0.75rem 0;
    }
    
    .page-header {
        padding: 2rem 0;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .page-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 0 20px;
    }
    
    .header-inner {
        gap: 0.5rem;
    }
    
    .site-title {
        font-size: 1.25rem;
    }
    
    .mobile-menu-content {
        padding: 1.5rem;
    }
    
    .mobile-menu-header {
        margin-bottom: 2rem;
    }
    
    .mobile-nav-menu a {
        font-size: 1.1rem;
        padding: 1rem 0;
    }
    
    .page-header {
        padding: 1.5rem 0;
    }
    
    .breadcrumbs {
        font-size: 0.8rem;
    }
}

/* ===================================
   ACCESSIBILITY ENHANCEMENTS
   =================================== */

/* Screen reader text */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    background-color: #f1f1f1;
    border-radius: 3px;
    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
    clip: auto !important;
    color: #21759b;
    display: block;
    font-size: 14px;
    font-weight: bold;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

/* Skip link */
.skip-link {
    background: #1e40af;
    color: white;
    padding: 1rem 1.5rem;
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999999;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    left: 6px;
    top: 7px;
}

/* Focus indicators */
.nav-menu a:focus,
.header-cta-button:focus,
.mobile-menu-toggle:focus,
.phone-link:focus {
    outline: 2px solid #1e40af;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .site-header {
        border-bottom: 2px solid;
    }
    
    .nav-menu a,
    .header-cta-button {
        border: 1px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .mobile-menu-overlay {
        transition: none;
    }
    
    .hamburger-line {
        transition: none;
    }
}

/* Print styles */
@media print {
    .site-header,
    .mobile-menu-overlay,
    .breadcrumbs-container {
        display: none;
    }
    
    body {
        padding-top: 0 !important;
    }
}