/* ================================================
   Route Finder - Modern Layout Styles
   Based on Schedule Generator Design
   ================================================ */

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.content-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container & Layout */
.form-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 50px 80px;
}

.form-container h2 {
    font-size: 2rem;
    font-weight: 600;
    color: #4092cc;
    text-align: center;
    margin-bottom: 40px;
    letter-spacing: 0.5px;
}

#flight-filter-form {
    background-color: #ffffff;
    padding: 40px 50px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e8e8e8;
}

/* Route Type Toggle */
.route-type-container {
    margin-bottom: 35px;
    text-align: center;
}

.route-type-toggle {
    display: inline-flex;
    gap: 0;
    background: #f0f0f0;
    padding: 4px;
    border-radius: 8px;
    min-width: 280px;
}

.route-type-btn {
    flex: 1;
    padding: 10px 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.route-type-btn:hover:not(.selected) {
    color: #4092cc;
}

.route-type-btn.selected {
    background: #4092cc;
    color: #fff;
    box-shadow: 0 2px 4px rgba(64, 146, 204, 0.2);
}

/* Airline Selection Section */
.airline-logo-container {
    margin-bottom: 35px;
}

.airline-select-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    font-family: 'Poppins', sans-serif;
    text-align: center;
}

#airline-search {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 15px;
    display: block;
    padding: 10px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s ease;
    text-align: center;
}

#airline-search::placeholder {
    text-align: center;
}

#airline-search:focus {
    outline: none;
    border-color: #4092cc;
}

#airline-logo-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 25px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    width: 100%;
}

.airline-logo {
    width: 110px;
    height: auto;
    object-fit: contain;
    cursor: pointer;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 6px;
    transition: all 0.2s ease;
    background: white;
}

.airline-logo:hover {
    transform: translateY(-2px);
    border-color: #4092cc;
    box-shadow: 0 2px 8px rgba(64, 146, 204, 0.15);
}

.airline-logo.selected {
    border-color: #4092cc;
}

/* Aircraft Grid */
#aircraft-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 25px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    margin-bottom: 30px;
    width: 100%;
}

.aircraft-box {
    padding: 12px 24px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    background-color: white;
    color: #666;
}

.aircraft-box:hover:not(.selected) {
    border-color: #4092cc;
    color: #4092cc;
    transform: translateY(-1px);
}

.aircraft-box.selected {
    background-color: #4092cc;
    color: white;
    border-color: #4092cc;
}

.aircraft-box.any-aircraft {
    font-weight: 600;
}

/* Form Rows - Multi-column Layout */
.form-row {
    display: grid;
    gap: 25px;
    margin-bottom: 30px;
}

.form-row.filters-row {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
    font-family: 'Poppins', sans-serif;
    text-align: center;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="time"] {
    width: 100%;
    min-height: 45px;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
    background: white;
    box-sizing: border-box;
    text-align: center;
}

.form-group input::placeholder {
    text-align: center;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #4092cc;
    box-shadow: 0 0 0 3px rgba(64, 146, 204, 0.1);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%23666' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 36px;
}

/* Slider Styles */
.sliders-wrapper {
    margin-bottom: 30px;
}

.slider-group {
    margin-bottom: 30px;
}

.slider-group label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
    font-family: 'Poppins', sans-serif;
    text-align: center;
}

.slider-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Slider container */
.slider-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 15px;
    position: relative;
}

/* noUiSlider target */
.noUi-target {
    background: #f1f1f1 !important;
    border-radius: 8px !important;
    border: none !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1) !important;
    height: 8px !important;
}

.noUi-connects {
    border-radius: 8px !important;
}

.noUi-connect {
    background: #4092cc !important;
}

.noUi-horizontal {
    height: 8px !important;
}

/* FIX: Handle positioning - use left offset instead of right */
.noUi-horizontal .noUi-handle {
    width: 24px !important;
    height: 24px !important;
    right: -12px !important;  /* Keep this */
    top: -8px !important;
    border: none !important;
    background: #4092cc !important;
    cursor: pointer !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
    border-radius: 50% !important;
}

.noUi-handle:hover {
    background: #357ab7 !important;
}

