/* General Form Container */
.booking-form-container {
    position: relative;
    overflow: hidden;
    background-color: #fff;
    border-radius: 0.5rem;
}

/* Form Steps */
.form-step {
    display: none;
    animation-duration: 0.5s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-in-out;
}

.form-step.active {
    display: block;
}

/* Animations for form steps */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-100%); opacity: 0; }
}

.form-step.slide-in-right { animation-name: slideInRight; }
.form-step.slide-in-left { animation-name: slideInLeft; }
.form-step.slide-out-right { animation-name: slideOutRight; }
.form-step.slide-out-left { animation-name: slideOutLeft; }

/* Progress Bar */
.progress-container {
    margin-bottom: 2rem;
}

.progress {
    height: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    overflow: visible; /* Allow steps to overflow */
}

.progress-bar {
    background-color: var(--accent, #007bff); /* Fallback color */
    transition: width 0.4s ease;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    top: -10px; /* Adjust to position above the bar */
    margin: 0 auto;
    width: 100%;
    padding: 0;
}

.progress-step {
    color: #6c757d;
    font-size: 0.8rem;
    text-align: center;
    position: relative;
    flex: 1;
    transition: color 0.4s ease;
    padding-top: 30px; /* Adjusted space for the circle and text alignment */
}

.progress-step strong {
    font-weight: bold;
    display: block;
}

.progress-step::before {
    content: '';
    position: absolute;
    top: 5px; /* Adjusted to vertically center on the progress bar */
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #e9ecef;
    border: 3px solid #e9ecef;
    transition: background-color 0.4s ease, border-color 0.4s ease;
    z-index: 2; /* Ensure circle is above the line */
}

.progress-step.active {
    color: var(--accent, #007bff); /* Fallback color */
}

.progress-step.active::before {
    background-color: var(--accent, #007bff); /* Fallback color */
    border-color: var(--accent, #007bff); /* Fallback color */
}

.progress-step.completed::before {
    background-color: var(--accent, #007bff); /* Fallback color */
    border-color: var(--accent, #007bff); /* Fallback color */
    content: '\2713'; /* Checkmark */
    color: white;
    font-size: 12px;
    line-height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-step.completed {
    color: #6c757d; /* Keep text color subtle for completed steps */
}

/* Form elements */
.form-control:focus, .form-select:focus {
    border-color: var(--primary, #0056b3); /* Fallback color */
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-rgb, 0, 86, 179), 0.25); /* Fallback for RGB */
}

.form-control.is-invalid, .was-validated .form-control:invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* Summary section */
#summary {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 1.5rem;
}

#summary h5 {
    color: var(--primary, #0056b3); /* Fallback color */
}

#summary p {
    margin-bottom: 0.5rem;
}

#summary strong {
    color: #343a40;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .progress-step {
        font-size: 0.7rem;
    }
    .booking-form-container {
        padding: 1.5rem !important;
    }
    
    .progress-steps {
        flex-direction: column;
        gap: 0.5rem;
        top: 0;
        margin-top: 1rem;
    }
    
    .progress-step {
        padding-top: 0;
        text-align: left;
        padding-left: 2rem;
    }
    
    .progress-step::before {
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        position: absolute;
    }
    
    .form-control, .form-select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem;
        min-height: 48px; /* Touch-friendly */
    }
    
    .btn {
        min-height: 48px;
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
    }
    
    #summary {
        padding: 1rem;
        font-size: 0.9rem;
    }
}

/* Ultra small devices - Foldable phones (closed) */
@media (max-width: 360px) {
    .booking-form-container {
        padding: 1rem !important;
        margin: 0 0.5rem;
    }
    
    .progress-step {
        font-size: 0.65rem;
        padding-left: 1.5rem;
    }
    
    .progress-step::before {
        width: 16px;
        height: 16px;
        font-size: 10px;
        line-height: 10px;
    }
    
    .form-control, .form-select {
        font-size: 16px;
        padding: 0.6rem;
        min-height: 44px;
    }
    
    .btn {
        min-height: 44px;
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #summary {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    .form-check-label {
        font-size: 0.85rem;
        line-height: 1.4;
    }
}

