/**
 * Blue Motors Southampton - Mobile Critical Fixes
 * Sprint 1: Critical mobile enhancements
 * 
 * IMPORTANT: This file is ADDITIVE ONLY - no breaking changes
 * All existing class names and functionality preserved
 * 
 * @package BlueMotosSouthampton
 * @since 1.4.1
 */

/* =================================================================
   FIX #1: PROGRESS STEPS - COMPACT MOBILE LAYOUT
   ================================================================= */

/**
 * Problem: Progress steps take 300px vertical space on mobile portrait
 * Solution: Show compact "Step X of 5" indicator on small screens
 * Preserves: All existing .bms-progress-steps classes and structure
 */

@media (max-width: 767px) and (orientation: portrait) {
    /* Override column layout only on portrait mobile */
    .bms-progress-steps {
        flex-direction: row !important; /* Override existing column direction */
        justify-content: center;
        align-items: center;
        padding: 12px 16px !important;
        gap: 8px !important;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Hide scrollbar on Firefox */
    }
    
    /* Hide scrollbar on Webkit browsers */
    .bms-progress-steps::-webkit-scrollbar {
        display: none;
    }
    
    /* Make individual steps more compact */
    .bms-progress-steps .step {
        min-width: 60px;
        flex-shrink: 0;
        scroll-snap-align: center;
        padding: 8px 12px !important;
        flex-direction: column !important;
        text-align: center;
        align-items: center;
        justify-content: center;
    }
    
    /* Adjust step number sizing */
    .bms-progress-steps .step-number {
        width: 32px !important;
        height: 32px !important;
        margin-right: 0 !important;
        margin-bottom: 4px;
        font-size: 14px !important;
    }
    
    /* Adjust step label sizing */
    .bms-progress-steps .step-label {
        font-size: 11px !important;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    /* Active step - slightly larger for emphasis */
    .bms-progress-steps .step.active {
        transform: scale(1.05);
        z-index: 10;
    }
    
    /* Completed steps - show checkmark clearly */
    .bms-progress-steps .step.completed .step-number::before {
        content: '✓' !important;
        font-size: 14px !important;
    }
    
    /* Hide step label text for non-active steps on very small screens */
    @media (max-width: 380px) {
        .bms-progress-steps .step:not(.active) .step-label {
            display: none;
        }
        
        .bms-progress-steps .step {
            min-width: 48px;
        }
    }
}

/* Keep landscape mode as is - it already works well */
@media (max-width: 768px) and (orientation: landscape) {
    /* Existing landscape styles are good - no changes needed */
}


/* =================================================================
   FIX #2: SERVICE COMPARISON TABLE - MOBILE RESPONSIVE
   ================================================================= */

/**
 * Problem: .comparison-table has no mobile CSS, likely overflows
 * Solution: Make table scrollable horizontally with clear indicators
 * Preserves: All existing .comparison-table classes
 */

@media (max-width: 768px) {
    /* Service comparison section - add mobile styles */
    .bms-service-comparison {
        margin: 24px 0;
        padding: 16px;
        background: #f8fafc;
        border-radius: 12px;
    }
    
    .comparison-header {
        text-align: center;
        margin-bottom: 16px;
    }
    
    .comparison-header h2 {
        font-size: 18px;
        margin: 0 0 8px 0;
        color: #1e3a8a;
    }
    
    .comparison-header p {
        font-size: 14px;
        color: #6b7280;
        margin: 0;
    }
    
    /* Comparison content container - enable horizontal scroll */
    .comparison-content {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        margin: 16px -16px; /* Extend to container edges */
        padding: 0 16px;
    }
    
    /* Comparison table - set minimum width to prevent squishing */
    .comparison-table {
        min-width: 500px; /* Ensures table doesn't get too narrow */
        width: 100%;
        border-collapse: collapse;
    }
    
    /* Table rows */
    .comparison-row {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr; /* Check item, Interim, Full */
        gap: 8px;
        padding: 12px 8px;
        border-bottom: 1px solid #e5e7eb;
        align-items: center;
    }
    
    .comparison-row.header-row {
        background: #1e3a8a;
        color: white;
        font-weight: 700;
        font-size: 13px;
        border-radius: 8px 8px 0 0;
        margin-bottom: 4px;
    }
    
    /* Table cells */
    .check-item {
        font-size: 14px;
        color: #374151;
        padding: 0 8px;
        text-align: left;
    }
    
    .comparison-row.header-row .check-item {
        color: white;
    }
    
    .interim-col,
    .full-col {
        font-size: 16px;
        font-weight: 600;
        text-align: center;
        color: #1e3a8a;
    }
    
    .comparison-row.header-row .interim-col,
    .comparison-row.header-row .full-col {
        color: white;
        font-size: 12px;
    }
    
    /* Scroll indicator shadow */
    .comparison-content::after {
        content: '';
        position: absolute;
        top: 0;
        right: 16px;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to left, rgba(248, 250, 252, 1), transparent);
        pointer-events: none;
    }
    
    /* More info button */
    .btn-more-info {
        width: 100%;
        margin-top: 16px;
        padding: 12px 24px;
        background: white;
        color: #1e3a8a;
        border: 2px solid #1e3a8a;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s ease;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .btn-more-info:hover,
    .btn-more-info:focus {
        background: #1e3a8a;
        color: white;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(30, 58, 138, 0.2);
    }
}


/* =================================================================
   FIX #3: MOT PRICING TABLE - MOBILE RESPONSIVE
   ================================================================= */

/**
 * Problem: MOT pricing table with multiple columns doesn't fit mobile
 * Solution: Stack columns vertically on small screens with clear pricing
 * Preserves: All existing .mot-pricing-table classes
 */

@media (max-width: 768px) {
    /* MOT section wrapper */
    .bms-mot-section {
        margin: 24px 0;
        padding: 20px 16px;
        background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
        border-radius: 12px;
        border: 2px solid #bae6fd;
    }
    
    .mot-header {
        text-align: center;
        margin-bottom: 20px;
    }
    
    .mot-header h2 {
        font-size: 20px;
        margin: 0 0 8px 0;
        color: #1e3a8a;
    }
    
    .mot-header h3 {
        font-size: 18px;
        margin: 0 0 8px 0;
        color: #0c4a6e;
    }
    
    .mot-subtitle {
        font-size: 14px;
        color: #475569;
        margin: 0;
    }
    
    /* MOT pricing table - stacked card layout */
    .mot-pricing-table {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    
    /* Hide desktop table header on mobile */
    .pricing-header {
        display: none;
    }
    
    /* Pricing rows - convert to cards */
    .pricing-row {
        background: white;
        border-radius: 12px;
        padding: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    /* Highlight Interim vs Full */
    .pricing-row.interim-row {
        border-left: 4px solid #3b82f6;
    }
    
    .pricing-row.full-row {
        border-left: 4px solid #10b981;
    }
    
    /* Column styling for mobile cards */
    .pricing-row .col-service,
    .pricing-row .col-mot,
    .pricing-row .col-total {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
    }
    
    .col-service {
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 12px;
    }
    
    /* Service name and price */
    .service-name {
        font-size: 16px;
        font-weight: 700;
        color: #1e3a8a;
    }
    
    .service-price {
        font-size: 18px;
        font-weight: 800;
        color: #1e3a8a;
    }
    
    /* MOT price */
    .mot-price {
        font-size: 16px;
        font-weight: 600;
        color: #0891b2;
    }
    
    /* Total price display */
    .col-total {
        background: #f0f9ff;
        padding: 12px !important;
        border-radius: 8px;
        margin: 8px 0;
    }
    
    .total-price {
        font-size: 24px;
        font-weight: 900;
        color: #0c4a6e;
    }
    
    .savings {
        font-size: 12px;
        font-weight: 700;
        color: #16a34a;
        background: #f0fdf4;
        padding: 4px 8px;
        border-radius: 4px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    /* Action button */
    .col-action {
        padding: 0 !important;
    }
    
    .pricing-row .btn-select-combo {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        border-radius: 8px;
        background: linear-gradient(135deg, #1e3a8a, #3b82f6);
        color: white;
        border: none;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 0 4px 8px rgba(30, 58, 138, 0.2);
    }
    
    .pricing-row .btn-select-combo:hover,
    .pricing-row .btn-select-combo:focus {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(30, 58, 138, 0.3);
    }
    
    .pricing-row .btn-select-combo:active {
        transform: translateY(0);
    }
    
    /* Add labels for clarity on mobile */
    .col-service::before {
        content: 'Service: ';
        font-size: 12px;
        color: #6b7280;
        font-weight: 600;
        text-transform: uppercase;
    }
    
    .col-mot::before {
        content: 'MOT: ';
        font-size: 12px;
        color: #6b7280;
        font-weight: 600;
        text-transform: uppercase;
    }
    
    .col-total::before {
        content: 'Total: ';
        font-size: 14px;
        color: #6b7280;
        font-weight: 700;
        text-transform: uppercase;
        margin-right: auto;
    }
}

/* Extra small screens - even more compact */
@media (max-width: 480px) {
    .mot-header h2 {
        font-size: 18px;
    }
    
    .mot-header h3 {
        font-size: 16px;
    }
    
    .service-name {
        font-size: 14px;
    }
    
    .service-price {
        font-size: 16px;
    }
    
    .total-price {
        font-size: 20px;
    }
}


/* =================================================================
   TABLET OPTIMIZATION
   ================================================================= */

/**
 * Tablet screens get a hybrid layout - between mobile and desktop
 */

@media (min-width: 769px) and (max-width: 1024px) {
    /* Progress steps - horizontal but with full labels */
    .bms-progress-steps {
        flex-direction: row;
        justify-content: space-between;
        padding: 12px 24px;
    }
    
    .bms-progress-steps .step {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .bms-progress-steps .step-number {
        margin-right: 0;
        margin-bottom: 4px;
    }
    
    /* MOT pricing table - show as grid */
    .mot-pricing-table {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .pricing-row {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr 1.5fr;
        gap: 12px;
        align-items: center;
        padding: 16px;
    }
    
    .pricing-header {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr 1.5fr;
        gap: 12px;
        padding: 12px 16px;
        background: #1e3a8a;
        color: white;
        font-weight: 700;
        border-radius: 8px;
        margin-bottom: 8px;
    }
}


/* =================================================================
   ACCESSIBILITY ENHANCEMENTS
   ================================================================= */

/**
 * Ensure all new elements maintain accessibility standards
 */

@media (max-width: 768px) {
    /* Focus visible states for new buttons */
    .btn-more-info:focus-visible,
    .btn-select-combo:focus-visible {
        outline: 3px solid #3b82f6;
        outline-offset: 3px;
    }
    
    /* High contrast mode adjustments */
    @media (prefers-contrast: high) {
        .comparison-table,
        .mot-pricing-table {
            border: 2px solid currentColor;
        }
        
        .pricing-row {
            border: 2px solid currentColor;
        }
    }
    
    /* Reduced motion */
    @media (prefers-reduced-motion: reduce) {
        .bms-progress-steps .step.active {
            transform: none;
        }
        
        .btn-select-combo:hover,
        .btn-more-info:hover {
            transform: none;
        }
    }
}


/* =================================================================
   PRINT STYLES
   ================================================================= */

/**
 * Ensure booking form prints nicely if user wants to save/print
 */

@media print {
    .bms-progress-steps {
        display: block !important;
        break-inside: avoid;
    }
    
    .comparison-table,
    .mot-pricing-table {
        page-break-inside: avoid;
    }
    
    .btn-select-combo,
    .btn-more-info {
        display: none !important;
    }
}


/* =================================================================
   BROWSER-SPECIFIC FIXES
   ================================================================= */

/**
 * Handle browser-specific quirks
 */

/* Safari-specific fixes */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        /* Fix iOS scroll momentum */
        .bms-progress-steps,
        .comparison-content {
            -webkit-overflow-scrolling: touch;
        }
        
        /* Fix iOS button appearance */
        .btn-select-combo,
        .btn-more-info {
            -webkit-appearance: none;
            appearance: none;
        }
    }
}

/* Firefox-specific fixes */
@-moz-document url-prefix() {
    @media (max-width: 768px) {
        /* Fix Firefox flexbox issues */
        .pricing-row {
            min-height: auto;
        }
    }
}


/* =================================================================
   END OF MOBILE CRITICAL FIXES
   ================================================================= */

/**
 * Summary of fixes:
 * 1. ✅ Progress steps - Compact horizontal layout on mobile portrait
 * 2. ✅ Service comparison table - Scrollable with clear structure
 * 3. ✅ MOT pricing table - Stacked card layout for mobile
 * 
 * All fixes are:
 * - Additive only (no breaking changes)
 * - Use existing class names
 * - Properly scoped with media queries
 * - Maintain accessibility
 * - Include fallbacks for older browsers
 */