.noUi-handle:before,
.noUi-handle:after {
    display: none !important;
}

.noUi-state-drag * {
    cursor: grabbing !important;
}

/* FIX: Labels need to match slider positions exactly */
.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 11px;
    color: #999;
    padding: 0;  /* Changed from 5px to 0 */
    position: relative;
}

.slider-labels span {
    display: block;
    width: 20px;  /* Give each label a fixed width */
    text-align: center;
    position: relative;
    left: -10px;  /* Offset by half width to center */
}

/* OR use this alternative approach with absolute positioning */
.slider-labels-alt {
    position: relative;
    height: 20px;
    margin-top: 12px;
    font-size: 11px;
    color: #999;
}

.slider-labels-alt span {
    position: absolute;
    transform: translateX(-50%);
}

/* Position each label at exact percentage points */
.slider-labels-alt span:nth-child(1) { left: 0%; }
.slider-labels-alt span:nth-child(2) { left: 6.67%; }
.slider-labels-alt span:nth-child(3) { left: 13.33%; }
.slider-labels-alt span:nth-child(4) { left: 20%; }
.slider-labels-alt span:nth-child(5) { left: 26.67%; }
.slider-labels-alt span:nth-child(6) { left: 33.33%; }
.slider-labels-alt span:nth-child(7) { left: 40%; }
.slider-labels-alt span:nth-child(8) { left: 46.67%; }
.slider-labels-alt span:nth-child(9) { left: 53.33%; }
.slider-labels-alt span:nth-child(10) { left: 60%; }
.slider-labels-alt span:nth-child(11) { left: 66.67%; }
.slider-labels-alt span:nth-child(12) { left: 73.33%; }
.slider-labels-alt span:nth-child(13) { left: 80%; }
.slider-labels-alt span:nth-child(14) { left: 86.67%; }
.slider-labels-alt span:nth-child(15) { left: 93.33%; }
.slider-labels-alt span:nth-child(16) { left: 100%; }

.slider-value {
    margin-top: 12px;
    text-align: center;
    font-weight: 600;
    color: #4092cc;
    font-size: 14px;
}

/* Submit Button */
.button-container {
    display: flex;
    justify-content: center;
    margin-top: 35px;
}

.button-container button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 12px 48px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.button-container button:hover {
    background-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

/* Results Section */
.results {
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Flight Cards - Constrain width but let them be responsive */
.results .flight-card {
    max-width: 650px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Map Section */
#flight-map {
    max-width: 100% !important;
    width: 100% !important;
    height: 800px !important;
    margin: 40px auto !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    position: relative !important;
    left: 0 !important;
}

/* Leaflet-specific styles */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid rgba(64, 146, 204, 0.2);
}

.custom-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
    cursor: pointer;
}

.departure-marker {
    background-color: #4CAF50;
}

.arrival-marker {
    background-color: #f44336;
}

.flight-route {
    stroke-width: 4;
    stroke-opacity: 0.8;
    fill: none;
    cursor: pointer;
}

.flight-route:hover {
    stroke-width: 6;
}

.multi-airline-route {
    stroke: #808080;
    stroke-width: 6;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4092cc;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 40px auto;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message Container */
.message-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    padding: 20px;
    text-align: center;
}

.message-text {
    font-size: 15px;
    color: #666;
    max-width: 600px;
    line-height: 1.6;
}

