/* Mobile Checkout Optimization for K12Buddy */

/* Stripe Elements Mobile Optimization */
@media screen and (max-width: 768px) {
    /* Stripe Checkout Modal */
    .stripe-checkout-iframe,
    iframe[name*="stripe"] {
        width: 100% !important;
        max-width: 100vw !important;
        min-height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 9999 !important;
    }
    
    /* Stripe Payment Form */
    .StripeElement {
        padding: 15px !important;
        font-size: 16px !important;
    }
    
    /* Ensure checkout buttons are easily tappable */
    button[onclick*="checkout"],
    button[onclick*="Checkout"] {
        min-height: 48px !important;
        font-size: 16px !important;
        padding: 12px 24px !important;
        touch-action: manipulation !important;
    }
}

/* Subscription Selection Cards Mobile */
@media screen and (max-width: 768px) {
    /* Make entire pricing card clickable */
    #pricing .bg-white,
    #pricing .bg-blue-600 {
        cursor: pointer !important;
        transition: transform 0.2s ease !important;
    }
    
    #pricing .bg-white:active,
    #pricing .bg-blue-600:active {
        transform: scale(0.98) !important;
    }
    
    /* Highlight selected plan */
    #pricing .selected-plan {
        border: 3px solid #2563eb !important;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
    }
}

/* Payment Form Mobile Optimization */
.payment-form-mobile {
    padding: 20px !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
}

/* Mobile Loading States */
@media screen and (max-width: 768px) {
    .loading-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0, 0, 0, 0.5) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 10000 !important;
    }
    
    .loading-spinner {
        width: 50px !important;
        height: 50px !important;
        border: 4px solid #f3f3f3 !important;
        border-top: 4px solid #2563eb !important;
        border-radius: 50% !important;
        animation: spin 1s linear infinite !important;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message Mobile Styling */
@media screen and (max-width: 768px) {
    .error-message,
    .alert {
        position: fixed !important;
        top: 20px !important;
        left: 20px !important;
        right: 20px !important;
        padding: 16px !important;
        background: #fee !important;
        border: 1px solid #fcc !important;
        border-radius: 8px !important;
        font-size: 14px !important;
        z-index: 10001 !important;
    }
    
    .success-message {
        background: #efe !important;
        border-color: #cfc !important;
    }
}

/* Mobile Keyboard Optimization */
@media screen and (max-width: 768px) {
    /* Prevent zoom on input focus in iOS */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100% !important;
    }
    
    /* Adjust layout when keyboard is open */
    .keyboard-open #auth-modal {
        position: fixed !important;
        top: 0 !important;
        transform: none !important;
    }
}

/* Touch Feedback */
@media (hover: none) and (pointer: coarse) {
    button:active,
    a:active {
        opacity: 0.8 !important;
    }
}

/* Safe Area Insets for Modern Phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #auth-modal .max-w-md {
        padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
    }
    
    nav {
        padding-top: env(safe-area-inset-top) !important;
    }
}

/* Improve Tap Target Size */
@media screen and (max-width: 768px) {
    /* Make all interactive elements at least 44x44 pixels */
    button,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 44px !important;
    }
}

/* Checkout Progress Indicator */
@media screen and (max-width: 768px) {
    .checkout-progress {
        display: flex !important;
        justify-content: space-between !important;
        padding: 16px !important;
        margin-bottom: 20px !important;
        background: #f9f9f9 !important;
        border-radius: 8px !important;
    }
    
    .checkout-step {
        flex: 1 !important;
        text-align: center !important;
        font-size: 12px !important;
        color: #999 !important;
    }
    
    .checkout-step.active {
        color: #2563eb !important;
        font-weight: bold !important;
    }
    
    .checkout-step.completed {
        color: #10b981 !important;
    }
}

/* Mobile Payment Method Icons */
@media screen and (max-width: 768px) {
    .payment-methods {
        display: flex !important;
        gap: 12px !important;
        justify-content: center !important;
        margin: 16px 0 !important;
    }
    
    .payment-method-icon {
        width: 40px !important;
        height: 25px !important;
        object-fit: contain !important;
    }
}

/* Optimize Scrolling */
@media screen and (max-width: 768px) {
    body {
        -webkit-overflow-scrolling: touch !important;
    }
    
    .modal-content {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: calc(100vh - 40px) !important;
    }
}

/* Fix for iOS Safari Rubber Band Scrolling - REMOVED as it breaks interaction */
/* This was causing the site to appear static and unscrollable */

/* Autofill Styling */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px white inset !important;
    -webkit-text-fill-color: #333 !important;
}