/**
 * ARETIV PRO - MOBILE OPTIMIZATION FIX
 * ====================================
 *
 * This file fixes mobile display issues including:
 * - Burger menu visibility and functionality
 * - Responsive images and tables
 * - Mobile layout improvements
 * - Touch-friendly interface elements
 *
 * Author: Claude Code Assistant
 * Version: 1.0.0
 */

/* ==========================================================================
   MOBILE MENU FIXES
   ========================================================================== */

/**
 * Ensure Mobile Menu Toggle is Visible
 * Force display the hamburger menu on mobile devices
 */
@media (max-width: 767px) {
    /* FORCE REMOVE ALL HERO-BACKGROUND OVERLAYS - HIGHEST PRIORITY */
    .hero-section .hero-slide .hero-background::before,
    .hero-section .hero-background::before,
    .hero-slide .hero-background::before,
    .hero-background::before {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        background: transparent !important;
        content: "" !important;
        z-index: -1 !important;
    }

    .mobile-menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        position: relative;
        z-index: 1001;
    }

    .hamburger-icon {
        display: flex;
        flex-direction: column;
        width: 24px;
        height: 18px;
        position: relative;
    }

    .hamburger-icon span {
        display: block;
        height: 3px;
        width: 100%;
        background: #DC2626;
        border-radius: 2px;
        transition: all 0.3s ease;
        position: absolute;
    }

    .hamburger-icon span:nth-child(1) {
        top: 0;
    }

    .hamburger-icon span:nth-child(2) {
        top: 50%;
        transform: translateY(-50%);
    }

    .hamburger-icon span:nth-child(3) {
        bottom: 0;
    }

    /* Animated hamburger menu */
    .mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Hide desktop navigation on mobile */
    .main-navigation {
        display: none !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #2d2d2d !important;
        backdrop-filter: blur(10px);
        z-index: 1000;
        padding: 80px 20px 20px;
        overflow-y: auto;
        transition: all 0.3s ease;
    }

    .main-navigation.is-active {
        display: block !important;
    }

    /* Force dark background for mobile navigation - override inline styles */
    .main-navigation.mobile-menu-active,
    .main-navigation[style*="background"] {
        background: #2d2d2d !important;
    }

    .main-navigation ul {
        display: flex !important;
        flex-direction: column;
        gap: 0;
        padding: 0;
        margin: 0;
        list-style: none;
    }

    .main-navigation li {
        border-bottom: 1px solid #e5e7eb;
    }

    .main-navigation a {
        display: block;
        padding: 16px 0;
        font-size: 18px;
        font-weight: 500;
        color: #111827;
        text-decoration: none;
        transition: color 0.3s ease;
    }

    .main-navigation a:hover {
        color: #DC2626;
    }

    /* Mobile submenu styles */
    .main-navigation .sub-menu {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        background: #f9fafb;
        box-shadow: none !important;
        margin: 0;
        padding: 0;
        border-radius: 8px;
        margin-top: 8px;
    }

    .main-navigation .sub-menu a {
        padding: 12px 16px;
        font-size: 16px;
        color: #6b7280;
        border-bottom: none;
    }

    .main-navigation .sub-menu a:hover {
        background: #f3f4f6;
        color: #DC2626;
    }

    /* Ensure header elements don't overlap */
    .header-right {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    /* Mobile Search Button - Make Visible and Styled */
    .header-search {
        order: 1;
        display: flex !important;
    }

    .header-search .search-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px !important;
        height: 44px !important;
        background: #DC2626 !important;
        border: none !important;
        border-radius: 8px !important;
        cursor: pointer;
        transition: all 0.3s ease;
        padding: 8px !important;
    }

    .header-search .search-toggle:hover,
    .header-search .search-toggle:focus {
        background: #B91C1C !important;
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
    }

    .header-search .search-toggle:active {
        transform: translateY(0);
    }

    .header-search .search-icon {
        width: 20px !important;
        height: 20px !important;
        color: #ffffff !important;
        fill: none !important;
        stroke: #ffffff !important;
        stroke-width: 2;
    }

    .mobile-menu-toggle {
        order: 2;
    }

    .header-cta {
        display: none !important;
    }

    /* Hide hero dots and arrows on mobile */
    .hero-dots {
        display: none !important;
    }

    .hero-arrows {
        display: none !important;
    }

    /* Remove overlay from hero-background - force override */
    .hero-section .hero-background::before,
    .hero-slide .hero-background::before {
        display: none !important;
        background: none !important;
        content: none !important;
    }

    /* Add overlay only to the image container */
    .hero-image-container {
        position: relative;
        width: 100%;
        height: 100%;
    }

    .hero-image-container::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 55, 150, 0.5) !important;
        z-index: 1;
        pointer-events: none;
    }

    .hero-image-container .hero-bg-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    /* Set hero slide minimum height to 30vh on mobile */
    .hero-slide,
    .hero-section {
        min-height: 30vh !important;
    }

    /* Ensure text is readable over image with text shadow */
    .hero-title,
    .hero-subtitle {
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 1px 2px rgba(0, 0, 0, 0.6) !important;
        color: #ffffff !important;
    }

    /* Ensure all services are visible in mobile submenu */
    .services-submenu,
    .mobile-submenu,
    .mobile-services-submenu {
        overflow-y: auto;
        transition: max-height 0.3s ease;
    }

    /* Open state for services submenu */
    .services-submenu.submenu-open {
        max-height: 800px !important;
        overflow-y: auto !important;
    }

    /* Mobile CTA Button Optimization */
    .mobile-cta-btn {
        width: 100% !important;
        max-width: 280px !important;
        min-height: 56px !important;
        height: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        user-select: none !important;
        background: linear-gradient(135deg, #DC2626 0%, #B91C1C 50%, #991B1B 100%) !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        hyphens: auto !important;
        overflow: hidden !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        position: relative !important;
        padding: 16px 20px !important;
        line-height: 1.4 !important;
    }

    .mobile-cta-btn:hover,
    .mobile-cta-btn:focus {
        color: #ffffff !important;
        text-decoration: none !important;
        outline: none !important;
        background: linear-gradient(315deg, #DC2626 0%, #EF4444 50%, #F87171 100%) !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4) !important;
    }

    .mobile-cta-btn:active {
        transform: scale(0.98) translateY(-1px) !important;
    }

    /* General CTA Button Mobile Optimizations */
    .btn--primary,
    .cta-button {
        min-height: 48px !important;
        height: auto !important;
        padding: 14px 28px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        border-radius: 8px !important;
        text-align: center !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        width: auto !important;
        max-width: 90% !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        hyphens: auto !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        position: relative !important;
        line-height: 1.4 !important;
    }

    /* Ensure gradient is preserved on mobile */
    .btn--primary {
        background: linear-gradient(135deg, #DC2626 0%, #B91C1C 50%, #991B1B 100%) !important;
    }

    .btn--primary:hover,
    .btn--primary:focus {
        background: linear-gradient(315deg, #DC2626 0%, #EF4444 50%, #F87171 100%) !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4) !important;
        color: #ffffff !important;
        text-decoration: none !important;
    }

    .btn--primary:active {
        transform: translateY(0) scale(0.98) !important;
    }

    /* CTA Button specific mobile styles */
    .cta-button {
        background: linear-gradient(135deg, #DC2626 0%, #B91C1C 50%, #991B1B 100%) !important;
        color: #ffffff !important;
        position: relative !important;
        overflow: hidden !important;
    }

    .cta-button:hover {
        background: linear-gradient(315deg, #DC2626 0%, #EF4444 50%, #F87171 100%) !important;
        color: #ffffff !important;
        text-decoration: none !important;
    }

    /* CTA Button wrapper mobile optimization */
    .cta-button-wrapper {
        text-align: center !important;
        margin: 24px 0 !important;
        padding: 16px !important;
    }
}

/* ==========================================================================
   TABLET STYLES (768px - 1023px)
   ========================================================================== */

@media (min-width: 768px) and (max-width: 1023px) {
    /* FORCE REMOVE ALL HERO-BACKGROUND OVERLAYS - HIGHEST PRIORITY */
    .hero-section .hero-slide .hero-background::before,
    .hero-section .hero-background::before,
    .hero-slide .hero-background::before,
    .hero-background::before {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        background: transparent !important;
        content: "" !important;
        z-index: -1 !important;
    }

    /* Hide hero arrows on tablet as well */
    .hero-arrows {
        display: none !important;
    }

    /* Remove overlay from hero-background - force override */
    .hero-section .hero-background::before,
    .hero-slide .hero-background::before {
        display: none !important;
        background: none !important;
        content: none !important;
    }

    /* Add overlay only to the image container */
    .hero-image-container {
        position: relative;
        width: 100%;
        height: 100%;
    }

    .hero-image-container::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 55, 150, 0.4) !important;
        z-index: 1;
        pointer-events: none;
    }

    .hero-image-container .hero-bg-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    /* Set hero slide minimum height to 30vh on tablet as well */
    .hero-slide,
    .hero-section {
        min-height: 30vh !important;
    }

    /* Ensure text is readable over image with text shadow */
    .hero-title,
    .hero-subtitle {
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 1px 2px rgba(0, 0, 0, 0.6) !important;
        color: #ffffff !important;
    }
}

/* Additional mobile optimizations for smaller screens */
@media (max-width: 480px) {
    .btn--primary,
    .cta-button {
        max-width: 95% !important;
        min-width: auto !important;
        padding: 16px 24px !important;
        font-size: 16px !important;
        margin: 8px auto !important;
        height: auto !important;
        min-height: 48px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        hyphens: auto !important;
        line-height: 1.4 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .cta-button-wrapper {
        padding: 20px 16px !important;
        margin: 32px 0 !important;
        text-align: center !important;
        overflow: visible !important;
    }

    /* For very small screens, ensure adequate spacing */
    @media (max-width: 320px) {
        .btn--primary,
        .cta-button {
            max-width: 100% !important;
            padding: 18px 20px !important;
            min-height: 52px !important;
            font-size: 15px !important;
            line-height: 1.3 !important;
        }
    }
}

/* ==========================================================================
   RESPONSIVE IMAGES FIX
   ========================================================================== */

/**
 * Fix images that overflow on mobile
 * Make all images responsive and contained within their containers
 */
img {
    max-width: 100% !important;
    height: auto !important;
    display: block;
}

.wp-block-image img,
.attachment-full,
.size-full,
.hero-image img,
.service-image img,
.about-image img,
.team-image img,
.testimonial-image img,
.logo-image img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: cover;
}

/* Fix for images in content */
.entry-content img,
.post-content img,
.page-content img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    margin: 16px 0;
    border-radius: 8px;
}

/* Hero section image fixes */
.hero-section {
    background-size: cover !important;
    background-position: center !important;
    background-attachment: scroll !important; /* Fix for iOS */
}

/* ==========================================================================
   RESPONSIVE TABLES FIX
   ========================================================================== */

/**
 * Fix tables that overflow on mobile - COMPLETE OVERRIDE
 * Force standard table layout without any fancy responsive transformations
 */
@media (max-width: 767px) {
    /* Remove any ::before pseudo-elements that might be adding content */
    table th::before,
    table td::before {
        content: none !important;
        display: none !important;
    }

    /* Force all tables to use standard table display */
    table,
    .table-responsive table,
    .wp-block-table table,
    .entry-content table,
    .post-content table,
    .page-content table {
        display: table !important;
        min-width: 600px !important;
        width: 100% !important;
        table-layout: auto !important;
        border-collapse: collapse !important;
        margin: 0 !important;
        font-size: 14px !important;
        background: #ffffff !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 8px !important;
        overflow: visible !important;
    }

    /* Table headers - force standard display */
    table thead,
    table tbody {
        display: table-header-group !important;
    }

    table tbody {
        display: table-row-group !important;
    }

    table tr {
        display: table-row !important;
        border: none !important;
    }

    table th {
        display: table-cell !important;
        background: #f8f9fa !important;
        font-weight: 600 !important;
        color: #495057 !important;
        text-align: center !important;
        vertical-align: middle !important;
        padding: 12px 16px !important;
        border-bottom: 2px solid #dee2e6 !important;
        border-right: 1px solid #dee2e6 !important;
        white-space: nowrap !important;
        font-size: 13px !important;
        line-height: 1.2 !important;
        min-width: 120px !important;
    }

    table th:last-child {
        border-right: none !important;
    }

    /* Table data cells - force standard display */
    table td {
        display: table-cell !important;
        text-align: center !important;
        vertical-align: middle !important;
        padding: 10px 16px !important;
        border-bottom: 1px solid #dee2e6 !important;
        border-right: 1px solid #dee2e6 !important;
        color: #6c757d !important;
        white-space: nowrap !important;
        font-size: 12px !important;
        line-height: 1.3 !important;
        min-width: 120px !important;
    }

    table td:last-child {
        border-right: none !important;
    }

    table tr:last-child td {
        border-bottom: none !important;
    }

    /* Natural column widths based on content for better scrollability */
    table th,
    table td {
        width: auto !important;
        max-width: none !important;
    }

    /* Responsive wrapper - force horizontal scroll */
    .table-responsive {
        width: 100% !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 16px 0 !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 8px !important;
        background: #ffffff !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    }

    .table-responsive table {
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        min-width: 600px !important;
        width: auto !important;
    }

    /* Ensure tables without wrapper also get scroll capability */
    table:not(.table-responsive table) {
        min-width: 600px !important;
        width: auto !important;
        margin: 16px auto !important;
    }

    /* Hover effects */
    table tbody tr:hover {
        background-color: #f8f9fa !important;
    }

    /* Override any theme-specific table modifications */
    .entry-content table,
    .post-content table,
    .page-content table,
    .seo-text-content table {
        display: table !important;
        table-layout: fixed !important;
    }

    .entry-content table th,
    .post-content table th,
    .page-content table th,
    .seo-text-content table th,
    .entry-content table td,
    .post-content table td,
    .page-content table td,
    .seo-text-content table td {
        display: table-cell !important;
        text-align: center !important;
    }

    /* Remove any mobile-specific table transformations from theme */
    @supports (display: table) {
        table,
        table thead,
        table tbody,
        table tr,
        table th,
        table td {
            display: table !important;
        }

        table thead { display: table-header-group !important; }
        table tbody { display: table-row-group !important; }
        table tr { display: table-row !important; }
        table th, table td { display: table-cell !important; }
    }
}

/* ==========================================================================
   MOBILE LAYOUT IMPROVEMENTS
   ========================================================================== */

@media (max-width: 767px) {
    /**
     * Container and spacing fixes
     */
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
        max-width: 100% !important;
    }

    /**
     * Typography adjustments for mobile
     */
    h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 16px !important;
    }

    h2 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
        margin-bottom: 14px !important;
    }

    h3 {
        font-size: 1.5rem !important;
        line-height: 1.4 !important;
        margin-bottom: 12px !important;
    }

    p {
        font-size: 16px !important;
        line-height: 1.6 !important;
        margin-bottom: 16px !important;
    }

    /**
     * Button improvements for touch
     */
    .btn,
    button,
    .wp-block-button__link,
    input[type="submit"],
    input[type="button"] {
        min-height: 48px !important;
        padding: 12px 24px !important;
        font-size: 16px !important;
        touch-action: manipulation !important;
        border-radius: 8px !important;
        cursor: pointer !important;
    }

    /**
     * Form improvements for mobile
     */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    textarea,
    select {
        width: 100% !important;
        min-height: 48px !important;
        padding: 12px 16px !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
        border: 2px solid #e5e7eb !important;
        border-radius: 8px !important;
        background: #ffffff !important;
        box-sizing: border-box !important;
    }

    input:focus,
    textarea:focus,
    select:focus {
        outline: none !important;
        border-color: #DC2626 !important;
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
    }

    /**
     * Grid improvements for mobile
     */
    .grid,
    .services-grid,
    .testimonials-grid,
    .team-grid {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }

    /**
     * Card improvements for mobile
     */
    .service-card,
    .testimonial-card,
    .team-card,
    .card {
        padding: 20px !important;
        margin-bottom: 20px !important;
        border-radius: 12px !important;
    }

    /**
     * Section spacing for mobile
     */
    .section {
        padding: 40px 0 !important;
    }

    .section--lg {
        padding: 60px 0 !important;
    }

    /**
     * Footer improvements for mobile
     */
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
        text-align: center !important;
    }
}

