/**
 * BluStreet Checkout - Responsive Styles
 * Mobile-first responsive design for checkout system
 * Breakpoints: 320px (mobile), 768px (tablet), 1024px (desktop), 1280px (wide)
 */

/* ==========================================================================
   TABLET & BELOW (< 1024px)
   ========================================================================== */

@media (max-width: 1024px) {
    #checkout-container {
        padding: 0 var(--space-2);
        margin: var(--space-3) auto;
    }
    
    /* Stack layout */
    .checkout-content {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    .sidebar-column {
        position: static;
        order: -1; /* Price summary first on mobile */
    }
    
    /* Progress bar - Reduce spacing */
    .checkout-progress {
        padding: var(--space-3) var(--space-2);
    }
    
    .progress-line {
        width: 60px;
        margin: 0 var(--space-1);
    }
    
    .step-label {
        font-size: var(--text-xs);
    }
    
    .step-number {
        width: 40px;
        height: 40px;
        font-size: var(--text-sm);
    }
    
    /* Cards */
    .checkout-card {
        padding: var(--space-3);
    }
    
    .checkout-card h3 {
        font-size: var(--text-lg);
    }
    
    /* Vehicle summary */
    .vehicle-summary {
        flex-direction: column;
    }
    
    .vehicle-summary img {
        width: 100%;
        max-width: 400px;
        height: auto;
        aspect-ratio: 16 / 9;
    }
    
    /* Info grids */
    .info-grid {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }
    
    /* Form grids */
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-field.full-width {
        grid-column: span 1;
    }
    
    /* Saved cards grid */
    .saved-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   MOBILE (< 768px)
   ========================================================================== */

@media (max-width: 768px) {
    :root {
        /* Adjust spacing for mobile */
        --space-4: 1.5rem;
        --space-5: 2rem;
        --space-6: 2.5rem;
    }
    
    #checkout-container {
        margin: var(--space-2) auto;
    }
    
    /* Progress bar - Vertical on small mobile */
    .checkout-progress {
        flex-direction: row;
        justify-content: space-between;
        padding: var(--space-2);
        margin-bottom: var(--space-3);
    }
    
    .progress-step {
        flex: 1;
        gap: var(--space-1);
    }
    
    .step-number {
        width: 36px;
        height: 36px;
        font-size: var(--text-xs);
    }
    
    .step-label {
        font-size: 10px;
        text-align: center;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .progress-line {
        width: 100%;
        max-width: 40px;
        margin: 0 4px;
    }
    
    /* Typography */
    .main-column > h2 {
        font-size: var(--text-2xl);
    }
    
    .notice-card h2 {
        font-size: var(--text-2xl);
    }
    
    .vehicle-details h4 {
        font-size: var(--text-xl);
    }
    
    /* Rental dates - Stack */
    .rental-dates {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .date-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Buttons - Full width, larger tap targets */
    .btn-primary,
    .btn-secondary {
        padding: var(--space-3) var(--space-3);
        font-size: var(--text-lg);
        min-height: 48px; /* Better tap target */
    }
    
    /* Terms scroll - Smaller on mobile */
    .terms-scroll {
        height: 180px;
        font-size: var(--text-xs);
    }
    
    .checkbox-label {
        font-size: var(--text-sm);
        padding: var(--space-2);
    }
    
    .checkbox-label input[type="checkbox"] {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }
    
    /* Signature pad */
    .signature-pad-canvas,
    #signature-pad {
        min-height: 150px;
    }
    
    /* Price summary */
    .price-summary-card {
        padding: var(--space-2);
    }
    
    .price-row {
        font-size: var(--text-sm);
    }
    
    .price-row.total {
        font-size: var(--text-lg);
    }
    
    /* Notice cards */
    .notice-card {
        padding: var(--space-4);
    }
    
    .requirements-list {
        font-size: var(--text-xs);
    }
}

/* ==========================================================================
   SMALL MOBILE (< 480px)
   ========================================================================== */

@media (max-width: 480px) {
    .checkout-progress {
        padding: var(--space-1);
    }
    
    .step-number {
        width: 32px;
        height: 32px;
    }
    
    .step-label {
        font-size: 9px;
        max-width: 60px;
    }
    
    .progress-line {
        max-width: 20px;
        margin: 0 2px;
    }
    
    .checkout-card {
        padding: var(--space-2);
    }
    
    .vehicle-summary img {
        height: auto;
    }
    
    /* Saved cards - Full width */
    .saved-cards-grid {
        gap: var(--space-1);
    }
    
    .card-option {
        padding: var(--space-1);
    }
    
    .form-field input,
    .form-field select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ==========================================================================
   LARGE DESKTOP (> 1280px)
   ========================================================================== */

@media (min-width: 1280px) {
    #checkout-container {
        max-width: 1100px;
    }
    
    .checkout-content {
        grid-template-columns: 1fr 440px;
        gap: var(--space-6);
    }
    
    .checkout-card {
        padding: var(--space-5);
    }
    
    .progress-line {
        width: 160px;
    }
}

/* ==========================================================================
   TOUCH DEVICE IMPROVEMENTS
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    .card-option,
    .btn-primary,
    .btn-secondary,
    .link-button,
    .checkbox-label {
        min-height: 44px; /* Apple recommended tap target */
    }
    
    /* Remove hover states on touch */
    .checkout-card:hover {
        box-shadow: var(--shadow-sm);
    }
    
    .card-option:hover {
        transform: none;
    }
    
    /* Signature pad optimized for touch */
    .signature-pad-canvas,
    #signature-pad {
        border-width: 2px;
        border-style: solid;
        border-color: var(--brand-primary);
        cursor: default;
    }
}

/* ==========================================================================
   LANDSCAPE ORIENTATION
   ========================================================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .terms-scroll {
        height: 140px;
    }
    
    .signature-pad-canvas,
    #signature-pad {
        min-height: 120px;
    }
    
    .notice-card {
        max-width: 600px;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT (Future Enhancement)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Uncomment when ready to implement dark mode */
    /*
    :root {
        --gray-50: #1f2937;
        --gray-100: #374151;
        --gray-200: #4b5563;
        --gray-300: #6b7280;
        --gray-900: #f9fafb;
        --brand-primary-lighter: rgba(0, 102, 204, 0.1);
    }
    
    .checkout-card,
    .notice-card,
    .price-summary-card {
        background: var(--gray-800);
    }
    */
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .checkout-step,
    .notice-card,
    #new-card-form {
        animation: none;
    }
}

/* ==========================================================================
   HIGH CONTRAST MODE
   ========================================================================== */

@media (prefers-contrast: high) {
    .checkout-card,
    .notice-card,
    .price-summary-card {
        border-width: 2px;
    }
    
    .btn-primary {
        border: 2px solid currentColor;
    }
    
    .form-field input:focus,
    .form-field select:focus {
        outline: 2px solid var(--brand-primary);
        outline-offset: 2px;
    }
}
