/* Reset and Base Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Roboto', sans-serif; background-color: #f4f6f8; color: #333; line-height: 1.6; transition: background-color 0.3s ease; }
.container { width: 90%; margin: auto; padding: 20px 0; transition: width 0.5s ease, max-width 0.5s ease; }
.container.full-width { width: 95%; }

/* Header */
header { background: linear-gradient(135deg, #6b73ff 0%, #000dff 100%); padding: 15px 0; color: #fff; text-align: center; margin-bottom: 20px; }
header h1 { font-size: 1.8em; font-weight: 700; }

/* Main Content */
main { display: flex; flex-direction: column; gap: 20px; }
.main-container { display: flex; flex-direction: column; gap: 20px; transition: flex-direction 0s ease 0.5s; }
.left-panel { display: flex; flex-direction: column; gap: 20px; width: 100%; transition: all 0.5s ease; }
.right-panel { width: 100%; transition: all 0.5s ease; }
.sticky-wrapper { position: -webkit-sticky; position: sticky; top: 20px; z-index: 10; }

/* Search Section */
.search-section { background-color: #fff; padding: 20px; border-radius: 6px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: all 0.5s ease; width: 100%; max-width: 100%; overflow: hidden; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 5px; }
.form-group input[type="number"], .form-group input[type="date"], .form-group input[type="text"], .form-group select { width: 100%; padding: 10px; border: 1px solid #ccd0d5; border-radius: 4px; transition: border 0.3s ease; }
.form-group input:focus, .form-group select:focus, .form-group input[type="text"]:focus { border-color: #6b73ff; outline: none; }
.checkbox-group { display: flex; align-items: center; gap: 10px; }
.form-row { display: flex; gap: 15px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }

/* --- Nicer Range Slider Styles --- */
.form-row .stop-days-group {
    flex: 2; /* Make it take up more space */
    min-width: 280px;
}
.stop-days-group .form-group-label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
}
.range-slider-wrapper {
    /* Main container for the whole component */
}
.range-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.range-header label {
    margin-bottom: 0; /* Override default form-group label margin */
}
.range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}
.range-inputs input[type="number"] {
    width: 55px;
    padding: 6px 8px;
    text-align: center;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9em;
    -moz-appearance: textfield;
}
.range-inputs input[type="number"]::-webkit-outer-spin-button,
.range-inputs input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.range-inputs span {
    color: #888;
    font-weight: 500;
}
.range-slider {
    position: relative;
    height: 20px;
}
.range-slider .slider-track-background {
    position: absolute;
    width: 100%;
    height: 5px;
    background: #e9ecef;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 3px;
    z-index: 1;
}
.range-slider .slider-track-range {
    position: absolute;
    height: 5px;
    background: #6b73ff;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 3px;
    z-index: 2;
}
.range-slider input[type="range"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
    background: transparent;
    z-index: 3;
    height: 100%;
    margin: 0;
}
.range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: all;
    width: 18px;
    height: 18px;
    background: #6b73ff;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6.5px;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.range-slider input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.range-slider input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(107, 115, 255, 0.3);
}
.range-slider input[type="range"]::-moz-range-thumb {
    pointer-events: all;
    -moz-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #6b73ff;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.range-slider input[type="range"]:hover::-moz-range-thumb {
    transform: scale(1.15);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.range-slider input[type="range"]:active::-moz-range-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(107, 115, 255, 0.3);
}
/* --- End Nicer Range Slider Styles --- */


/* Buttons */
.btn { position: relative; display: inline-block; background-color: #6b73ff; color: #fff; padding: 10px 20px; border: none; border-radius: 20px; cursor: pointer; font-size: 1em; transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease; width: 100%; text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn i { margin-right: 5px; }
.btn:hover { background-color: #575fcf; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn-small { padding: 5px 10px; font-size: 0.8em; border-radius: 15px; width: auto; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; white-space: nowrap; }
.btn-small i { font-size: 0.85em; margin-right: 3px; }
.btn-accommodation { background-color: #ffc107; color: #333; }
.btn-accommodation:hover { background-color: #e0a800; color: #333; }
.btn-book-flight { background-color: #28a745; color: #fff; }
.btn-book-flight:hover { background-color: #218838; color: #fff; }
.btn.btn-secondary { background-color: #6c757d; }
.btn.btn-secondary:hover { background-color: #5a6268; }

/* Spinner */
.spinner { display: inline-block; width: 16px; height: 16px; border: 3px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: #fff; animation: spin 1s ease-in-out infinite; margin-left: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.loading { cursor: not-allowed; opacity: 0.7; }
.btn.loading .spinner { display: inline-block; }
.btn .spinner { display: none; }

/* Reset Button */
.reset-btn { margin-top: 15px; background-color: #ff6b6b; display: none; border-radius: 20px; }
.reset-btn:hover { background-color: #ff4c4c; }
.reset-btn.hidden { display: none; }

/* Map Section */
.map-section { background-color: #fff; padding: 15px; border-radius: 6px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: all 0.5s ease; opacity: 0; transform: translateY(20px); width: 100%; max-width: 100%; height: 350px; margin-bottom: 15px; }
.map-section.visible { opacity: 1; transform: translateY(0); }
.map-section.hidden { display: none; }
#map { width: 100%; height: 100%; }

/* Results Navigation (Tabs) */
.results-navigation { margin-bottom: 15px; border-bottom: 2px solid #dee2e6; padding-bottom: 5px; transition: opacity 0.3s ease; opacity: 1; }
.results-navigation .tab { display: inline-block; padding: 8px 15px; cursor: pointer; border: none; background-color: transparent; color: #495057; font-weight: 500; border-bottom: 3px solid transparent; transition: color 0.2s ease, border-bottom-color 0.2s ease; position: relative; }
.results-navigation .tab:hover { color: #007bff; }
.results-navigation .tab.active { color: #6b73ff; border-bottom-color: #6b73ff; }
.results-navigation .tab .badge { background-color: #dc3545; color: white; font-size: 0.7em; padding: 2px 5px; border-radius: 8px; position: absolute; top: 4px; right: 2px; line-height: 1; }

/* Airport Filter Section */
.airport-filter-section {
    background-color: #fff;
    padding: 12px 15px; /* Slightly reduced padding */
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 15px;
}
.airport-filter-section .filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.airport-filter-section h4 {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.05em; /* Slightly smaller title */
    color: #333;
    font-weight: 500;
}
/* Make clear filter button smaller */
#clear-airport-filters-btn {
    padding: 4px 8px;
    font-size: 0.75em;
}
#clear-airport-filters-btn i {
    margin-right: 3px;
    font-size: 0.9em;
}
.airport-filter-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px; /* Reduced gap */
    padding-bottom: 3px;
}
.airport-filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px; /* Reduced padding for compactness */
    border-radius: 14px; /* Slightly less rounded */
    border: 1px solid #ccd0d5;
    cursor: pointer;
    font-size: 0.8em; /* Smaller font for compactness */
    transition: all 0.2s ease;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.3; /* Adjusted line-height */
    max-width: 200px; /* Prevent extremely long pills */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.airport-filter-pill:hover {
    border-color: #6b73ff;
    background-color: #e6e9ff;
}
.airport-filter-pill i {
    margin-left: 5px; /* Adjusted icon margin */
    font-size: 0.85em; /* Adjusted icon size */
    flex-shrink: 0; /* Prevent icon from shrinking */
}
.airport-filter-pill.include {
    background-color: #d1e7dd; border-color: #badbcc; color: #0f5132;
}
.airport-filter-pill.include i { color: #198754; }
.airport-filter-pill.exclude {
    background-color: #f8d7da; border-color: #f5c2c7; color: #58151c;
}
.airport-filter-pill.exclude i { color: #dc3545; }


/* Results Section */
.results-section { background-color: transparent; padding: 0; border-radius: 0; box-shadow: none; transition: all 0.5s ease; opacity: 0; transform: translateY(0); }
.results-section.visible { opacity: 1; transform: translateY(0); }
.results-section.hidden { display: none; }
.results-section #initial-placeholder { padding: 20px; text-align: center; color: #6c757d; font-style: italic; }

/* Results Table Styling */
#results table { width: 100%; border-collapse: separate; border-spacing: 0 8px; margin-top: 0; }
#results table thead { background-color: #6b73ff; color: #fff; }
#results table thead th { padding: 10px 8px; text-align: center; font-weight: 500; position: sticky; top: 0; z-index: 5; font-size: 0.85em; white-space: nowrap; }
#results table thead th:first-child { border-top-left-radius: 6px; width: 40px; }
#results table thead th:nth-child(2) { text-align: left; }
#results table thead th:last-child { border-top-right-radius: 6px; }

#results table tbody tr.result-summary-row { background-color: #fff; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.07); transition: background-color 0.2s ease, box-shadow 0.2s ease, border-radius 0.2s ease; cursor: pointer; overflow: hidden; border: 1px solid transparent; }
#results table tbody tr.result-summary-row:hover { background-color: #f8f9fa; box-shadow: 0 3px 6px rgba(0,0,0,0.1); }
#results table tbody tr.result-summary-row.active-row { box-shadow: 0 4px 10px rgba(107, 115, 255, 0.2); border: 1px solid #a9adf5; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-color: transparent; }

#results table tbody td { padding: 8px; text-align: center; vertical-align: middle; font-size: 0.9em; }
#results table tbody td.star-cell { width: 40px; padding: 8px 0; text-align: center; vertical-align: middle; }
#results table tbody td.flight-path-cell { text-align: left; }
#results table tbody td.date-cell { white-space: nowrap; font-size: 0.85em; }
#results table tbody tr.result-summary-row td:first-child { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
#results table tbody tr.result-summary-row td:last-child { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
#results table tbody tr.result-summary-row.active-row td:first-child { border-bottom-left-radius: 0; }
#results table tbody tr.result-summary-row.active-row td:last-child { border-bottom-right-radius: 0; }

/* Save Star Icon */
.save-star-icon { font-size: 1.2em; color: #ffc107; cursor: pointer; transition: transform 0.2s ease, color 0.2s ease; }
.save-star-icon:hover { transform: scale(1.2); }
.save-star-icon.fas { color: #ffc107; }
.save-star-icon.far { color: #adb5bd; }
.save-star-icon.far:hover { color: #ffc107; }

/* Flight Path Icon Styling */
.flight-path-icon { margin: 0 4px; color: #6b73ff; font-size: 0.85em; }

/* Integrated Details Styling */
.flight-details-row { background-color: #fff; box-shadow: 0 4px 10px rgba(107, 115, 255, 0.2); border: 1px solid #a9adf5; border-top: none; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; cursor: pointer; }
.flight-details-row td { padding: 0; border: none; }
.integrated-details-content { padding: 15px; display: flex; flex-direction: column; gap: 10px; }

.flight-segment { background-color: #f8f9fa; border-radius: 4px; padding: 10px; border: 1px solid #e9ecef; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.segment-main { flex-grow: 1; }
.segment-action { flex-shrink: 0; }
.segment-airports { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.airport { flex: 1; }
.airport.from { text-align: left; }
.airport.to { text-align: right; }
.airport-code { display: block; font-size: 1em; font-weight: 700; color: #333; }
.airport-name { display: block; font-size: 0.8em; color: #555; margin-bottom: 2px; line-height: 1.2; }
.airport-time { display: block; font-size: 0.85em; color: #333; font-weight: 500; }
.segment-arrow { display: flex; flex-direction: column; align-items: center; text-align: center; color: #6b73ff; margin: 0 5px; }
.segment-arrow i { font-size: 1.2em; }
.segment-duration, .segment-price { font-size: 0.8em; color: #555; margin-top: 2px; font-weight: 500; white-space: nowrap; }
.segment-price { color: #28a745; font-weight: 700; }

.stay-info { display: flex; align-items: center; gap: 10px; background-color: #e9ecef; padding: 8px 10px; border-radius: 4px; border: 1px solid #dee2e6; font-size: 0.9em; }
.stay-icon { font-size: 1.2em; color: #6c757d; flex-shrink: 0; }
.stay-details { flex-grow: 1; line-height: 1.3; }
.stay-location { display: block; font-weight: 500; color: #333; }
.stay-duration, .stay-dates { display: inline-block; margin-right: 8px; font-size: 0.9em; color: #555; }
.stay-details .btn-accommodation { margin-left: auto; }

/* Pagination Styles */
.pagination-container { display: flex; justify-content: center; padding: 20px 0; margin-top: 10px; }
.pagination { display: flex; padding-left: 0; list-style: none; border-radius: 0.25rem; }
.page-item { margin: 0 2px; }
.page-item .page-link, .page-item span.page-link { position: relative; display: block; padding: 0.5rem 0.75rem; line-height: 1.25; color: #6b73ff; background-color: #fff; border: 1px solid #dee2e6; text-decoration: none; transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; cursor: pointer; }
.page-item:first-child .page-link, .page-item:first-child span.page-link { border-top-left-radius: 0.25rem; border-bottom-left-radius: 0.25rem; }
.page-item:last-child .page-link, .page-item:last-child span.page-link { border-top-right-radius: 0.25rem; border-bottom-right-radius: 0.25rem; }
.page-item .page-link:hover { z-index: 2; color: #575fcf; background-color: #e9ecef; border-color: #ced4da; }
.page-item.active .page-link, .page-item.active span.page-link { z-index: 3; color: #fff; background-color: #6b73ff; border-color: #6b73ff; }
.page-item.disabled .page-link, .page-item.disabled span.page-link { color: #6c757d; pointer-events: none; cursor: auto; background-color: #fff; border-color: #dee2e6; }

/* Footer */
footer { background-color: #fff; padding: 15px 0; text-align: center; margin-top: 30px; border-top: 1px solid #e0e0e0; }
footer p { color: #777; font-size: 0.85em; }

/* --- Responsive Design --- */
@media (min-width: 769px) {
    .main-container.search-active { flex-direction: row; gap: 25px; align-items: flex-start; }
    .main-container.search-active .left-panel { width: 35%; flex-shrink: 0; }
    .main-container .right-panel { width: 65%; flex-grow: 1; }
}

@media (max-width: 992px) {
    .segment-airports { flex-direction: column; align-items: stretch; gap: 5px; }
    .airport.from, .airport.to { text-align: center; }
    .segment-arrow i { transform: rotate(90deg); }
    .segment-arrow { margin: 5px 0; }
    .flight-segment { flex-direction: column; align-items: stretch; }
    .segment-action { margin-top: 8px; text-align: center; }
    .stay-info { flex-wrap: wrap; }
    .stay-details { flex-basis: 100%; margin-bottom: 5px; }
    .stay-info .btn-accommodation { margin-left: auto; }
}

@media (max-width: 768px) {
    .main-container.search-active { flex-direction: column; }
    .main-container.search-active .left-panel { position: static; width: 100%; order: 1; }
    .main-container.search-active .left-panel .sticky-wrapper { position: static; top: auto; bottom: auto; }
    .main-container.search-active .right-panel.visible { width: 100%; order: 2; }

    .left-panel, .right-panel { width: 100%; }
    .map-section { height: 280px; margin-top: 0; transform: translateY(0); margin-bottom: 15px; }
    .results-section { max-width: 100%; }
    .results-navigation { margin-bottom: 10px; }
    .results-navigation .tab { padding: 6px 10px; font-size: 0.9em; }
    .pagination-container { padding: 15px 5px; }
    .page-item .page-link, .page-item span.page-link { padding: 0.4rem 0.6rem; font-size: 0.9em; }

    .airport-filter-section .filter-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .airport-filter-section h4 { margin-bottom: 5px; font-size: 1em; }
    #clear-airport-filters-btn { align-self: flex-start; font-size: 0.7em; padding: 3px 6px; }
    .airport-filter-pill { font-size: 0.75em; padding: 3px 8px; max-width: 150px; }

    .select2-container--default .select2-selection--multiple { height: auto; min-height: 38px; }
    .select2-container--default .select2-selection--multiple .select2-selection__rendered { display: flex; flex-wrap: wrap; padding: 5px; }
    .select2-container--default .select2-selection--multiple .select2-selection__choice { margin: 2px 5px 2px 0; }
    .select2-container--default .select2-selection--multiple .select2-search--inline { width: auto; }
    .select2-container--default .select2-results__option { white-space: normal; }

    #results table { border-spacing: 0 5px; }
    #results table thead { display: none; }
    #results table tbody tr.result-summary-row { display: block; margin-bottom: 0; border-radius: 6px 6px 0 0; box-shadow: 0 2px 3px rgba(0,0,0,0.06); position: relative; border: 1px solid transparent; }
    #results table tbody tr.result-summary-row.active-row { box-shadow: 0 2px 5px rgba(107, 115, 255, 0.15); border: 1px solid #c1c4f7; border-bottom-color: transparent; }
    #results table tbody tr.result-summary-row td { display: block; text-align: right; padding-left: 45%; position: relative; border: none; border-bottom: 1px dotted #eee; padding-top: 8px; padding-bottom: 8px; padding-right: 10px; border-radius: 0 !important; font-size: 0.9em; }
    #results table tbody tr.result-summary-row td.star-cell { position: absolute; top: 0; left: 0; height: 100%; width: 40px; padding: 0; display: flex; align-items: center; justify-content: center; border-bottom: none; background-color: #f9f9f9; border-right: 1px dotted #eee; border-radius: 6px 0 0 0 !important; }
    #results table tbody tr.result-summary-row td.star-cell::before { display: none; }
    #results table tbody tr.result-summary-row td:not(.star-cell) { padding-left: calc(45% + 40px); }
    #results table tbody tr.result-summary-row td::before { content: attr(data-label); position: absolute; left: 48px; width: calc(45% - 16px); padding-right: 5px; white-space: nowrap; text-align: left; font-weight: bold; top: 50%; transform: translateY(-50%); font-size: 0.9em; }
    #results table tbody tr.result-summary-row td.flight-path-cell { text-align: left; padding-left: 48px; font-weight: normal; background-color: #f9f9f9; border-radius: 0 6px 0 0 !important; min-height: 40px; }
    #results table tbody tr.result-summary-row td.flight-path-cell::before { position: static; display: block; transform: none; width: auto; margin-bottom: 3px; font-weight: bold; padding-left: 0; }
    #results table tbody tr.result-summary-row td:last-child { border-bottom: none; }

    .flight-details-row { display: block; border-radius: 0 0 6px 6px; margin-bottom: 10px; box-shadow: 0 2px 5px rgba(107, 115, 255, 0.15); border: 1px solid #c1c4f7; border-top: none; }
    .flight-details-row td { display: block; width: 100%; }
    .integrated-details-content { padding: 10px; gap: 8px; }
    .flight-segment { padding: 8px; flex-direction: column; align-items: stretch; }
    .segment-action { text-align: center; margin-top: 8px; }
    .btn-small { padding: 5px 10px; font-size: 0.8em; }
    .stay-info { padding: 6px 8px; font-size: 0.85em; }
    .stay-info .btn-accommodation { align-self: flex-end; }
}