/* =========================================
   1. VARIABLES (SINGLE SOURCE OF TRUTH)
   ========================================= */
   :root {
    /* Color Palette */
    --bg-page: #202124;
    --bg-card: #303134;
    
    /* Text Colors */
    --text-primary: #E8EAED;
    --text-secondary: #bdc1c6;
    --text-muted: #777;

    /* Borders */
    --border-card: #5f6368;
    --border-card-hover: #8ab4f8;

    /* Accents & UI States */
    --color-accent: #8ab4f8;
    --color-accent-hover: #a3c5f9;
    --color-btn-text: #fff;
    --color-btn-bg: #333;

    /* Status Colors (Weekdays/Prices) */
    --status-green: #81c995;
    --status-yellow: #fdd663;
    --status-blue: #8AB4F8;
    --status-red: #ff4d4f;
    
    /* Spacing & Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 20px;
    --spacing-lg: 40px;
}

/* =========================================
   2. BASE & RESET
   ========================================= */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

/* =========================================
   3. LAYOUT
   ========================================= */
.container {
    max-width: 1000px;
    margin: var(--spacing-lg) auto;
    padding: 0 var(--spacing-md);
    text-align: center;
}

.logo-container {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.site-logo {
    max-width: 400px;
    height: auto;
    display: inline-block;
}

.section-divider {
    border: 0;
    border-top: 1px solid var(--border-card);
    margin: var(--spacing-lg) 0 var(--spacing-md);
}

/* =========================================
   4. HOME TILES
   ========================================= */
.options-container {
    display: flex;
    gap: var(--spacing-lg);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

.options-container a {
    flex: 1 1 100%;
    min-width: 200px;
    display: flex;
}

.content-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    width: 100%;
    min-height: 100px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: border-color 0.2s ease;
}

.content-box:hover {
    border-color: var(--border-card-hover);
}

.content-box h2 {
    margin-top: 0;
    color: var(--color-accent);
}

@media (min-width: 768px) {
    .options-container a:nth-child(1),
    .options-container a:nth-child(2) {
        flex: 0 0 calc(50% - (var(--spacing-lg) / 2));
        max-width: calc(50% - (var(--spacing-lg) / 2));
    }
    .options-container a:nth-child(3) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* =========================================
   5. FORMS & INPUTS
   ========================================= */
.search-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.search-flex .form-group {
    flex: 1 1 0;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    position: relative;
    margin-bottom: 25px;
}

.form-group label {
    margin-bottom: 8px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.form-control {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 1em;
    width: 100%;
    transition: border-color 0.2s, background-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--border-card-hover);
}

/* Django Error Styling */
.form-group .errorlist {
    position: absolute;
    top: 100%;
    left: 0;
    margin: 0;
    padding: 4px 0 0 0;
    list-style: none;
    color: var(--status-red);
    font-size: 0.75rem;
    line-height: 1;
    width: 100%;
    text-align: left;
}

.form-control.is-invalid {
    border-color: var(--status-red);
}

/* Buttons */
.search-flex .form-actions {
    width: 100%;
    margin-top: 5px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    display: inline-block;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--bg-page);
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid transparent;
}

.btn-secondary:hover {
    background-color: var(--border-card);
}

/* =========================================
   6. RESULTS SECTION
   ========================================= */
.results-list {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 15px;
}

.header-container-live {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 20px 0 30px 0;
}

.h3-header-live {
    display: flex;
    gap: 12px;
    font-size: 1.5rem;
    margin-bottom: 5px;
    color: var(--text-primary);
}

/* Legend */
.legend-container {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    font-size: 0.9em;
    color: var(--text-secondary);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.green { background-color: var(--status-green); }
.legend-dot.yellow { background-color: var(--status-yellow); }
.legend-dot.blue { background-color: var(--status-blue); }

/* Deal Card Core */
.deals-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.deal-card {
    --theme-color: #555; /* Default fallback */
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-left: 15px solid var(--theme-color);
    border-radius: var(--radius-lg);
    padding: 15px 25px;
    width: 100%;
    max-width: 1000px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: border-color 0.2s;
}

.deal-card:hover {
    border-color: var(--theme-color);
}

.deal-card.friday { --theme-color: var(--status-green); }
.deal-card.thursday { --theme-color: var(--status-yellow); }
.deal-card.saturday { --theme-color: var(--status-blue); }

/* Card Content: Route & Price */
.deal-info {
    display: flex;
    /* flex: 0 0 300px;  */
    flex-direction: column;
    align-items: flex-start;
    min-width: 300px;
}

.route {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}

.origin-name, .destination-name {
    font-weight: 400;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.deal-card .price {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--theme-color);
    margin-top: 5px;
}

/* Card Content: Schedule */
.deal-schedule {
    flex: 1;
    min-width: 0;
}

.flight-row {
    display: flex;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 5px;
    gap: 10px;
}

.flight-row .icon {
    margin-top: 2px;
    flex-shrink: 0;
}

.flight-data {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 10px;
    row-gap: 2px;
}

.flight-data .date {
    font-weight: bold;
    color: var(--text-primary);
    white-space: nowrap;
}

.flight-data .time {
    color: #ddd;
    white-space: nowrap;
}

.flight-data .duration { 
    color: var(--text-muted); 
    font-size: 0.85em; 
}

/* Tags & Hints */
.deal-tag {
    font-size: 0.8em;
    margin-top: 4px;
    text-align: left;
}
.deal-tag.warning { color: var(--status-yellow); }
.deal-tag.success { color: var(--status-green); }
.deal-tag.info { color: var(--status-blue); }

.deal-hint, .deal-hint-live {
    color: var(--text-secondary); 
    font-size: 0.8em; 
    font-style: italic; 
    text-align: center;
    line-height: 1.2;
}

.deal-hint-live {
    line-height: 0.8;
    margin-top: 12px;
}

.deal-action {
    text-align: right;
}

.btn-check-deal {
    display: block;
    width: 100%;
    padding: 10px 20px;
    background-color: var(--color-btn-bg);
    color: var(--color-btn-text);
    border: 1px solid #555;
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.btn-check-deal:hover {
    color: #000;
    background-color: var(--theme-color);
}

.btn-check-deal-additional-info {
    display: block;
    font-size: 0.75em;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    margin-top: 5px;
}

.btn-check-deal-additional-info:hover {
    text-decoration: underline;
}

/* =========================================
   7. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 768px) {
    .container {
        padding: 0 40px; 
    }

    .site-logo {
        max-width: 250px;
    }

    .search-flex {
        flex-direction: column;
        gap: 20px;
    }

    .search-flex .form-group {
        width: 100%;
    }

    .search-flex .form-actions {
        flex-direction: column;
    }

    .search-flex .form-actions .btn {
        width: 100%;
    }

    .deal-card {
        flex-direction: column;
        text-align: center;
        padding: 20px 15px;
        align-items: stretch;
    }

    .deal-info, 
    .deal-schedule, 
    .deal-action {
        width: 100%;
        max-width: none;
        align-items: center;
        margin-left: 0 !important;
    }
    
    .route {
        justify-content: center;
    }

    .deal-schedule {
        padding: 15px 0;
        border-top: 1px solid rgba(255,255,255,0.1);
        border-bottom: 1px solid rgba(255,255,255,0.1);
        margin: 10px 0;
    }

    .flight-row {
        justify-content: center;
    }

    .deal-action {
        padding-top: 10px;
    }

    .deal-tag {
        text-align: center;
    }
}

@media (max-width: 600px) {
    .origin-name, .destination-name {
        display: block;
        margin-top: 2px;
    }
}

/* =========================================
   8. UTILITIES & STATES
   ========================================= */
.link-disabled {
    pointer-events: none;
    opacity: 0.5;
    filter: grayscale(100%);
    cursor: default;
    position: relative;
}

.link-disabled::after {
    content: "WKRÓTCE";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-page);
    color: var(--text-primary);
    padding: 5px 10px;
    border: 1px solid var(--border-card);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 10;
}


@media (max-width: 900px) {
    .deal-card {
        flex-direction: column;
        text-align: center;
        padding: 20px 15px;
        align-items: stretch;
    }

    .deal-info, 
    .deal-schedule, 
    .deal-action {
        width: 100%;
        max-width: none;
        align-items: center;
        margin-left: 0 !important;
        flex-basis: auto; 
    }
    
    .route {
        justify-content: center;
    }

    .deal-schedule {
        padding: 15px 0;
        border-top: 1px solid rgba(255,255,255,0.1);
        border-bottom: 1px solid rgba(255,255,255,0.1);
        margin: 15px 0;
    }

    .flight-row {
        justify-content: center;
    }

    .deal-action {
        padding-top: 10px;
    }

    .deal-tag {
        text-align: center;
    }
}