/* Samsung Galaxy Z Fold (Closed) - 280px x 653px */
@media (min-width: 280px) and (max-width: 320px) and (orientation: portrait) {
    .booking-form-container {
        padding: 0.75rem !important;
        margin: 0 0.25rem;
        border-radius: 0.25rem;
    }
    
    .progress-container {
        margin-bottom: 1rem;
    }
    
    .progress {
        height: 6px;
    }
    
    .progress-step {
        font-size: 0.6rem;
        padding-left: 1.25rem;
    }
    
    .progress-step::before {
        width: 14px;
        height: 14px;
        font-size: 8px;
        line-height: 8px;
        border-width: 2px;
    }
    
    .form-control, .form-select {
        font-size: 16px;
        padding: 0.5rem;
        min-height: 42px;
        border-radius: 0.25rem;
    }
    
    .form-label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
    
    .btn {
        min-height: 42px;
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
        border-radius: 0.25rem;
    }
    
    .mb-3 {
        margin-bottom: 0.75rem !important;
    }
    
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    #summary {
        padding: 0.5rem;
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    .form-check-label {
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    .invalid-feedback {
        font-size: 0.7rem;
    }
}

/* Samsung Galaxy Z Flip (Closed) - 260px x 512px */
@media (min-width: 250px) and (max-width: 280px) and (min-height: 500px) and (orientation: portrait) {
    .booking-form-container {
        padding: 0.5rem !important;
        margin: 0 0.25rem;
        border-radius: 0.25rem;
    }
    
    .progress-container {
        margin-bottom: 0.75rem;
    }
    
    .progress {
        height: 4px;
    }
    
    .progress-step {
        font-size: 0.55rem;
        padding-left: 1rem;
        line-height: 1.2;
    }
    
    .progress-step::before {
        width: 12px;
        height: 12px;
        font-size: 7px;
        line-height: 6px;
        border-width: 1px;
    }
    
    .form-control, .form-select {
        font-size: 16px;
        padding: 0.4rem;
        min-height: 40px;
        border-radius: 0.2rem;
    }
    
    .form-label {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
    }
    
    .btn {
        min-height: 40px;
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
        border-radius: 0.2rem;
    }
    
    .mb-3 {
        margin-bottom: 0.5rem !important;
    }
    
    .mb-4 {
        margin-bottom: 0.75rem !important;
    }
    
    #summary {
        padding: 0.4rem;
        font-size: 0.7rem;
        line-height: 1.2;
    }
    
    .form-check-label {
        font-size: 0.7rem;
        line-height: 1.2;
    }
    
    .invalid-feedback {
        font-size: 0.65rem;
    }
    
    h4 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }
}

/* Landscape orientation for foldable devices */
@media (min-width: 500px) and (max-width: 700px) and (orientation: landscape) and (max-height: 400px) {
    .booking-form-container {
        padding: 1rem !important;
    }
    
    .progress-steps {
        flex-direction: row;
        top: -10px;
        margin-top: 0;
    }
    
    .progress-step {
        padding-top: 30px;
        text-align: center;
        padding-left: 0;
        font-size: 0.7rem;
    }
    
    .progress-step::before {
        left: 50%;
        top: 5px;
        transform: translateX(-50%);
    }
    
    .form-control, .form-select {
        padding: 0.5rem;
        min-height: 40px;
    }
    
    .btn {
        min-height: 40px;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
    
    .d-flex.justify-content-between {
        flex-direction: row;
        gap: 1rem;
    }
    
    .d-flex.justify-content-between .btn {
        width: auto;
        margin-bottom: 0;
    }
    
    #summary {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Two-column layout for form fields in landscape */
    .row.g-3 {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .row.g-3 > div {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 991px) {
    .booking-form-container {
        padding: 2rem !important;
    }
    
    .progress-step {
        font-size: 0.85rem;
    }
    
    .form-control, .form-select {
        padding: 0.75rem;
        font-size: 0.95rem;
    }
    
    .btn {
        font-size: 0.95rem;
        padding: 0.75rem 1.25rem;
    }
    
    #summary {
        padding: 1.25rem;
        font-size: 0.95rem;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .booking-form-container {
        padding: 2.5rem !important;
    }
    
    .progress-step {
        font-size: 0.9rem;
    }
    
    .form-control, .form-select {
        padding: 0.875rem;
        font-size: 1rem;
    }
    
    .btn {
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
    }
    
    #summary {
        padding: 1.5rem;
        font-size: 1rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .form-control, .form-select {
        min-height: 48px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .btn {
        min-height: 48px;
        touch-action: manipulation;
    }
    
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-top: 0.125rem;
    }
    
    .form-check-label {
        padding-left: 0.5rem;
        cursor: pointer;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .progress-bar {
        background-color: #000;
    }
    
    .progress-step.active::before,
    .progress-step.completed::before {
        background-color: #000;
        border-color: #000;
    }
    
    .form-control:focus, .form-select:focus {
        border-color: #000;
        box-shadow: 0 0 0 0.25rem rgba(0, 0, 0, 0.25);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .form-step,
    .progress-bar,
    .progress-step,
    .progress-step::before {
        transition: none;
        animation: none;
    }
    
    .form-step.slide-in-right,
    .form-step.slide-in-left,
    .form-step.slide-out-right,
    .form-step.slide-out-left {
        animation: none;
    }
}

/* Form validation improvements */
.was-validated .form-control:valid,
.was-validated .form-select:valid {
    border-color: #198754;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='m2.3 6.73.94-.94 1.44 1.44L7.4 4.5l.94.94L4.66 9.2z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .form-control:valid:focus,
.was-validated .form-select:valid:focus {
    border-color: #198754;
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* Loading state */
.booking-form-container.loading {
    pointer-events: none;
    opacity: 0.7;
}

.booking-form-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary, #007bff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Error state improvements */
.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #dc3545;
}

/* Success message styling */
.alert-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-success .alert-heading {
    color: inherit;
}

/* Error message styling */
.alert-danger {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
