/**
 * EOC Theme - Mobile & Responsive Fixes
 * Fixes for tables, cards, and overall mobile experience
 */

/* ============================================
   GLOBAL MOBILE FIXES
   ============================================ */

/* Force horizontal scroll on tables */
.table-wrapper,
.specs-table-wrapper,
table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tables responsive */
table {
    min-width: 600px;
}

/* Container padding on mobile */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Hero section */
    .hero {
        min-height: 50vh !important;
        padding: 80px 1rem 2rem !important;
    }

    .hero-title {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
    }

    .hero-subtitle {
        font-size: 1rem !important;
        line-height: 1.5 !important;
    }

    /* Section spacing */
    .section {
        padding: 2rem 0 !important;
    }

    .section-title {
        font-size: 1.5rem !important;
    }

    /* Grid fixes */
    .esd-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* Cards */
    .card {
        padding: 1.25rem !important;
    }

    /* Tables - make them scrollable */
    table {
        display: block !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        max-width: 100% !important;
    }

    table th,
    table td {
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Stats grid */
    [style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Feature grids */
    .features-grid,
    .services-grid {
        grid-template-columns: 1fr !important;
    }

    /* Footer */
    .footer-content {
        flex-direction: column !important;
        gap: 2rem !important;
        text-align: center !important;
    }

    .footer-links {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    /* Navigation */
    .navbar {
        padding: 0.75rem 1rem !important;
    }

    .nav-menu {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: var(--md-sys-color-background) !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 2rem !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s ease !important;
    }

    .nav-menu.active {
        transform: translateX(0) !important;
    }

    /* === NAVBAR MOBILE FIXES === */
    .navbar {
        padding: 0.5rem 1rem !important;
    }

    .navbar-container {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }

    .navbar-logo {
        flex-shrink: 0 !important;
        max-width: 100px !important;
    }

    .navbar-logo img {
        max-height: 40px !important;
        width: auto !important;
    }

    /* Hide CTA button on mobile - show in menu instead */
    .navbar-cta {
        display: none !important;
    }

    /* Menu toggle button */
    .navbar-toggle {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 5px !important;
        width: 40px !important;
        height: 40px !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
        z-index: 1001 !important;
        order: 3 !important;
    }

    .navbar-toggle span {
        display: block !important;
        width: 24px !important;
        height: 2px !important;
        background: var(--md-sys-color-primary) !important;
        transition: all 0.3s ease !important;
    }

    /* Mobile menu - MUST be hidden by default */
    .navbar-menu {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        /* Hidden off-screen */
        left: auto !important;
        bottom: auto !important;
        width: 80% !important;
        max-width: 320px !important;
        height: 100vh !important;
        background: rgba(18, 18, 18, 0.98) !important;
        backdrop-filter: blur(20px) !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 2rem !important;
        transition: right 0.3s ease !important;
        z-index: 1000 !important;
        padding: 2rem !important;
        transform: none !important;
        /* Override any transform */
        display: flex !important;
        visibility: visible !important;
    }

    /* Menu open state */
    .navbar-menu.active {
        right: 0 !important;
        /* Slide in from right */
    }

    .navbar-menu li {
        list-style: none !important;
    }

    .navbar-link {
        font-size: 1.25rem !important;
        padding: 0.75rem 1rem !important;
        color: #fff !important;
    }

    /* CTA buttons */
    .hero-actions {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .btn {
        width: 100% !important;
        text-align: center !important;
    }

    /* Contact cards */
    .contact-grid {
        grid-template-columns: 1fr !important;
    }

    /* Values/Features cards - 1 column */
    [style*="grid-template-columns: repeat(auto-fit, minmax(280px"] {
        grid-template-columns: 1fr !important;
    }

    /* Stats bar - 2x2 grid */
    [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* Compliance badges */
    .compliance-badges {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 1rem !important;
    }

    .compliance-badge {
        min-width: 140px !important;
        max-width: 45% !important;
    }

    /* Timeline */
    .timeline-item {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .timeline-item>div:first-child {
        min-width: auto !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .hero-title {
        font-size: 1.5rem !important;
    }

    .section-title {
        font-size: 1.25rem !important;
    }

    /* Stats - single column on very small */
    [style*="grid-template-columns: repeat(auto-fit, minmax(200px"] {
        grid-template-columns: 1fr !important;
    }

    /* Stat numbers smaller */
    .card [style*="font-size: 3.5rem"] {
        font-size: 2.5rem !important;
    }

    /* Tables - even smaller font */
    table th,
    table td {
        padding: 0.5rem !important;
        font-size: 0.75rem !important;
    }
}

/* ============================================
   SPECS TABLE SPECIFIC FIXES
   ============================================ */
.specs-table {
    width: 100%;
    border-collapse: collapse;
}

@media (max-width: 768px) {
    .specs-table {
        font-size: 0.875rem;
    }

    /* Card layout for spec tables on mobile */
    .specs-table,
    .specs-table tbody,
    .specs-table tr {
        display: block !important;
    }

    .specs-table thead {
        display: none;
    }

    .specs-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--md-sys-color-outline);
        border-radius: 8px;
        padding: 1rem;
    }

    .specs-table td {
        display: flex !important;
        justify-content: space-between !important;
        padding: 0.5rem 0 !important;
        border: none !important;
        white-space: normal !important;
    }

    .specs-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--md-sys-color-primary);
    }
}

/* ============================================
   IMAGE FIXES
   ============================================ */
img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .navbar,
    .footer,
    .fab-button {
        display: none !important;
    }

    .hero {
        min-height: auto !important;
        padding: 2rem !important;
    }
}

/* ============================================
   HOMEPAGE SPECIFIC MOBILE FIXES
   ============================================ */
@media (max-width: 768px) {

    /* === STATS SECTION FIX === */
    /* Force 2x2 grid on mobile, single column on very small */
    .stats-grid,
    .section [style*="display: grid"][style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* Stats cards - make them smaller */
    .stats-grid>div,
    .stat-card,
    .section [style*="display: grid"]>div[style*="background"] {
        padding: 1rem !important;
        min-width: 0 !important;
    }

    /* Stat numbers - smaller on mobile */
    .stat-number,
    [style*="font-size: 3.5rem"],
    [style*="font-size: 3rem"],
    [style*="font-size: 2.5rem"] {
        font-size: 2rem !important;
    }

    /* Stat labels */
    .stat-label,
    [style*="font-size: 0.875rem"] {
        font-size: 0.75rem !important;
    }

    /* === ABOUT SECTION FIX === */
    /* Stack all cards vertically */
    .about-cards,
    .about-grid,
    [style*="display: flex"][style*="gap"] {
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    /* About feature cards - full width */
    .about-card,
    .feature-card,
    [style*="flex: 1"][style*="padding"] {
        flex: none !important;
        width: 100% !important;
    }

    /* Hide overflow elements that create horizontal scroll */
    .about-section [style*="overflow"],
    section [style*="overflow: visible"] {
        overflow: hidden !important;
    }

    /* === INDUSTRIES SECTION FIX === */
    /* Force 2 columns for industry icons */
    .industries-grid,
    [style*="justify-content: center"][style*="gap"][style*="flex-wrap"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
        justify-items: center !important;
    }

    .industry-item,
    [style*="text-align: center"][style*="display: flex"][style*="flex-direction: column"] {
        width: 100% !important;
        max-width: 140px !important;
    }

    /* Industry icons - smaller */
    .industry-icon,
    [style*="font-size: 3rem"] {
        font-size: 2rem !important;
    }

    /* === FAB BUTTON FIX === */
    .fab-button,
    .floating-action-button,
    [style*="position: fixed"][style*="right"][style*="bottom"] {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.25rem !important;
        right: 1rem !important;
        bottom: 1rem !important;
    }

    /* Theme toggle - smaller and better positioned */
    .theme-toggle,
    #theme-toggle,
    [style*="position: fixed"][style*="right: 20px"] {
        width: 40px !important;
        height: 40px !important;
        right: 0.75rem !important;
        top: 80px !important;
        padding: 0.5rem !important;
    }

    /* === CTA SECTION FIX === */
    .cta-section,
    [style*="background"][style*="gradient"][style*="padding"] {
        padding: 2rem 1rem !important;
    }

    .cta-title,
    .cta-section h2,
    [style*="color"][style*="font-size: 2"] {
        font-size: 1.5rem !important;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    }

    /* CTA buttons - stack vertically */
    .cta-buttons,
    .cta-section [style*="display: flex"][style*="gap"] {
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
    }

    .cta-section .btn,
    .cta-buttons .btn {
        width: 100% !important;
    }

    /* === WHY CHOOSE EOC SECTION === */
    .features-section .grid,
    .why-choose-grid,
    [style*="display: grid"][style*="repeat(3"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* === EXPERTISE/SERVICES CARDS === */
    .services-grid,
    .expertise-grid,
    [style*="display: grid"][style*="repeat(auto-fit, minmax(300px"] {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* Service cards - adjust padding */
    .service-card,
    .expertise-card {
        padding: 1.5rem !important;
    }

    /* === FOOTER IMPROVEMENTS === */
    .footer {
        padding: 2rem 1rem !important;
    }

    .footer-content {
        flex-direction: column !important;
        text-align: center !important;
        gap: 2rem !important;
    }

    .footer-section {
        width: 100% !important;
    }

    .footer-links {
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }

    .footer-links a {
        padding: 0.5rem 1rem !important;
        display: block !important;
    }

    /* Social icons - better spacing */
    .social-icons,
    .footer [style*="display: flex"][style*="gap"] {
        justify-content: center !important;
        gap: 1rem !important;
    }

    .social-icon,
    .social-icons a {
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* === GENERAL OVERFLOW FIX === */
    body,
    html {
        overflow-x: hidden !important;
    }

    .container,
    .section,
    section {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* Glow effects - hide on mobile to prevent overflow */
    [style*="filter: blur"],
    [style*="background"][style*="radial-gradient"][style*="opacity"] {
        display: none !important;
    }
}

/* === EXTRA SMALL SCREENS (375px and below) === */
@media (max-width: 480px) {

    /* Stats - single column */
    .stats-grid,
    .section [style*="display: grid"][style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Industries - single column */
    .industries-grid,
    [style*="justify-content: center"][style*="gap"][style*="flex-wrap"] {
        grid-template-columns: 1fr !important;
    }

    .industry-item {
        max-width: 100% !important;
    }

    /* Even smaller stat numbers */
    .stat-number,
    [style*="font-size: 3.5rem"],
    [style*="font-size: 3rem"] {
        font-size: 1.75rem !important;
    }

    /* Hero title smaller */
    .hero-title {
        font-size: 1.25rem !important;
    }

    /* Buttons full width with smaller text */
    .btn {
        font-size: 0.875rem !important;
        padding: 0.75rem 1.5rem !important;
    }
}

/* ============================================
   ANTISTATIC & PRODUCT PAGE FIXES
   ============================================ */
@media (max-width: 768px) {

    /* Force simple grids to 1 column */
    .esd-grid,
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Fix Applications section alignment */
    [style*="gap: 4rem"] {
        gap: 2rem !important;
    }

    /* ESD Diagram responsive */
    .esd-diagram svg {
        width: 100% !important;
        height: auto !important;
        max-height: 300px !important;
    }

    /* ROI/Investment grid */
    [style*="grid-template-columns"][style*="minmax"] {
        grid-template-columns: 1fr !important;
    }

    /* Fix content padding/margins */
    .esd-content,
    .esd-visual {
        width: 100% !important;
        padding: 0 !important;
    }

    /* Feature tags wrap */
    .esd-features {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Canvas/Animation containers */
    #particles-canvas,
    canvas {
        max-width: 100vw !important;
        overflow: hidden !important;
    }

    /* === GENERAL CONTRAST FIXES (Mobile) === */
    /* Ensure text is readable on dark backgrounds */
    [data-theme="dark"] p,
    [data-theme="dark"] li,
    [data-theme="dark"] span:not(.badge):not(.btn) {
        color: #e0e0e0 !important;
    }

    [data-theme="dark"] h1,
    [data-theme="dark"] h2,
    [data-theme="dark"] h3,
    [data-theme="dark"] h4,
    [data-theme="dark"] strong {
        color: #ffffff !important;
    }

    /* Muted text should be lighter in dark mode */
    [data-theme="dark"] .text-secondary {
        color: #b0b0b0 !important;
    }
}