/* 
 * ENGAGEENGINE - Mobile Header Fix 2025
 * Following modern responsive design best practices
 * Mobile-first approach with Tailwind CSS compatibility
 */

/* =================================
   RESET & BASE STYLES
   ================================= */

* {
    box-sizing: border-box;
}

/* CRITICAL: Override any potential header hiding */
header {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure navigation container exists */
header nav {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Mobile Menu Default State - CLOSED */
#mobile-menu {
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
    opacity: 0;
    visibility: hidden;
}

/* Mobile Menu Open State */
#mobile-menu.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Hamburger Animation */
.hamburger {
    transition: all 0.3s ease;
}

.hamburger.open {
    transform: rotate(90deg);
}

/* =================================
   MOBILE FIRST (< 768px)
   ================================= */

/* Force proper mobile header layout */
@media (max-width: 767px) {
    
    /* Header Container - CRITICAL: Force visibility */
    header {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 50 !important;
        background: white !important;
        border-bottom: 1px solid #e5e7eb !important;
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1) !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* Navigation Container */
    nav {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 1rem !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        height: 4rem !important; /* 64px */
    }
    
    /* Logo */
    nav h1 {
        font-size: 1.25rem !important; /* 20px */
        font-weight: 700 !important;
        color: #2563EB !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
    }
    
    /* CRITICAL: Hide desktop navigation and contact button */
    .hidden.md\:flex,
    nav > div.hidden.md\:flex {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
    }
    
    /* Show mobile controls only */
    .md\:hidden {
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important; /* 12px */
    }
    
    /* Mobile Language Selector */
    #langSelectMobile {
        font-size: 0.75rem !important; /* 12px */
        padding: 0.25rem 0.5rem !important;
        border: 1px solid #d1d5db !important;
        border-radius: 0.375rem !important;
        background: white !important;
        min-height: 2.75rem !important; /* 44px - touch target */
        min-width: 2.75rem !important;
    }
    
    /* Mobile Menu Button */
    #mobile-menu-button {
        width: 2.75rem !important; /* 44px - touch target */
        height: 2.75rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: transparent !important;
        border: none !important;
        color: #4b5563 !important;
        cursor: pointer !important;
        border-radius: 0.375rem !important;
    }
    
    #mobile-menu-button:hover {
        background: #f3f4f6 !important;
        color: #2563EB !important;
    }
    
    #mobile-menu-button svg {
        width: 1.5rem !important; /* 24px */
        height: 1.5rem !important;
        stroke: currentColor !important;
        fill: none !important;
    }
    
    /* Mobile Menu Panel */
    #mobile-menu {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        border-bottom: 1px solid #e5e7eb !important;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
        z-index: 40 !important;
    }
    
    #mobile-menu .px-4 {
        padding: 1rem !important;
    }
    
    #mobile-menu a {
        display: block !important;
        padding: 0.75rem 0 !important;
        color: #374151 !important;
        text-decoration: none !important;
        font-weight: 500 !important;
        min-height: 2.75rem !important; /* 44px touch target */
        display: flex !important;
        align-items: center !important;
        border-bottom: 1px solid #f3f4f6 !important;
    }
    
    #mobile-menu a:hover {
        color: #2563EB !important;
    }
    
    #mobile-menu a:last-child {
        border-bottom: none !important;
    }
    
    /* CRITICAL: Hide any blue contact buttons in mobile menu */
    #mobile-menu .bg-primary,
    #mobile-menu a[class*="bg-primary"],
    #mobile-menu .border-t {
        display: none !important;
        visibility: hidden !important;
    }
}

/* =================================
   TABLET & DESKTOP (768px+)
   ================================= */

@media (min-width: 768px) {
    
    /* Hide mobile controls on desktop */
    .md\:hidden {
        display: none !important;
    }
    
    /* Show desktop navigation */
    .hidden.md\:flex {
        display: flex !important;
    }
    
    /* Ensure mobile menu is always hidden on desktop */
    #mobile-menu {
        display: none !important;
    }
    
    /* Desktop navigation spacing */
    nav {
        max-width: 80rem !important; /* 1280px */
        margin: 0 auto !important;
        padding: 0 1.5rem !important;
    }
    
    /* Desktop contact button styles */
    .hidden.md\:flex a[href*="contact"] {
        background-color: #2563EB !important;
        color: white !important;
        padding: 0.5rem 1rem !important;
        border-radius: 0.375rem !important;
        transition: opacity 0.2s ease !important;
        text-decoration: none !important;
        display: inline-flex !important;
        align-items: center !important;
        min-height: 2.75rem !important; /* 44px touch target */
    }
    
    .hidden.md\:flex a[href*="contact"]:hover {
        opacity: 0.9 !important;
    }
}

/* =================================
   ACCESSIBILITY & TOUCH TARGETS
   ================================= */

/* Ensure all interactive elements meet 44px minimum touch target */
.touch-target {
    min-height: 2.75rem !important; /* 44px */
    min-width: 2.75rem !important;
}

/* Focus states for accessibility */
button:focus,
select:focus,
a:focus {
    outline: 2px solid #2563EB !important;
    outline-offset: 2px !important;
}

/* Prevent iOS form zoom */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* =================================
   ANTI-GLITCH MEASURES
   ================================= */

/* Prevent any stray blue buttons on mobile */
@media (max-width: 767px) {
    
    /* Specifically target the desktop contact button */
    nav .hidden.md\:flex a[href="/contact.html"],
    nav .hidden.md\:flex a[href*="contact"],
    header a.bg-primary,
    header button.bg-primary,
    nav a.bg-primary,
    nav button.bg-primary {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
        width: 0 !important;
        height: 0 !important;
    }
}

/* =================================
   TEXT CONTRAST FIXES
   ================================= */

/* Fix text visibility on gray backgrounds */
.bg-gray-50 .text-gray-600,
section.bg-gray-50 .text-gray-600 {
    color: #374151 !important; /* darker gray for better contrast */
}

.bg-gray-100 .text-gray-600,
section.bg-gray-100 .text-gray-600 {
    color: #1f2937 !important; /* even darker for gray-100 background */
}

/* Ensure CTA sections are highly visible */
section.bg-primary {
    background-color: #2563EB !important;
    color: white !important;
}

section.bg-primary p {
    color: rgba(255, 255, 255, 0.9) !important;
}

section.bg-primary h2 {
    color: white !important;
}

/* Fix any light text on light backgrounds */
.text-gray-300, .text-gray-400, .text-gray-500 {
    color: #374151 !important;
}

/* Force high contrast on gradient backgrounds */
.gradient-bg {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #1d4ed8 100%) !important;
}

.gradient-bg h2 {
    color: white !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

.gradient-bg p {
    color: rgba(255,255,255,0.95) !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2) !important;
}

.text-blue-100 {
    color: rgba(255,255,255,0.9) !important;
}

/* Performance optimizations */
* {
    -webkit-tap-highlight-color: transparent;
}

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