/* ========================================
   MOBILE RESPONSIVE ENHANCEMENTS V2.0
   Enhanced breakpoints, touch interactions, and mobile-specific optimizations
   ======================================== */

/* ========================================
   EXTRA SMALL MOBILE (iPhone SE, Galaxy Fold)
   ======================================== */
@media (max-width: 375px) {

    /* Ultra-compact spacing */
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Smaller typography */
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.25rem !important;
    }

    p {
        font-size: 0.95rem;
    }

    /* Compact buttons */
    .btn {
        padding: 12px 16px !important;
        font-size: 0.9rem !important;
    }

    /* Tighter section spacing */
    .section {
        padding-top: 30px !important;
        padding-bottom: 30px !important;
    }

    /* Smaller cards */
    .glass-card {
        padding: 16px !important;
    }
}

/* ========================================
   SMALL MOBILE (Standard Phones)
   ======================================== */
@media (max-width: 480px) {
    h1 {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.75rem !important;
    }

    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    .section {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }

    /* Smaller buttons on very small screens */
    .btn {
        padding: 14px 20px !important;
        font-size: 0.95rem !important;
    }

    /* Tighter spacing */
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        gap: 15px !important;
    }
}

/* ========================================
   MOBILE (Large Phones, Small Tablets)
   ======================================== */