.message-text.error {
    color: #dc3545;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .form-container {
        padding: 30px 40px;
    }

    .form-row.filters-row {
        grid-template-columns: 1fr;
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .form-container {
        padding: 20px;
    }

    #flight-filter-form {
        padding: 25px 20px;
    }

    .form-row,
    .form-row.filters-row {
        grid-template-columns: 1fr;
    }

    .route-type-toggle {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .route-type-btn {
        padding: 12px 20px;
        font-size: 14px;
    }

    #airline-logo-grid,
    #aircraft-grid {
        gap: 8px;
        padding: 15px;
    }

    .airline-logo {
        width: 80px;
    }

    .slider-container {
        padding: 0 10px;
    }

    .button-container button {
        width: 100%;
        max-width: 300px;
    }
    
    /* Mobile Flight Card Fixes */
    .results {
        padding: 0 15px;
    }
    
    .flight-card-home {
        max-width: 100%;
        width: 100%;
    }

    .flight-card-home__grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    .flight-card-home__airline {
        order: 1;
        width: 100%;
    }
    
    .flight-card-home__logo-container {
        margin: 0 auto;
    }

    .flight-card-home__route {
        order: 3 !important;
        background: #f8fafc !important;
        padding: 16px !important;
        border-radius: 8px !important;
        width: 100%;
        box-sizing: border-box;
    }
    
    .flight-card-home__flight-path {
        margin: 0 auto;
    }
    
    .flight-card-home__airport {
        min-width: 80px;
    }
    
    .flight-card-home__airport-code {
        font-size: 1.5em !important;
        word-break: keep-all;
        white-space: nowrap;
    }

    .flight-card-home__details {
        order: 2 !important;
        flex-direction: row !important;
        justify-content: space-around !important;
        gap: 20px !important;
        width: 100%;
    }
    
    .flight-card-home__detail-item {
        flex: 1;
        min-width: 0;
    }
    
    .flight-card-home__detail-value,
    .flight-card-home__detail-label {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .flight-card-home__content {
        padding: 20px 16px;
    }
    
    #flight-map {
        height: 500px !important;
    }
}

@media (max-width: 480px) {
    .form-container h2 {
        font-size: 1.5rem;
    }

    .route-type-btn {
        padding: 8px 20px;
        font-size: 13px;
    }

    .aircraft-box {
        min-width: 45%;
        font-size: 12px;
    }
}

/* Footer Styles */
.footer {
    margin-top: auto;
    padding: 1.5rem 0;
    background-color: #ffffff;
    border-top: 1px solid #e8e8e8;
    width: 100%;
    font-family: 'Poppins', Arial, sans-serif;
}

.discord-link-container {
    text-align: center;
    padding: 0.75rem 0;
}

.discord-link {
    color: #5865F2;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border: 2px solid #5865F2;
    border-radius: 8px;
    display: inline-block;
    transition: all 0.2s ease;
}

.discord-link:hover {
    background-color: #5865F2;
    color: white;
}

.version-number {
    text-align: center;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: #999;
}

/* Flight Cards */
.flight-card {
    cursor: pointer;
    margin: 1rem auto;
    user-select: none;
    transition: transform 0.2s ease;
}

.flight-card.selected .flight-card-home {
    box-shadow: 0 0 0 3px #28a745, 0 4px 12px rgba(40, 167, 69, 0.2);
    transform: translateY(-2px);
}

.flight-card:hover {
    transform: translateY(-2px);
}

