/**
 * MOBILE OPTIMIZATIONS for Payment Portal
 * File: mobile-fixes.css
 * Priority: HIGH - loads after main stylesheet
 *
 * Fixes:
 * 1. Horizontal scrolling
 * 2. Touch target sizes
 * 3. Text sizes
 * 4. Button visibility
 * 5. Typography hierarchy
 * 6. Visual polish
 */

/* CRITICAL FIX #1: Prevent Horizontal Scrolling */
@media (max-width: 768px) {
    html,
    body,
    body * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    /* Container elements */
    .tpp-container,
    .tpp-header-content,
    .tpp-main-content,
    .tpp-content-wrapper,
    .tpp-card,
    .tpp-dual-panel,
    .tpp-payment-layout,
    .tpp-form-row,
    .tpp-citation-grid {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Images and media */
    img,
    video,
    iframe {
        max-width: 100% !important;
        height: auto !important;
    }

    /* CRITICAL FIX #2: Text Sizes (Minimum 14px) */
    * {
        font-size: inherit;
    }

    body {
        font-size: 16px !important;
    }

    /* Small text minimum */
    small,
    .small-text,
    .tpp-contact-label,
    .tpp-tagline,
    .tpp-header-info,
    .tpp-community-name,
    .tpp-citation-badge,
    .tpp-detail-label,
    .tpp-input-hint,
    .tpp-security-badge span,
    .tpp-secure-logos,
    .tpp-faq-answer p,
    .tpp-faq-answer li {
        font-size: 14px !important;
    }

    /* Form elements */
    input,
    select,
    textarea,
    button,
    .tpp-btn,
    label {
        font-size: 16px !important;
    }

    /* CRITICAL FIX #3: Touch Target Sizes (Minimum 48x48px) */

    /* All buttons */
    .tpp-btn,
    button,
    input[type="button"],
    input[type="submit"],
    .tpp-btn-primary,
    .tpp-btn-secondary,
    .tpp-btn-ghost,
    .tpp-btn-large {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 12px 20px !important;
        margin: 8px 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Large buttons */
    .tpp-btn-large {
        min-height: 56px !important;
        padding: 16px 24px !important;
        font-size: 18px !important;
    }

    /* Full width buttons on mobile */
    .tpp-btn-full,
    .tpp-receipt-actions .tpp-btn {
        width: 100% !important;
    }

    /* Links */
    a {
        min-height: 44px !important;
        padding: 12px 16px !important;
        display: inline-flex !important;
        align-items: center !important;
    }

    a:not(.tpp-btn) {
        display: inline-flex !important;
        min-height: 44px !important;
    }

    /* Form inputs */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    select,
    textarea {
        min-height: 48px !important;
        padding: 14px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        width: 100% !important;
    }

    .tpp-form-group.modern input {
        min-height: 48px !important;
        padding: 14px 18px !important;
    }

    /* Progress circles */
    .tpp-progress-circle {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
    }

    /* Contact methods */
    .tpp-contact-method,
    .tpp-faq-contact-method {
        min-height: 48px !important;
        padding: 14px 16px !important;
    }

    /* FAQ buttons */
    .tpp-faq-question {
        min-height: 56px !important;
        padding: 16px 20px !important;
    }

    .tpp-faq-trigger {
        min-height: 48px !important;
        padding: 14px 24px !important;
    }

    /* CRITICAL FIX #4: Button Visibility */

    /* Primary buttons - MUST be visible */
    .tpp-btn-primary,
    button.tpp-btn-primary,
    input[type="submit"],
    .tpp-btn.tpp-btn-primary {
        background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
        background-color: #2563eb !important;
        color: #ffffff !important;
        border: none !important;
        font-weight: 600 !important;
    }

    .tpp-btn-primary:hover,
    .tpp-btn-primary:active,
    .tpp-btn-primary:focus {
        background: #1e40af !important;
        background-color: #1e40af !important;
        color: #ffffff !important;
    }

    /* Secondary buttons */
    .tpp-btn-secondary {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #0f172a !important;
        border: 2px solid #e2e8f0 !important;
    }

    .tpp-btn-secondary:hover {
        background: #f1f5f9 !important;
        border-color: #2563eb !important;
        color: #2563eb !important;
    }

    /* Ensure white text in blue areas */
    .tpp-header-banner,
    .tpp-header-banner *,
    .tpp-btn-primary,
    .tpp-btn-primary *,
    .tpp-btn-primary span,
    .tpp-btn-primary svg,
    .tpp-faq-trigger,
    .tpp-faq-trigger *,
    .tpp-progress-step.active .tpp-progress-circle,
    .tpp-progress-step.active .tpp-progress-circle * {
        color: #ffffff !important;
    }

    /* Spacing between buttons */
    .tpp-btn + .tpp-btn,
    button + button {
        margin-top: 12px !important;
    }

    .tpp-receipt-actions {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .tpp-receipt-actions .tpp-btn {
        margin: 0 !important;
        width: 100% !important;
    }

    /* Ensure cards don't overflow */
    .tpp-card {
        padding: 20px !important;
        margin: 0 !important;
        width: 100% !important;
    }

    /* Form rows stack on mobile */
    .tpp-form-row {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Citation grid stacks */
    .tpp-citation-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* ENHANCEMENT #5: Visual Hierarchy & Typography */

    /* Page titles - stronger hierarchy */
    .tpp-page-title,
    h1.tpp-page-title {
        font-size: 28px !important;
        font-weight: 700 !important;
        color: #0f172a !important;
        line-height: 1.2 !important;
        margin-bottom: 12px !important;
    }

    .tpp-subtitle {
        font-size: 16px !important;
        color: #64748b !important;
        line-height: 1.5 !important;
        margin-bottom: 24px !important;
    }

    /* Section headings */
    h2 {
        font-size: 24px !important;
        font-weight: 700 !important;
        line-height: 1.3 !important;
    }

    h3 {
        font-size: 20px !important;
        font-weight: 600 !important;
        line-height: 1.3 !important;
    }

    h4 {
        font-size: 18px !important;
        font-weight: 600 !important;
        line-height: 1.4 !important;
    }

    /* ENHANCEMENT #6: Focus States for Accessibility */

    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus,
    .tpp-btn:focus {
        outline: 3px solid #3b82f6 !important;
        outline-offset: 2px !important;
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
    }

    /* ENHANCEMENT #7: Improved Transitions */

    .tpp-btn,
    button,
    a,
    input,
    select,
    textarea {
        transition: all 0.2s ease !important;
    }

    .tpp-btn:active,
    button:active {
        transform: scale(0.98) !important;
    }

    /* ENHANCEMENT #8: Better Visual Separation */

    .tpp-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid #e2e8f0 !important;
    }

    .tpp-step-content {
        padding: 24px 16px !important;
    }

    /* ENHANCEMENT #9: Improve Header Readability */
    /* DOC-CHANGE: 2025-10-19 - Claude - Reduced banner height to match desktop compact design */
    .tpp-header-banner {
        padding: 10px 16px !important;
    }

    .tpp-header-content {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
    }

    .tpp-logo-section {
        gap: 0px !important;
    }

    .tpp-logo-section h1 {
        font-size: 18px !important;
        font-weight: 700 !important;
        line-height: 1.1 !important;
        margin-bottom: 2px !important;
    }

    .tpp-tagline {
        font-size: 10px !important;
        line-height: 1.2 !important;
        display: none !important; /* Hide tagline on mobile to save space */
    }

    .tpp-header-info {
        font-size: 10px !important;
        gap: 6px !important;
        line-height: 1.1 !important;
    }

    /* ENHANCEMENT #10: Progress Bar Improvements */

    .tpp-progress-bar {
        padding: 24px 12px !important;
    }

    .tpp-progress-step span {
        font-size: 13px !important;
        margin-top: 8px !important;
    }

    /* ENHANCEMENT #11: Better Form Field Spacing */

    .tpp-form-group {
        margin-bottom: 20px !important;
    }

    label {
        font-weight: 600 !important;
        margin-bottom: 8px !important;
        display: block !important;
        color: #1e293b !important;
    }

    /* ENHANCEMENT #12: Improved Success State */

    .tpp-success-title {
        font-size: 28px !important;
        font-weight: 700 !important;
        margin-top: 20px !important;
    }

    .tpp-success-message {
        font-size: 16px !important;
        color: #64748b !important;
    }
}

/* Additional fixes for very small screens */
@media (max-width: 375px) {
    .tpp-btn {
        font-size: 15px !important;
        padding: 12px 16px !important;
    }

    .tpp-card {
        padding: 16px !important;
    }

    .tpp-page-title {
        font-size: 24px !important;
    }

    .tpp-header-banner {
        padding: 14px 16px !important;
    }
}

/* ENHANCEMENT #13: Navigation Landmark (All Screen Sizes) */

.tpp-navigation {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 0 !important;
}

.tpp-nav-content {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 12px 16px !important;
    max-width: 1320px !important;
    margin: 0 auto !important;
}

.tpp-nav-link {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 12px 16px !important;
    min-height: 48px !important;
    color: #64748b !important;
    text-decoration: none !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}

.tpp-nav-link svg {
    flex-shrink: 0 !important;
}

.tpp-nav-link:hover {
    background: #f1f5f9 !important;
    color: #2563eb !important;
}

.tpp-nav-link:focus {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
}

.tpp-nav-link:active {
    transform: scale(0.98) !important;
}

/* ENHANCEMENT #14: Desktop Improvements */
@media (min-width: 769px) {
    /* Better spacing on larger screens */
    .tpp-container {
        padding: 0 40px !important;
    }

    .tpp-page-title {
        font-size: 40px !important;
    }

    /* Ensure buttons have proper hover states */
    .tpp-btn:hover,
    button:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    }

    .tpp-btn-primary:hover {
        background: #1e40af !important;
        background-color: #1e40af !important;
    }

    .tpp-btn-secondary:hover {
        background: #f1f5f9 !important;
        border-color: #2563eb !important;
    }
}
