/* Enhanced Mobile Optimizations for Job Listings and Forms */

/* Mobile-first approach for all mobile devices */
@media screen and (max-width: 768px) {
    /* Job Modal Enhancements */
    #job-details-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 9999 !important;
        background: rgba(0, 0, 0, 0.95) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }
    
    #job-details-modal .modal-content {
        background: white !important;
        min-height: 100vh !important;
        min-height: calc(var(--vh, 1vh) * 100) !important;
        position: relative !important;
        z-index: 10000 !important;
    }
    
    /* Modal Header Mobile Enhancements */
    #job-details-modal .bg-white.border-b {
        position: -webkit-sticky !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 10001 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Modal Footer Mobile Enhancements */
    #job-details-modal .bg-white.border-t {
        position: -webkit-sticky !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10001 !important;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Modal Buttons */
    #job-details-modal button {
        min-height: 44px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    #job-details-modal button:active {
        transform: scale(0.98) !important;
        transition: transform 0.1s ease !important;
    }
    
    /* Job Cards Mobile Enhancements */
    .job-card {
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
        cursor: pointer !important;
    }
    
    .job-card:active {
        transform: scale(0.98) !important;
        transition: transform 0.1s ease !important;
    }
    
    /* Disable hover effects on mobile */
    .job-card:hover {
        transform: none !important;
    }
    
    /* Form Enhancements */
    .form-step {
        padding: 16px !important;
    }
    
    .form-step input,
    .form-step select,
    .form-step textarea {
        font-size: 16px !important;
        min-height: 48px !important;
        padding: 14px 16px !important;
        border-radius: 8px !important;
        border: 2px solid #e5e7eb !important;
        background: white !important;
        width: 100% !important;
        box-sizing: border-box !important;
        -webkit-appearance: none !important;
        appearance: none !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    .form-step input:focus,
    .form-step select:focus,
    .form-step textarea:focus {
        outline: none !important;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
        transform: none !important;
        -webkit-transform: none !important;
        transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    }
    
    .form-step input.mobile-focused {
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
        transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    }
    
    .form-step label {
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #374151 !important;
        margin-bottom: 8px !important;
        display: block !important;
    }
    
    .form-step .validation-error {
        font-size: 14px !important;
        color: #ef4444 !important;
        margin-top: 8px !important;
        padding: 8px 12px !important;
        background: #fef2f2 !important;
        border-radius: 6px !important;
        border: 1px solid #fecaca !important;
    }
    
    /* Form Buttons */
    .form-step button {
        min-height: 48px !important;
        padding: 14px 24px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        font-weight: 600 !important;
    }
    
    .form-step button:active {
        transform: scale(0.98) !important;
        transition: transform 0.1s ease !important;
    }
    
    /* Disable excessive animations on mobile */
    .form-step button:hover {
        box-shadow: none !important;
        transform: none !important;
    }
    
    .form-step .next-btn,
    .form-step .prev-btn {
        width: 100% !important;
        margin: 8px 0 !important;
    }
    
    /* File Input Enhancements */
    .form-step input[type="file"] {
        display: none !important;
    }
    
    .mobile-file-input-wrapper {
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 24px !important;
        border: 2px dashed #d1d5db !important;
        border-radius: 12px !important;
        background: #f9fafb !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        text-align: center !important;
        min-height: 100px !important;
        touch-action: manipulation !important;
    }
    
    .mobile-file-input-wrapper:hover {
        border-color: #3b82f6 !important;
        background: #eff6ff !important;
    }
    
    .mobile-file-button {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 14px 24px !important;
        background: #3b82f6 !important;
        color: white !important;
        border: none !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        touch-action: manipulation !important;
        min-height: 48px !important;
    }
    
    .mobile-file-button:hover {
        background: #2563eb !important;
    }
    
    .mobile-file-button:active {
        transform: scale(0.98) !important;
        background: #1d4ed8 !important;
    }
    
    /* Checkbox and Radio Enhancements */
    .form-step input[type="checkbox"],
    .form-step input[type="radio"] {
        width: 20px !important;
        height: 20px !important;
        min-height: 20px !important;
        margin-right: 12px !important;
        accent-color: #3b82f6 !important;
    }
    
    /* Select Dropdown Enhancements */
    .form-step select {
        background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E") !important;
        background-position: right 16px center !important;
        background-repeat: no-repeat !important;
        background-size: 16px !important;
        padding-right: 48px !important;
        cursor: pointer !important;
    }
    
    /* Textarea Enhancements */
    .form-step textarea {
        min-height: 120px !important;
        resize: vertical !important;
        line-height: 1.6 !important;
        font-family: inherit !important;
    }
    
    /* Progress Bar Mobile Enhancements */
    .progress-step-item {
        padding: 12px !important;
        border-radius: 8px !important;
        margin-bottom: 8px !important;
    }
    
    .progress-step-item.active {
        background: #eff6ff !important;
        border-color: #3b82f6 !important;
    }
    
    .progress-step-item.completed {
        background: #f0fdf4 !important;
        border-color: #10b981 !important;
    }
    
    .progress-step-item .icon-wrapper {
        width: 40px !important;
        height: 40px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin-right: 12px !important;
    }
    
    .progress-step-item .step-text {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    .progress-step-item .step-number {
        font-weight: 600 !important;
        color: #374151 !important;
    }
    
    .progress-step-item .step-title {
        color: #6b7280 !important;
        margin-top: 2px !important;
    }
    
    /* Input Wrapper Enhancements */
    .input-wrapper {
        margin-bottom: 24px !important;
    }
    
    .input-wrapper .input-icon {
        display: none !important;
    }
    
    .input-wrapper input.has-icon {
        padding-left: 16px !important;
    }
    
    /* Form Step Titles */
    .form-step h3 {
        font-size: 24px !important;
        margin-bottom: 8px !important;
        line-height: 1.2 !important;
        color: #111827 !important;
        font-weight: 700 !important;
    }
    
    .form-step > p {
        font-size: 16px !important;
        margin-bottom: 24px !important;
        line-height: 1.5 !important;
        color: #6b7280 !important;
    }
    
    /* Prevent iOS zoom on input focus */
    input[type="text"],
    input[type="email"], 
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100% !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }
    
    /* Smooth scrolling for modal */
    #job-details-modal {
        scroll-behavior: smooth !important;
    }
    
    /* Loading states */
    .form-submitting {
        pointer-events: none !important;
        opacity: 0.8 !important;
    }
    
    .form-submitting * {
        cursor: wait !important;
    }
}

