/* Guest Registration Modal - Mobile Responsive Styles */

/* CRITICAL: Ensure modal is hidden by default on page load */
/* BUT: Bootstrap .show class must override these rules */
#guestRegistrationModal:not(.show) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

/* CRITICAL: Bootstrap .show class MUST override hidden state */
/* This ensures modal can be opened programmatically via Bootstrap */
#guestRegistrationModal.show {
    display: block !important; /* Bootstrap requirement */
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1050 !important; /* From terms-privacy-modals.css */
    pointer-events: auto !important;
}

/* CRITICAL: When modal-open class is on body, allow modal to show */
/* This ensures Bootstrap can properly show the modal */
body.modal-open #guestRegistrationModal.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1050 !important;
    pointer-events: auto !important;
}

/* Force hide on page load ONLY if modal-open is not on body */
/* This prevents auto-show on page load but allows Bootstrap to show it */
body:not(.modal-open) #guestRegistrationModal:not(.show) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

/* Ensure modal body is scrollable on mobile */
#guestRegistrationModal .modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    padding: 1rem;
}

/* Better scrolling on small screens */
@media (max-width: 768px) {
    #guestRegistrationModal .modal-dialog {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }
    
    #guestRegistrationModal .modal-content {
        max-height: calc(100vh - 1rem);
        display: flex;
        flex-direction: column;
    }
    
    #guestRegistrationModal .modal-header {
        flex-shrink: 0;
        padding: 0.75rem 1rem;
    }
    
    #guestRegistrationModal .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: calc(100vh - 150px);
        padding: 1rem 0.75rem;
        /* Ensure smooth scrolling */
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    #guestRegistrationModal .modal-footer {
        flex-shrink: 0;
        padding: 0.75rem 1rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        background: var(--surface-color, #fff);
        position: sticky;
        bottom: 0;
        z-index: 10;
    }
    
    /* Make form fields more touch-friendly on mobile */
    #guestRegistrationModal .form-control,
    #guestRegistrationModal .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
        min-height: 44px; /* Minimum touch target size */
    }
    
    #guestRegistrationModal .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    /* Better spacing for form sections */
    #guestRegistrationModal .mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    /* Ensure buttons are easily tappable */
    #guestRegistrationModal .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Improve tab navigation visibility */
    #guestRegistrationModal input:focus,
    #guestRegistrationModal select:focus,
    #guestRegistrationModal textarea:focus {
        outline: 3px solid rgba(13, 110, 253, 0.5);
        outline-offset: 2px;
        box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    }
    
    /* Scroll indicator for long forms */
    #guestRegistrationModal .modal-body::after {
        content: '';
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        height: 20px;
        background: linear-gradient(to top, var(--surface-color, #fff), transparent);
        pointer-events: none;
        z-index: 1;
    }
}

/* Very small screens */
@media (max-width: 576px) {
    #guestRegistrationModal .modal-dialog {
        margin: 0.25rem;
        max-height: calc(100vh - 0.5rem);
    }
    
    #guestRegistrationModal .modal-body {
        padding: 0.75rem 0.5rem;
        max-height: calc(100vh - 120px);
    }
    
    /* Stack form fields vertically on very small screens */
    #guestRegistrationModal .row > [class*="col-"] {
        margin-bottom: 0.75rem;
    }
    
    /* Smaller text on very small screens */
    #guestRegistrationModal .form-text {
        font-size: 0.75rem;
    }
}

/* Ensure proper tab order and focus management */
#guestRegistrationModal [tabindex] {
    outline-offset: 2px;
}

#guestRegistrationModal [tabindex]:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.5);
    outline-offset: 2px;
}

/* Smooth scroll to focused element on mobile */
@media (max-width: 768px) {
    #guestRegistrationModal input:focus,
    #guestRegistrationModal select:focus {
        scroll-margin-top: 80px; /* Account for sticky header */
    }
}

/* Loading state - ensure it doesn't block scrolling */
#guestRegistrationModal .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Error messages should be visible */
#guestRegistrationModal .alert {
    margin-bottom: 1rem;
    word-wrap: break-word;
}

/* Progress indicator */
#guestRegistrationModal .progress {
    height: 4px;
    margin-bottom: 1rem;
}

