/**
 * Modal Styles
 * Single source of truth for all modal styling (container + forms)
 * Applies to: contact-modal, general-contact-modal, booking-modal
 * 
 * @package EliteAir
 * @since 1.0.0
 */

/* ============================================
   MODAL CONTAINER STYLES
   ============================================ */

/* Modal Container - Base */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

/* Modal Active State */
.modal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Modal Backdrop */
.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

/* Modal Content Container */
.modal-content {
    position: relative;
    background: rgba(36, 36, 36, 0.98);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(103, 217, 252, 0.2);
    border-radius: 0.5rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transform: scale(0.95) translateY(-20px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    z-index: 1;
}

.modal.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Modal Header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

/* Modal Title */
.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #67d9fc;
    margin: 0;
    flex: 1;
}

/* Modal Close Button */
.modal-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 0.25rem;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.modal-close svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.modal-close:hover {
    color: #67d9fc;
    background: rgba(103, 217, 252, 0.1);
    transform: rotate(90deg);
}

.modal-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* Modal Body */
.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Responsive Modal Styles */
@media (max-width: 640px) {
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 0.5rem 0.5rem 0 0;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
}

/* Reduce backdrop blur on mobile for performance */
@media (max-width: 768px), (prefers-reduced-motion: reduce) {
    .modal-backdrop {
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    
    .modal-content {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

/* ============================================
   MODAL FORM STYLES
   ============================================ */

/* Modal Form Group Styles - Unified for all modals */
.modal .form-group {
    position: relative;
    margin-top: 6px;
    width: 100%;
    box-sizing: border-box;
}

.modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Modal Toggle Row */
.modal-toggle-row {
    margin-bottom: 1rem;
}

/* Request Flight Route Display */
.request-flight-route {
    margin-bottom: 0.75rem;
    font-size: 1.1375rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    text-align: center;
    min-height: 1.5rem;
}

.modal .toggle-container {
    display: flex;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
    padding: 5px 8px;
    position: relative;
}

.modal .toggle-btn {
    flex: 1;
    padding: 11px 20px;
    border: none;
    background: transparent;
    border-radius: 0.2rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: rgba(255, 255, 255, 0.6);
    position: relative;
    z-index: 1;
    letter-spacing: 0.3px;
}

.modal .toggle-btn.active {
    background: #67d9fc;
    color: #242424;
    transform: scale(1.02);
}

.modal .toggle-btn:hover:not(.active) {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
}

/* On WooCommerce pages, modals should display single item per row */
body.woocommerce .modal .form-row,
body.woocommerce-cart .modal .form-row,
body.woocommerce-checkout .modal .form-row,
body.woocommerce-account .modal .form-row,
body.woocommerce-order .modal .form-row,
.woocommerce .modal .form-row {
    grid-template-columns: 1fr;
}

/* Modal Form Input Styles - matches demo pattern */
.modal .form-group input,
.modal .form-group textarea,
.modal .form-group .form-input,
.modal .form-group .input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(255, 255, 255, 0.15);
    border-bottom-color: rgba(63, 63, 63, 0.05);
    color: #fffdfd;
    border-radius: 0.25rem;
    font-size: 0.9rem;
    box-sizing: border-box;
    line-height: 1.4;
    min-height: 38px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color-scheme: dark;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-family: inherit;
}

.modal .form-group input:focus,
.modal .form-group textarea:focus,
.modal .form-group .form-input:focus,
.modal .form-group .input:focus {
    outline: none;
    border-color: #67d9fc;
    background: rgba(103, 217, 252, 0.1);
}

/* Modal Form Labels - Floating label pattern */
.modal .form-group label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    pointer-events: none;
    background: transparent;
    padding: 0 4px;
    z-index: 1;
    line-height: 1;
}

/* Ensure email and text input labels align the same way */
.modal .form-group input[type="text"] ~ label,
.modal .form-group input[type="email"] ~ label {
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
}

/* Label animation on focus or when input has value (exclude phone inputs) */
.modal .form-group:not(.phone-input-wrapper) input:focus ~ label,
.modal .form-group:not(.phone-input-wrapper) input.has-value ~ label,
.modal .form-group:not(.phone-input-wrapper) select:focus ~ label,
.modal .form-group:not(.phone-input-wrapper) select.has-value ~ label,
.modal .form-group:not(.phone-input-wrapper) textarea:focus ~ label,
.modal .form-group:not(.phone-input-wrapper) textarea.has-value ~ label {
    top: 0;
    font-size: 0.75rem;
    color: #67d9fc;
    background: #242424;
}

/* Textarea labels need special handling - only if label exists */
.modal .form-group textarea ~ label {
    top: 12px;
    transform: none;
}

.modal .form-group textarea:focus ~ label,
.modal .form-group textarea.has-value ~ label {
    top: 0;
    transform: translateY(-50%);
}

/* Hide labels for textareas that only have hint_text (no label_text) */
.modal #general-contact-message-group label,
.modal [id*="message-group"] label {
    display: none !important;
}



/* Textarea specific overrides */
.modal .form-group textarea {
    resize: vertical;
    min-height: 100px;
    padding-top: 12px;
    padding-bottom: 12px;
}

/* Select specific styles */
.modal .form-group select {
    background-image: url("data:image/svg+xml;charset=UTF-8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"%2367d9fc\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6,9 12,15 18,9\"></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.modal .form-group select option {
    background: #242424;
    color: white;
}

/* Date and Time inputs */
.modal .form-group input[type="date"],
.modal .form-group input[type="time"] {
    color-scheme: dark;
}

.modal .form-group input[type="date"]::-webkit-calendar-picker-indicator,
.modal .form-group input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Flatpickr altInput styling for modals - ensure alternate input is styled correctly */
.modal .form-group input.flatpickr-input {
    display: none; /* Hide the original input when altInput is enabled */
}

.modal .form-group input[type="text"].flatpickr-input {
    display: none; /* Hide the original input when altInput is enabled */
}

/* Readonly input override */
.modal .form-group input[readonly] {
    background: rgba(255, 255, 255, 0.05);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Field Hint (for optional fields) */
.modal .field-hint {
    display: block;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 400;
}

/* GDPR Consent Container */
.modal .gdpr-consent-container {
    margin: 1.5rem 0;
}

.modal .consent-checkbox-group {
    margin-bottom: 0;
}

.modal .consent-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

.modal .consent-checkbox {
    margin: 0;
    width: 18px;
    height: 18px;
    min-width: 18px;
    cursor: pointer;
    accent-color: #67d9fc;
}

.modal .consent-text {
    flex: 1;
    font-size: 0.75rem; /* 12px */
    line-height: 1.4;
}

.modal .privacy-link {
    color: #67d9fc;
    text-decoration: underline;
    transition: color 0.2s;
}

.modal .privacy-link:hover {
    color: #4fc5e8;
}

/* Button Group */
.modal .btn-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

.modal .btn-group .btn {
    flex: 0 0 auto;
}

@media (max-width: 640px) {
    .modal .btn-group {
        flex-direction: column;
    }
    
    .modal .btn-group .btn {
        width: 100%;
    }
}

/* Form Validation Error States */
.modal .form-group.error:not(.phone-input-wrapper) input,
.modal .form-group.error:not(.phone-input-wrapper) .form-input,
.modal .form-group.error select,
.modal .form-group.error textarea {
    border-color: #ff6b6b !important;
    background: rgba(255, 107, 107, 0.1) !important;
    animation: shake 0.5s ease-in-out;
}

.modal .form-group.error label {
    color: #ff6b6b !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}