/* Landscape orientation fixes */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .form-step {
        padding: 12px !important;
    }
    
    .form-step h3 {
        font-size: 20px !important;
        margin-bottom: 6px !important;
    }
    
    .form-step > p {
        font-size: 14px !important;
        margin-bottom: 16px !important;
    }
    
    .input-wrapper {
        margin-bottom: 16px !important;
    }
    
    .form-step input,
    .form-step select,
    .form-step textarea {
        min-height: 44px !important;
        padding: 12px 16px !important;
    }
    
    .form-step button {
        min-height: 44px !important;
        padding: 12px 20px !important;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media screen and (max-width: 375px) {
    .form-step {
        padding: 12px !important;
    }
    
    .form-step h3 {
        font-size: 22px !important;
    }
    
    .form-step input,
    .form-step select,
    .form-step textarea {
        padding: 12px 14px !important;
    }
    
    .form-step button {
        padding: 12px 20px !important;
    }
    
    .mobile-file-input-wrapper {
        padding: 20px !important;
        min-height: 80px !important;
    }
    
    .mobile-file-button {
        padding: 12px 20px !important;
    }
}

/* High DPI screens */
@media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
    #job-details-modal {
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
    
    .form-step input,
    .form-step select,
    .form-step textarea,
    .form-step button {
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
}

/* Dark mode support for mobile */
@media screen and (max-width: 768px) and (prefers-color-scheme: dark) {
    .form-step input,
    .form-step select,
    .form-step textarea {
        background: #1f2937 !important;
        color: #f9fafb !important;
        border-color: #4b5563 !important;
    }
    
    .form-step input:focus,
    .form-step select:focus,
    .form-step textarea:focus {
        border-color: #60a5fa !important;
        box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1) !important;
    }
    
    .form-step label {
        color: #e5e7eb !important;
    }
    
    .form-step h3 {
        color: #f9fafb !important;
    }
    
    .form-step > p {
        color: #d1d5db !important;
    }
}