@media (max-width: 768px) {

    /* Typography Scaling */
    h1 {
        font-size: 2.5rem !important;
        line-height: 1.2;
    }

    h2 {
        font-size: 2rem !important;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.5rem !important;
    }

    h4 {
        font-size: 1.25rem !important;
    }

    p {
        font-size: 1rem;
        line-height: 1.6;
    }

    /* Container Padding */
    .container {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* Section Padding */
    .section {
        padding-top: 60px !important;
        padding-bottom: 60px !important;
    }

    /* Hero Section */
    .hero-title {
        font-size: 2.5rem !important;
    }

    .hero-subtitle {
        font-size: 1.1rem !important;
    }

    /* Grid System */
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Cards */
    .card,
    .service-card,
    .feature-card {
        margin-bottom: 20px;
    }

    /* Buttons */
    .btn {
        width: 100%;
        padding: 16px 24px !important;
        font-size: 1rem !important;
    }

    .btn-group {
        flex-direction: column;
        gap: 15px;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* ========================================
       ENHANCED FORM IMPROVEMENTS
       ======================================== */

    /* Prevent zoom on input focus (iOS) */
    input,
    select,
    textarea {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        min-height: 48px;
        padding: 14px 16px !important;
        border-radius: 8px;
    }

    /* Better select dropdown */
    select {
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364ffda' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 16px center;
        background-size: 12px;
        padding-right: 44px !important;
    }

    .form-group {
        margin-bottom: 20px;
    }

    /* Submit buttons */
    input[type="submit"],
    button[type="submit"],
    .form-submit {
        width: 100%;
        min-height: 52px;
        font-size: 1.1rem !important;
        font-weight: 600;
        padding: 16px 24px !important;
    }

    /* Error messages */
    .error-message,
    .field-error {
        font-size: 0.9rem;
        margin-top: 6px;
        display: block;
        color: #ff6b6b;
    }

    /* Form labels */
    .form-label,
    label {
        font-size: 0.95rem;
        font-weight: 600;
        margin-bottom: 8px;
        display: block;
    }

    /* ========================================
       TABLES - HORIZONTAL SCROLL
       ======================================== */

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    table thead {
        display: table-header-group;
    }

    table tbody {
        display: table-row-group;
    }

    /* ========================================
       IMAGES & MEDIA
       ======================================== */

    img {
        max-width: 100%;
        height: auto;
    }

    /* Video embeds */
    iframe,
    video {
        max-width: 100%;
        height: auto;
    }

    /* ========================================
       STATS SECTION
       ======================================== */

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }

    .stat-card {
        text-align: center;
        padding: 30px 20px !important;
    }

    /* ========================================
       FOOTER
       ======================================== */

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 40px !important;
        text-align: center;
    }

    .footer-column {
        margin-bottom: 30px;
    }

    /* ========================================
       PAGE-SPECIFIC LAYOUTS
       ======================================== */

    /* Contact Page */
    .contact-grid,
    .grid-contact {
        grid-template-columns: 1fr !important;
    }

    .contact-info {
        margin-bottom: 30px;
    }

    /* About Page - Leadership */
    .leadership-grid {
        grid-template-columns: 1fr !important;
    }

    .leader-card {
        margin-bottom: 30px;
    }

    /* Services Page */
    .services-grid {
        grid-template-columns: 1fr !important;
    }

    /* Portfolio/Projects */
    .projects-grid {
        grid-template-columns: 1fr !important;
    }

    .project-card {
        margin-bottom: 25px;
    }

    /* Careers Page */
    .career-positions {
        grid-template-columns: 1fr !important;
    }

    /* Registration Form */
    .register-form .grid-2 {
        grid-template-columns: 1fr !important;
    }

    /* ========================================
       OVERFLOW PREVENTION
       ======================================== */

    /* Hide overflow on body */
    body {
        overflow-x: hidden;
    }

    /* Fix for elements breaking out */
    * {
        max-width: 100%;
    }

    /* ========================================
       SPACING UTILITIES
       ======================================== */

    .mb-mobile {
        margin-bottom: 20px;
    }

    .mt-mobile {
        margin-top: 20px;
    }

    .px-mobile {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ========================================
   TABLET PORTRAIT (iPad, Android Tablets)
   ======================================== */
@media (min-width: 769px) and (max-width: 1024px) {

    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    h1 {
        font-size: 3rem !important;
    }

    h2 {
        font-size: 2.5rem !important;
    }

    .container {
        padding-left: 30px !important;
        padding-right: 30px !important;
        max-width: 720px;
    }

    /* Tablet-optimized buttons */
    .btn {
        padding: 14px 28px;
    }

    /* Better grid for tablets */
    .services-grid,
    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ========================================
   TABLET LANDSCAPE
   ======================================== */
@media (min-width: 1025px) and (max-width: 1280px) {
    .container {
        max-width: 960px;
    }

    .grid-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .grid-3 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ========================================
   LANDSCAPE MOBILE (Phones in Landscape)
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .section {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }

    .hero-section {
        min-height: auto !important;
        padding: 60px 0 !important;
    }

    /* Reduce header size */
    .navbar {
        padding: 8px 20px !important;
    }

    .nav-logo-img {
        height: 32px !important;
    }

    /* Compact mobile menu */
    .mobile-menu-overlay .nav-links a {
        padding: 10px 20px;
        font-size: 1.2rem;
    }
}

/* ========================================
   TOUCH DEVICE ENHANCEMENTS
   ======================================== */
@media (hover: none) and (pointer: coarse) {

    /* Minimum tap target: 48x48px (WCAG AAA) */
    a,
    button,
    .btn,
    input[type="submit"],
    input[type="button"],
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 48px;
        min-width: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Increase spacing between tappable elements */
    .btn-group .btn {
        margin-bottom: 12px;
    }

    nav a {
        padding: 12px 16px;
    }

    /* Remove hover effects on touch devices */
    .card:hover,
    .btn:hover,
    a:hover {
        transform: none !important;
    }

    /* Add active states for visual feedback */
    .btn:active,
    button:active {
        transform: scale(0.96);
        opacity: 0.9;
        transition: transform 0.1s ease;
    }

    .card:active {
        transform: translateY(1px);
        box-shadow: var(--shadow-sm);
    }

    .glass-card:active {
        transform: translateY(1px);
        border-color: var(--color-secondary);
    }

    /* Larger checkbox and radio buttons */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
    }

    /* Better link spacing */
    a {
        padding: 8px 4px;
    }
}

/* ========================================
   REDUCED MOTION (Accessibility)
   ======================================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {

    .navbar,
    .mobile-toggle,
    .mobile-menu-overlay,
    .footer,
    .btn,
    .back-to-top {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .section {
        page-break-inside: avoid;
    }

    a {
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* ========================================
   MOBILE MENU OVERLAY
   ======================================== */
@media (max-width: 768px) {
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(10, 25, 47, 0.98);
        backdrop-filter: blur(10px);
        z-index: 9999;
        padding: 80px 30px 30px;
        overflow-y: auto;
    }

    .mobile-menu-overlay.active {
        display: flex;
        flex-direction: column;
        animation: slideIn 0.3s ease-out;
    }

    .mobile-menu-overlay .nav-links {
        display: flex;
        flex-direction: column;
        gap: 25px;
        margin-bottom: 40px;
    }

    .mobile-menu-overlay .nav-links a {
        font-size: 1.5rem;
        padding: 15px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        transition: all 0.3s ease;
    }

    .mobile-menu-overlay .nav-links a:active {
        color: var(--color-secondary);
        padding-left: 10px;
    }

    .mobile-menu-overlay .btn {
        width: 100%;
        margin-top: 20px;
    }

    @keyframes slideIn {
        from {
            opacity: 0;
            transform: translateX(-100%);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
}