/* ==========================================================================
   TOUCH AND ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/**
 * Improve touch targets and accessibility
 */
@media (max-width: 767px) {
    /* Larger touch targets */
    a,
    button,
    input,
    textarea,
    select {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Focus indicators */
    a:focus,
    button:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid #DC2626 !important;
        outline-offset: 2px !important;
    }

    /* Remove tap highlight on iOS */
    * {
        -webkit-tap-highlight-color: transparent !important;
    }

    /* Improve scrolling on iOS */
    body {
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT FOR MOBILE
   ========================================================================== */

@media (prefers-color-scheme: dark) and (max-width: 767px) {
    .main-navigation {
        background: rgba(17, 24, 39, 0.98) !important;
        color: #f9fafb !important;
    }

    .main-navigation a {
        color: #2d2d2d !important;
    }

    .main-navigation a:hover {
        color: #fca5a5 !important;
    }

    .main-navigation .sub-menu {
        background: #374151 !important;
    }

    .hamburger-icon span {
        background: #f9fafb !important;
    }
}

/* ==========================================================================
   UTILITY CLASSES FOR MOBILE
   ========================================================================== */

/**
 * Mobile-specific utility classes
 */
@media (max-width: 767px) {
    .mobile-hidden {
        display: none !important;
    }

    .mobile-visible {
        display: block !important;
    }

    .mobile-text-center {
        text-align: center !important;
    }

    .mobile-text-left {
        text-align: left !important;
    }

    .mobile-full-width {
        width: 100% !important;
    }

    .mobile-no-margin {
        margin: 0 !important;
    }

    .mobile-no-padding {
        padding: 0 !important;
    }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS FOR MOBILE
   ========================================================================== */

/**
 * Optimize animations and effects for mobile
 */
@media (max-width: 767px) {
    * {
        will-change: auto !important;
    }

    .parallax,
    .tilt-effect {
        transform: none !important;
        animation: none !important;
    }

    /* Reduce motion for better performance */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation: none !important;
            transition: none !important;
        }
    }
}

/* ==========================================================================
   BROWSER-SPECIFIC FIXES
   ========================================================================== */

/**
 * iOS Safari specific fixes
 */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS viewport units */
    .hero-section {
        min-height: -webkit-fill-available !important;
    }

    /* Fix for iOS form styling */
    input[type="search"] {
        -webkit-appearance: none !important;
        appearance: none !important;
    }

    /* Fix for iOS zoom issue */
    input,
    textarea,
    select {
        font-size: 16px !important;
    }
}

/**
 * Android Chrome specific fixes
 */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .mobile-menu-toggle {
        -webkit-tap-highlight-color: transparent !important;
    }
}

/* ==========================================================================
   PRINT STYLES FOR MOBILE
   ========================================================================== */

@media print {
    .mobile-menu-toggle,
    .main-navigation,
    .header-search,
    .hamburger-icon {
        display: none !important;
    }

    body {
        font-size: 12pt !important;
        line-height: 1.4 !important;
    }

    .container {
        max-width: none !important;
        padding: 0 !important;
    }
}

/* ==========================================================================
   DEBUGGING HELPERS (REMOVE IN PRODUCTION)
   ========================================================================== */

/*
.mobile-menu-toggle {
    border: 2px solid red !important;
    background: yellow !important;
}

.main-navigation {
    border: 2px solid blue !important;
}
*/