/* Mobile Optimizations for AppealArmor */

/* Mobile-first responsive design */
@media (max-width: 768px) {
    /* Fix viewport and prevent horizontal scroll */
    body {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Main container padding adjustments */
    .container,
    .max-w-7xl,
    .max-w-6xl,
    .max-w-4xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* LANDING PAGE MOBILE OPTIMIZATIONS */

    /* Hero section - better mobile spacing */
    #heroSection {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    /* Primary CTA button - A-GRADE mobile optimized */
    .pulse-animation,
    #startAppealBtn {
        font-size: 1.25rem !important;
        padding: 1rem 2rem !important;
        margin-bottom: 1rem;
        min-height: 56px !important; /* Premium touch target */
        min-width: 200px !important;
        border-radius: 28px !important; /* Easy thumb reach */
        transition: all 0.2s ease !important;
    }

    /* Haptic-style visual feedback for touch */
    #startAppealBtn:active,
    .pulse-animation:active {
        transform: scale(0.98) !important;
        background-color: #047857 !important;
        transition: transform 0.1s ease !important;
    }

    /* 3-step process - stack vertically on mobile */
    .flex.flex-col.md\\:flex-row {
        flex-direction: column !important;
        space-y: 1rem;
    }

    .flex.flex-col.md\\:flex-row .text-gray-400 {
        transform: rotate(90deg);
        font-size: 1.5rem;
    }

    /* Founder story section - mobile layout */
    .bg-blue-50 .flex {
        flex-direction: column !important;
        text-align: center !important;
        space-y: 1rem !important;
    }

    /* Benefits grid - 2 columns on mobile */
    .grid.md\\:grid-cols-2.lg\\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
    }

    /* Social proof stats - stack on mobile */
    .grid.md\\:grid-cols-3 {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }
    
    /* Upload sections - full width on mobile */
    .upload-section,
    .additional-docs-section,
    .voice-comments-section {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-radius: 0;
    }
    
    /* Larger touch targets for mobile - WCAG 2.5.5 compliance */
    button,
    .btn,
    input[type="button"],
    input[type="submit"],
    a.button,
    [role="button"] {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 12px 20px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Small inline buttons need special handling */
    .inline-btn,
    .small-btn {
        padding: 8px 16px;
        min-height: 44px !important;
    }
    
    /* Voice recording button - full width on mobile */
    #recordBtn {
        width: 100%;
        justify-content: center;
        font-size: 1.1rem;
    }
    
    /* File upload drop zones - better mobile sizing */
    #dropZone,
    #additionalDropZone {
        padding: 2rem 1rem;
        min-height: 180px;
    }
    
    /* Recording indicator - stack vertically */
    #recordingIndicator {
        justify-content: center;
        margin-top: 1rem;
    }
    
    /* Additional documents list - mobile friendly */
    #additionalDocsList > div {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    #additionalDocsList button {
        align-self: flex-end;
        margin-top: -2rem;
    }
    
    /* Audio player - full width */
    #audioPlayer {
        width: 100%;
    }
    
    /* Modal adjustments for mobile */
    .modal,
    .modal-content {
        width: 95%;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Text size adjustments for readability */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    p, .text-base { font-size: 1rem; }
    .text-sm { font-size: 0.9rem; }
    
    /* ===== A-GRADE: SKELETON LOADING & PERFORMANCE ===== */

    /* Skeleton loading animation for better perceived performance */
    .skeleton-loader {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: skeleton-pulse 1.5s ease-in-out infinite;
        border-radius: 4px;
    }

    @keyframes skeleton-pulse {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }

    .loading-skeleton-header {
        height: 32px;
        width: 80%;
        margin-bottom: 16px;
        border-radius: 8px;
    }

    .loading-skeleton-text {
        height: 16px;
        width: 100%;
        margin-bottom: 8px;
        border-radius: 4px;
    }

    .loading-skeleton-button {
        height: 44px;
        width: 150px;
        border-radius: 22px;
    }

    /* ===== A-GRADE: MOBILE UPLOAD EXPERIENCE ===== */

    /* Enhanced mobile file upload grid */
    .mobile-upload-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
        margin-top: 1rem !important;
    }

    .mobile-upload-option {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        padding: 1rem !important;
        background: #f8fafc !important;
        border: 2px dashed #cbd5e1 !important;
        border-radius: 12px !important;
        min-height: 80px !important;
        transition: all 0.2s ease !important;
        cursor: pointer !important;
    }

    .mobile-upload-option:active {
        background: #e2e8f0 !important;
        transform: scale(0.98) !important;
    }

    .mobile-upload-icon {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
        color: #475569 !important;
    }

    /* ===== A-GRADE: PROGRESS PRESERVATION ===== */

    .progress-indicator {
        position: fixed !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        background: rgba(0, 0, 0, 0.8) !important;
        color: white !important;
        padding: 8px 16px !important;
        border-radius: 20px !important;
        font-size: 0.875rem !important;
        z-index: 1000 !important;
        transition: opacity 0.3s ease !important;
    }

    /* Agent conversation - better mobile layout */
    .agent-conversation {
        padding: 1rem;
    }
    
    .agent-message,
    .user-message {
        max-width: 100%;
        word-wrap: break-word;
    }
    
    /* Timeline - horizontal scroll on mobile */
    .agent-timeline {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Packet items - stack on mobile */
    .packet-contents {
        flex-direction: column;
    }
    
    .packet-item {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* ===== A-GRADE: ERROR HANDLING & RECOVERY ===== */

    /* Mobile-optimized error recovery modal */
    .error-recovery-modal {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 1.5rem !important;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2) !important;
        z-index: 1001 !important;
        transform: translateY(100%) !important;
        transition: transform 0.3s ease !important;
    }

    .error-recovery-modal.show {
        transform: translateY(0) !important;
    }

    .error-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        margin-top: 1rem !important;
    }

    .error-action-btn {
        padding: 0.75rem 1rem !important;
        border-radius: 8px !important;
        font-weight: 600 !important;
        text-align: center !important;
        min-height: 44px !important;
        border: none !important;
        cursor: pointer !important;
    }

    .error-action-primary {
        background: #10b981 !important;
        color: white !important;
    }

    .error-action-secondary {
        background: #f3f4f6 !important;
        color: #374151 !important;
    }

    /* ===== A-GRADE: GESTURE SUPPORT ===== */

    /* Visual feedback for swipe gestures */
    .swipe-hint {
        position: relative !important;
        overflow: hidden !important;
    }

    .swipe-hint::after {
        content: '← Swipe →' !important;
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: rgba(79, 70, 229, 0.1) !important;
        color: #4f46e5 !important;
        text-align: center !important;
        padding: 4px !important;
        font-size: 0.75rem !important;
        opacity: 0.7 !important;
    }

    /* ===== A-GRADE: ENHANCED MICRO-INTERACTIONS ===== */

    /* Satisfying feedback for premium mobile experience */
    .btn-appeal:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
    }

    .btn-appeal:active {
        transform: translateY(0) !important;
        transition: transform 0.1s !important;
    }

    /* Fade-in animations for mobile */
    .fade-in-mobile {
        animation: fadeInUp 0.6s ease-out !important;
    }

    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Small mobile devices (iPhone SE, etc.) */
@media (max-width: 375px) {
    /* Even more compact spacing */
    .upload-section,
    .additional-docs-section,
    .voice-comments-section {
        padding: 0.75rem;
    }
    
    /* Smaller font sizes for very small screens */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
    p, .text-base { font-size: 0.95rem; }
    .text-sm { font-size: 0.85rem; }
    
    /* Compact buttons */
    button,
    .btn {
        padding: 10px 16px;
        font-size: 0.95rem;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .upload-section {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    #dropZone {
        min-height: 120px;
        padding: 1rem;
    }
    
    /* Hide less critical elements in landscape */
    .text-xs,
    .mt-4:not(.voice-comments-section) {
        display: none;
    }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Enable proper scrolling on iOS */
    body {
        position: relative;
        width: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix iOS form zoom */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Better touch feedback on iOS */
    button:active,
    .btn:active {
        opacity: 0.8;
    }
}

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

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Adjust colors for dark mode if needed */
    .upload-section,
    .additional-docs-section,
    .voice-comments-section {
        background-color: #1f2937;
        color: #f3f4f6;
    }
    
    .agent-message {
        background-color: #374151;
        color: #f3f4f6;
    }
}