/* Enhanced Mobile Navigation Styles */
@media screen and (max-width: 768px) {
    /* Mobile Navigation Overlay */
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Mobile Menu Container */
    #mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        background: transparent;
        pointer-events: none;
        /* Ensure it's properly hidden initially */
        visibility: hidden;
    }
    
    #mobile-menu.hidden {
        visibility: hidden;
        pointer-events: none;
    }
    
    #mobile-menu:not(.hidden) {
        visibility: visible;
        pointer-events: auto;
    }
    
    .mobile-nav-transition {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mobile-nav-content {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-radius: 24px 24px 0 0;
        box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.1), 0 -10px 10px -5px rgba(0, 0, 0, 0.04);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: auto;
        max-height: 85vh;
        min-height: 50vh;
        overflow: hidden;
        /* Force hardware acceleration for smooth animation */
        will-change: transform;
        backface-visibility: hidden;
        -webkit-transform: translate3d(0, 100%, 0);
        transform: translate3d(0, 100%, 0);
    }
    
    #mobile-menu.mobile-nav-open .mobile-nav-content {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    /* Mobile Navigation Header */
    .mobile-nav-header {
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
        border-bottom: 1px solid #e2e8f0;
        position: relative;
    }
    
    .mobile-nav-header::after {
        content: '';
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: #cbd5e1;
        border-radius: 2px;
    }
    
    /* Mobile Navigation Body */
    .mobile-nav-body {
        padding-bottom: env(safe-area-inset-bottom, 20px);
        overflow-y: auto;
        max-height: calc(85vh - 80px);
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mobile Navigation Items */
    .mobile-nav-item {
        position: relative;
        transform: translateX(-10px);
        opacity: 0;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    #mobile-menu.mobile-nav-open .mobile-nav-item {
        transform: translateX(0);
        opacity: 1;
    }
    
    #mobile-menu.mobile-nav-open .mobile-nav-item:nth-child(1) { transition-delay: 0.1s; }
    #mobile-menu.mobile-nav-open .mobile-nav-item:nth-child(2) { transition-delay: 0.2s; }
    #mobile-menu.mobile-nav-open .mobile-nav-item:nth-child(3) { transition-delay: 0.3s; }
    #mobile-menu.mobile-nav-open .mobile-nav-item:nth-child(4) { transition-delay: 0.4s; }
    
    .mobile-nav-item:hover {
        transform: translateX(4px);
        box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-nav-item.active {
        box-shadow: 0 8px 25px -5px rgba(59, 130, 246, 0.3);
    }
    
    /* Hamburger Animation */
    .mobile-menu-toggle {
        position: relative;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mobile-menu-toggle:hover {
        background: rgba(59, 130, 246, 0.1) !important;
        transform: scale(1.05);
    }
    
    .hamburger-line {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform-origin: center;
    }
    
    .mobile-menu-toggle.active .hamburger-line-1 {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-toggle.active .hamburger-line-2 {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active .hamburger-line-3 {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    /* Body scroll lock when menu is open */
    body.mobile-nav-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Quick actions animation */
    .mobile-nav-body .grid > a {
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mobile-nav-body .grid > a:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.1);
    }
    
    /* Enhanced touch targets */
    .mobile-nav-item {
        min-height: 48px !important;
        touch-action: manipulation !important;
    }
    
    /* Safe area padding */
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .mobile-nav-body {
            padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
        }
    }
    
    /* Improved accessibility focus states */
    .mobile-nav-item:focus {
        outline: 2px solid #3b82f6 !important;
        outline-offset: 2px !important;
        background: #f0f9ff !important;
    }
    
    /* Dark mode support */
    @media (prefers-color-scheme: dark) {
        .mobile-nav-content {
            background: #1f2937;
            color: white;
        }
        
        .mobile-nav-header {
            background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
            border-bottom-color: #374151;
        }
        
        .mobile-nav-item {
            color: #e5e7eb;
        }
        
        .mobile-nav-item:hover {
            background: #374151 !important;
        }
    }
}

/* Job Listings Mobile Enhancements */
@media screen and (max-width: 768px) {
    .job-card {
        border-radius: 12px !important;
        margin-bottom: 16px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        transition: all 0.3s ease !important;
    }
    
    .job-card:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
    }
    
    .job-title {
        font-size: 1.125rem !important;
        line-height: 1.4 !important;
        margin-bottom: 8px !important;
    }
    
    .job-company {
        font-size: 0.95rem !important;
        color: #2563eb !important;
    }
    
    .job-salary {
        background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%) !important;
        border-radius: 8px !important;
        padding: 12px !important;
        margin: 12px 0 !important;
    }
    
    .apply-btn-lookalike {
        font-size: 0.875rem !important;
        padding: 10px 16px !important;
        border-radius: 8px !important;
        transition: all 0.2s ease !important;
    }
    
    .apply-btn-lookalike:hover {
        background-color: #1d4ed8 !important;
        transform: scale(1.02) !important;
    }
    
    /* Text truncation utility */
    .line-clamp-2 {
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
    
    /* Job listings section spacing */
    #job-listings-section {
        padding: 3rem 1rem !important;
    }
    
    #jobs-container {
        gap: 1.5rem !important;
        grid-template-columns: 1fr !important;
    }
    
    /* Improved job card layout on mobile */
    .job-card-header {
        margin-bottom: 1rem !important;
    }
    
    .job-details {
        margin-bottom: 1rem !important;
    }
    
    .job-card-footer {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: stretch !important;
    }
    
    .apply-btn-lookalike {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }
    
    .view-details-lookalike {
        justify-content: center !important;
        font-size: 0.875rem !important;
    }
}
