:root {
    --brand-blue: #0052cc;
    --brand-blue-hover: #0041a3;
    --text-primary: #172b4d;
    --text-secondary: #6b778c;
    --bg-page: #f7f8fa;
    --bg-surface: #ffffff;
    --border-color: #dfe1e6;
    --shadow: 0px 4px 8px rgba(23, 43, 77, 0.07), 0px 0px 1px rgba(23, 43, 77, 0.2);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 8px;
    --input-height: 48px;
}

/* --- Base & Global Styles --- */
html {
    font-size: 16px;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-family);
    margin: 0;
    line-height: 1.5;
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.primary-heading-group {
    text-align: center;
    margin: 2.5rem 0;
    padding: 0 1rem;
}
.primary-heading-group h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}
.primary-heading-group p {
    margin-bottom: 1.5rem;
}


/* --- Form Container & Sections --- */
.booking-form-wrapper {
    background-color: var(--bg-surface);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

#travel-segments-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-division {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.form-division-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
}

.form-division-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}
.form-division-controls .form-division-header {
    width: 100%;
    margin-bottom: 0.5rem;
}

/* --- Journey Style Selector --- */
.journey-style-selector {
    display: inline-flex;
    background-color: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 4px;
    margin-bottom: 1.5rem;
    gap: 4px;
}
.journey-style-selector input[type="radio"] { display: none; }
.journey-style-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}
.journey-style-selector input[type="radio"]:checked + label {
    background-color: var(--bg-surface);
    color: var(--brand-blue);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(23, 43, 77, 0.1);
}
.journey-style-selector input[type="radio"]:not(:checked) + label:hover { color: var(--text-primary); }