.flight-card-home {
    position: relative;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 0.5em;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.flight-card-home__accent {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.flight-card-home__content {
    position: relative;
    z-index: 2;
    padding: 24px;
}

.flight-card-home__grid {
    display: grid;
    grid-template-columns: 140px 1fr 140px;
    gap: 24px;
    align-items: center;
}

.flight-card-home__airline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.flight-card-home__logo-container {
    background: white;
    padding: 10px;
    border-radius: 8px;
    width: 150px;
    height: 60px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.flight-card-home__logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.flight-card-home__flight-number {
    font-size: 1.1em;
    font-weight: 600;
    color: #4092cc;
}

.flight-card-home__route {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.flight-card-home__airport {
    text-align: center;
}

.flight-card-home__airport-code {
    font-size: 1.8em;
    font-weight: 600;
    color: #2c3e50;
}

.flight-card-home__airport-label {
    font-size: 0.8em;
    color: #94a3b8;
    margin-top: 4px;
}

.flight-card-home__flight-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.flight-card-home__line {
    width: 100px;
    height: 2px;
    background: #cbd5e1;
    position: relative;
    margin: 8px 0;
}

.flight-card-home__plane {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
}

.flight-card-home__duration {
    font-size: 0.9em;
    color: #4092cc;
    font-weight: 600;
    margin-top: 4px;
}

.flight-card-home__details {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}

.flight-card-home__detail-item {
    text-align: center;
}

.flight-card-home__detail-label {
    font-size: 0.8em;
    color: #94a3b8;
    margin-bottom: 4px;
}

.flight-card-home__detail-value {
    font-weight: 600;
    color: #2c3e50;
}

.fly-button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.fly-button:hover {
    background-color: #218838;
    transform: translateY(-1px);
}

/* Airline Summary Boxes */
.airline-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.2s ease;
}

.airline-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.airline-header img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

/* ================================================
   DARK MODE
   ================================================ */

/* Base Dark Mode Colors */
body.dark-mode {
    background-color: #1a1a1c;
    color: #e5e5e7;
}

body.dark-mode .content-wrapper {
    background-color: #1a1a1c;
}

/* Form Container */
body.dark-mode .form-container h2 {
    color: #5ab0e8;
}

body.dark-mode #flight-filter-form {
    background-color: #2c2c2e;
    border-color: #48484a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Route Type Toggle */
body.dark-mode .route-type-toggle {
    background: #3a3a3c;
}

body.dark-mode .route-type-btn {
    color: #e5e5e7;
}

body.dark-mode .route-type-btn:hover:not(.selected) {
    color: #5ab0e8;
}

body.dark-mode .route-type-btn.selected {
    background: #4092cc;
    color: #fff;
}

/* Labels */
body.dark-mode .airline-select-label,
body.dark-mode .form-group label,
body.dark-mode .slider-group label {
    color: #e5e5e7;
}

/* Search Box */
body.dark-mode #airline-search {
    background: #3a3a3c;
    border-color: #48484a;
    color: #e5e5e7;
}

body.dark-mode #airline-search::placeholder {
    color: #a0a0a0;
}

/* Airline Logo Grid */
body.dark-mode #airline-logo-grid {
    background: #3a3a3c;
    border-color: #48484a;
}

/* DO NOT change airline logos - keep them as-is */

/* Aircraft Grid */
body.dark-mode #aircraft-grid {
    background: #3a3a3c;
    border-color: #48484a;
}

body.dark-mode .aircraft-box {
    background-color: #2c2c2e;
    border-color: #48484a;
    color: #e5e5e7;
}

body.dark-mode .aircraft-box:hover:not(.selected) {
    border-color: #5ab0e8;
    color: #5ab0e8;
}

body.dark-mode .aircraft-box.selected {
    background-color: #4092cc !important;
    color: white !important;
    border-color: #4092cc !important;
}

/* Form Inputs */
body.dark-mode .form-group select,
body.dark-mode .form-group input[type="text"],
body.dark-mode .form-group input[type="number"],
body.dark-mode .form-group input[type="time"] {
    background: #3a3a3c;
    border-color: #48484a;
    color: #e5e5e7;
}

body.dark-mode .form-group input::placeholder {
    color: #a0a0a0;
}

/* Sliders */
body.dark-mode .slider-labels {
    color: #a0a0a0;
}

body.dark-mode .slider-value {
    color: #5ab0e8;
}

/* Flight Cards */
body.dark-mode .flight-card-home {
    background: #2c2c2e;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body.dark-mode .flight-card-home__airport-code,
body.dark-mode .flight-card-home__detail-value {
    color: #e5e5e7;
}

body.dark-mode .flight-card-home__airport-label,
body.dark-mode .flight-card-home__detail-label {
    color: #a0a0a0;
}

body.dark-mode .flight-card-home__flight-number {
    color: #5ab0e8;
}

body.dark-mode .flight-card-home__duration {
    color: #5ab0e8;
}

body.dark-mode .flight-card-home__line {
    background: #48484a;
}

/* DO NOT change logo containers - keep white background */

/* Messages */
body.dark-mode .message-text {
    color: #a0a0a0;
}

body.dark-mode .message-text.error {
    color: #ff6b6b;
}

/* Airline Headers */
body.dark-mode .airline-header {
    background: #2c2c2e;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Footer */
body.dark-mode .footer {
    background-color: #2c2c2e;
    border-top-color: #48484a;
}

body.dark-mode .version-number {
    color: #a0a0a0;
}

/* Leaflet Popups */
body.dark-mode .leaflet-popup-content-wrapper {
    background: #2c2c2e;
    color: #e5e5e7;
}

body.dark-mode .leaflet-popup-tip {
    background: #2c2c2e;
}