.journey-style-selector svg {
    display: none; /* Hide icons on desktop */
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

/* --- Form Inputs & Groups (REFINED) --- */
.input-field-group { display: flex; flex-direction: column; }

.input-field-group label { font-weight: 500; font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.icon-adorned-input { position: relative; display: flex; align-items: center; }
.icon-adorned-input svg { position: absolute; left: 14px; color: var(--text-secondary); pointer-events: none; }

/* This rule now ONLY targets inputs and selects within the fare grid */
.booking-form-wrapper input[type="text"],
.booking-form-wrapper input[type="number"],
.booking-form-wrapper select {
    width: 100%;
    box-sizing: border-box;
    height: var(--input-height);
    padding: 0 0 0 3rem; /* Space for icon */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-surface);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.icon-adorned-input input { padding-left: 44px; }
input:focus, select:focus {
    outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.2);
}

/* --- Travel Segment Layout --- */
.travel-segment {
    display: grid;
    grid-template-columns: 1fr auto 1fr 0.8fr 0.8fr auto;
    gap: 1rem;
    align-items: flex-end;
}
.swap-locations-button {
    display: flex; align-items: center; justify-content: center; 
    height: var(--input-height); 
    width: var(--input-height);
    border-radius: 50%; border: 1px solid var(--border-color); background-color: var(--bg-surface);
    cursor: pointer; transition: all 0.2s; color: var(--text-secondary);
}
.swap-locations-button:hover { color: var(--brand-blue); border-color: var(--brand-blue); transform: rotate(180deg); }

/* --- Segment Action Buttons (Add/Remove) --- */
.segment-actions {
    display: flex;
    gap: 0.5rem;
    height: var(--input-height);
    align-items: center;
}
.remove-segment-button {
    background: transparent; border: none; color: var(--text-secondary); 
    height: var(--input-height); 
    width: var(--input-height);
    font-size: 1.5rem; line-height: 1; cursor: pointer; transition: all 0.2s;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.remove-segment-button:hover { background-color: #fee2e2; color: #ef4444; }

.add-segment-button {
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    height: 44px; /* Slightly smaller than input height for aesthetics */
    width: 44px;
    border-radius: 50%;
    border: 1px dashed var(--border-color);
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}
.add-segment-button:hover {
    color: var(--brand-blue);
    border-color: var(--brand-blue);
    background-color: #eaf2ff;
}
.add-segment-button svg {
    width: 16px;
    height: 16px;
}


/* --- Passenger Options & Actions Layout --- */
.passenger-options-layout {
    display: flex; 
    gap: 1rem; 
    align-items: flex-end;
    flex-grow: 1;
}
.passenger-options-layout .passenger-count-widget { flex-basis: 140px; flex-grow: 1; }
.passenger-options-layout .cabin-select-group { flex-grow: 1; min-width: 180px; }

.numeric-incrementor {
    display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--border-color);
    padding: 6px; border-radius: var(--border-radius); 
    height: var(--input-height); 
    box-sizing: border-box;
}
.incrementor-button {
    width: 34px; height: 34px; /* Adjusted for larger input height */
    border: none; background: var(--bg-page); color: var(--text-secondary);
    font-size: 1.5rem; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.incrementor-button:hover { background-color: #dfe1e6; }
.incrementor-button:disabled { opacity: 0.5; cursor: not-allowed; }

.main-controls-area {
    display: flex;
    gap: 1rem;
}

.action-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    height: var(--input-height);
    padding: 0 1.5rem; border-radius: var(--border-radius);
    border: 1px solid transparent; font-family: var(--font-family); font-weight: 600;
    font-size: 1rem; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.action-button-main { background-color: var(--brand-blue); color: white; }
.action-button-main:hover { background-color: var(--brand-blue-hover); }

/* --- Typeahead (Autocomplete) Styles (REFINED) --- */
.typeahead-container { position: relative; }
.typeahead-suggestions {
    position: absolute; top: 100%; left: 0; right: 0; background-color: var(--bg-surface);
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
    box-shadow: var(--shadow); margin-top: 4px; max-height: 300px;
    overflow-y: auto; z-index: 1000; list-style: none; padding: 0.5rem;
    margin: 8px 0 0;
}
.suggestion-entry {
    display: flex;
    align-items: center; /* Vertically align content */
    gap: 1rem; /* Space between code and details */
    padding: 0.75rem 1rem;
    border-radius: 6px; cursor: pointer; transition: background-color 0.15s;
}
.suggestion-entry.is-active-suggestion, .suggestion-entry:hover { 
    background-color: #eaf2ff; 
}
.suggestion-iata-code {
    font-weight: 700;
    font-size: 1rem;
    color: var(--brand-blue);
    background-color: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    min-width: 50px;
    text-align: center;
    flex-shrink: 0; /* Prevent the code from shrinking */
}
/* REFINED: Container for the text details */
.suggestion-details {
    line-height: 1.4;
    overflow: hidden; /* Prevent long text from breaking layout */
}

.suggestion-details .suggestion-location { 
    font-weight: 600; 
    color: var(--text-primary);
}
.suggestion-details .suggestion-airport-name { 
    font-size: 0.875rem; 
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-suggestions-found { padding: 0.75rem 1rem; color: var(--text-secondary); }

.typeahead-suggestions .suggestion-category {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Cute Notification Styles --- */
#cute-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -150%);
    background-color: #fff0f0;
    color: #c53030;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid #fecaca;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 1rem;
    opacity: 0;
    transition: transform 0.4s ease-in-out, opacity 0.4s ease-in-out;
}
#cute-notification.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
#cute-notification .message {
    font-weight: 500;
}


/* --- Results Page Specific Styles --- */
#search-overlay-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000;
    display: none; align-items: flex-start; justify-content: center;
}
#search-overlay-container.is-visible { display: flex; }
.overlay-backdrop {
    position: absolute; width: 100%; height: 100%;
    background-color: rgba(9, 30, 66, 0.3);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.overlay-content-box {
    position: relative; z-index: 1; background-color: var(--bg-page);
    border-radius: 12px; margin-top: 5vh; width: 90%; max-width: 1200px;
    max-height: 90vh; display: flex; flex-direction: column;
}
.overlay-title-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color);
}
.overlay-title-bar h2 { margin: 0; }
#close-overlay-button, #close-filters-overlay-button {
    background: none; border: none; font-size: 2rem; color: var(--text-secondary);
    cursor: pointer; padding: 0; line-height: 1;
}
.overlay-body { overflow-y: auto; padding: 1.5rem; }
.overlay-body .booking-form-wrapper { box-shadow: none; border: none; padding: 0; }

#journey-options-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}
.loading-indicator-wrapper {
    grid-column: 1 / -1; text-align: center; padding: 4rem 1rem;
    color: var(--text-secondary);
}
.loading-indicator-animation {
    display: inline-block; width: 50px; height: 50px; border: 4px solid var(--border-color);
    border-top-color: var(--brand-blue); border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* IMPROVED: Empty State Styles */
.empty-state-message { 
    grid-column: 1 / -1; text-align: center; font-size: 1.2rem; padding: 4rem 1rem;
}
.empty-state-container {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1rem;
}
.empty-state-container .empty-state-message {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    padding: 0; /* Override generic padding */
}
.empty-state-container .action-button {
    width: auto; /* Override mobile full-width style */
    padding: 0 2rem;
}


.itinerary-item {
    background-color: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--border-radius); box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
.itinerary-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(23, 43, 77, 0.12);
}
.itinerary-item.is-highlighted {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.25);
    transform: translateY(-3px);
}

.item-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color);
}
.carrier-label { font-weight: 600; }
.fare-display { font-weight: 700; font-size: 1.5rem; color: var(--brand-blue); }
.item-details {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem;
}
.schedule-block { text-align: center; }
.hour-minute { font-size: 1.5rem; font-weight: 600; }
.iata-locator { color: var(--text-secondary); font-weight: 500; }
.route-summary { text-align: center; flex-grow: 1; padding: 0 1rem; }
.travel-time { font-size: 0.875rem; }
.route-connector {
    height: 1px; background-color: var(--border-color);
    margin: 0.25rem 0;
}
.connection-info { font-size: 0.875rem; color: var(--text-secondary); }

.floating-action-trigger {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 56px;
    padding: 0 1.5rem;
    background-color: var(--brand-blue);
    color: white;
    border-radius: 28px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
}
.floating-action-trigger:hover {
    background-color: var(--brand-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.1);
}
.floating-action-trigger svg {
    flex-shrink: 0;
}

/* --- Results Page Layout --- */
.results-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: start;
}

#available-journeys-section {
    padding-bottom: 6rem;
}

/* CORRECTED: Made sidebar sticky on desktop/tablet */
#filters-sidebar {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 1.5rem;
    background-color: var(--bg-surface);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.filter-group {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}
#filters-sidebar .filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-option label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--brand-blue);
    cursor: pointer;
    border-radius: 50%;
}
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--brand-blue);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}
#price-range-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

#airline-filter-options {
    max-height: 200px;
    overflow-y: auto;
}
.airline-filter-item label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    padding: 0.25rem 0;
    cursor: pointer;
}

/* NEW: Style for the "Select All" airline option */
.airline-filter-all-item {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
}
.airline-filter-all-item label {
    font-size: 0.95rem; /* Slightly larger */
}


/* --- Results Top Bar (Sort + Mobile Filter Trigger) --- */
.results-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

/* CORRECTED: Hide mobile-only button by default */
#mobile-filter-trigger {
    display: none;
}

#desktop-clear-filters-button {
    margin-right: auto; /* Push sort controls to the right */
}

.action-button-alt {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.action-button-alt:hover {
    border-color: var(--brand-blue);
    background-color: var(--bg-page);
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sort-controls label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.styled-select {
    position: relative;
    border-radius: var(--border-radius);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    overflow: hidden;
}
.styled-select select {
    -webkit-appearance: none;
    appearance: none;
    background-color: transparent;
    border: none;
    padding: 0 2rem 0 1rem;
    height: 40px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}
.styled-select:hover {
    border-color: var(--brand-blue);
}
.styled-select::after {
    content: ' ';
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b778c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
}


/* --- Mobile Filter Overlay --- */
#filters-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    display: none;
    background-color: rgba(247, 248, 250, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
#filters-overlay.is-visible {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
#filters-overlay-content {
    background-color: var(--bg-page);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}
#filters-overlay .overlay-body #filters-sidebar {
    box-shadow: none;
    border: none;
    padding: 0;
    background: transparent;
}
#filters-overlay .overlay-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}
#filters-overlay .overlay-footer .action-button {
    width: 100%;
    justify-content: center;
}


/* --- Responsive Adjustments --- */
@media (max-width: 992px) {
    .form-division-controls {
        flex-direction: column; align-items: stretch;
    }
    .main-controls-area {
        flex-direction: column-reverse; width: 100%;
    }
    .action-button { width: 100%; }
    
    .results-layout {
        grid-template-columns: 1fr;
    }
    
    .results-layout > #filters-sidebar {
        display: none;
    }
    .results-top-bar {
        justify-content: space-between;
    }

    #mobile-filter-trigger {
        display: inline-flex;
    }
    #desktop-clear-filters-button {
        display: none;
    }
    .sort-controls {
        flex-grow: 1;
        justify-content: flex-end;
    }
}

@media (max-width: 768px) {
    .primary-heading-group h1 { font-size: 2rem; }
    .booking-form-wrapper { padding: 1rem; }
    
    .journey-style-selector {
        width: 100%;
    }
    .journey-style-selector label {
        flex-grow: 1;
        justify-content: center;
        padding: 0.75rem 0.5rem;
        gap: 0;
    }
    .journey-style-selector .journey-style-label { display: none; }
    .journey-style-selector svg { display: block; }
    
    .floating-action-trigger {
        width: 56px;
        height: 56px;
        padding: 0;
        justify-content: center;
        right: 1.5rem;
        bottom: 1.5rem;
    }
    .floating-action-trigger .floating-trigger-label { display: none; }

    #cute-notification {
        width: 90%;
        top: 10px;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    form[data-journey-style="one-way"] .travel-segment,
    form[data-journey-style="round-trip"] .travel-segment {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
        grid-template-areas:
            "origin origin"
            "swap swap"
            "destination destination"
            "depart return"
            "actions actions";
        row-gap: 0.75rem;
    }

    form[data-journey-style="one-way"] .travel-segment {
        grid-template-areas:
            "origin origin"
            "swap swap"
            "destination destination"
            "depart depart"
            "actions actions";
    }

    form[data-journey-style="multi-city"] .travel-segment {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "origin origin"
            "swap swap"
            "destination destination"
            "depart actions";
        row-gap: 0.75rem;
    }

    .travel-segment .departure-group { grid-area: origin; }
    .travel-segment .arrival-group { grid-area: destination; }
    .travel-segment .swap-locations-button {
        grid-area: swap;
        justify-self: center;
        margin: -0.25rem 0;
    }
    .travel-segment .date-depart-group { grid-area: depart; }
    .travel-segment .date-return-group { grid-area: return; }
    .travel-segment .segment-actions {
        grid-area: actions;
        justify-content: flex-end;
    }
    
    form[data-journey-style="multi-city"] .travel-segment .segment-actions {
        align-self: end;
    }
}