/* Modern Flight Cards - Flighty App Inspired */
#flights-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Scoped box-sizing for flights content only */
#flights-content,
#flights-content *,
#flights-content *::before,
#flights-content *::after {
    box-sizing: border-box;
}

/* Header Styles */
.flights-header {
    margin-bottom: 2rem;
}

.flights-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 1.5rem 0;
    color: var(--md-default-fg-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem; /* This remains, it's internal to stats-block-container */
}

/* New style for the container of the stats grid */
.stats-block-container {
    margin-top: 2rem;    /* Provides space above the stats block */
    margin-bottom: 2rem; /* Provides space below the stats block */
}

.stat-card {
    background: var(--md-default-bg-color);
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--md-default-fg-color--lightest);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    color: var(--md-default-fg-color);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--md-default-fg-color--light);
    margin-top: 0.25rem;
}

/* New styles for stat details */
.stat-details {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--md-default-fg-color--lightest);
}

.airline-logos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.stat-airline-logo {
    max-height: 27px;
    object-fit: contain;
}

.airport-list {
    font-size: 0.8rem;
    color: var(--md-default-fg-color--light);
    line-height: 1.5;
    /* text-align: center; is inherited from .stat-card */
}

/* Section Headers */
.section-header {
    margin: 2rem 0 1rem 0;
}

.section-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--md-default-fg-color--light);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Flight Grid */
.flights-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

/* Past Flights List - Row Based */
.flights-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* Adjusted for tighter, consistent spacing */
}

.flight-row {
    background: var(--md-default-bg-color);
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 12px; /* Slightly less rounded than cards */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
    cursor: pointer;
    /* margin: 0.25rem 0; */ /* Removed to rely on parent's gap property */
}

.flight-row:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.flight-row.upcoming   { border-left: 4px solid #2196f3; }
.flight-row.completed  { border-left: 4px solid #4caf50; /* margin: 0.1rem 0; */  /* Removed to rely on parent's gap property */ }
.flight-row.canceled   { border-left: 4px solid #f44336; opacity: 0.7; }
.flight-row.diverted   { border-left: 4px solid #ff9800; }

.flight-row-collapsed {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem; /* Compact padding */
    gap: 1rem;
}

/* allow flex children to shrink properly */
.flight-row-collapsed > .route-summary,
.flight-row-collapsed > .date-flightno {
    min-width: 0;
}

.airline-logo-small {
    font-size: 1.0rem; /* Smaller logo for rows */
    line-height: 1.0rem;
    display: flex;
    flex-direction: column; /* Stack logo and index vertically */
    align-items: center; /* Center items horizontally */
    justify-content: center; /* Center vertically */
    width: 1.95rem; /* Give it a fixed width to align content in other columns */
    margin-top: 0.4rem;
}

.flight-index {
    font-size: 0.65rem;
    color: var(--md-default-fg-color--light);
    margin-top: 0.25rem;
    line-height: 0.75rem;
    opacity: 0.5;
}


/* General style for images (like country flags if they are used as fallback) */
.airline-logo-small img {
    height: 1.2rem; /* Default height for any image, including fallback country flags */
    width: auto;
    max-width: 2.5rem; /* Max width for country flags */
    object-fit: contain;
    vertical-align: middle;
    border-radius: 2px;
    border: 1px solid var(--md-default-fg-color--lightest); /* This border applies to fallback flags */
}

/* Specific style for airline company logos to allow them to be wider */
.airline-logo-small img.airline-company-logo {
    height: 2.0rem; /* Slightly taller for better logo visibility */
    width: auto;    /* Let width adjust based on aspect ratio */
    max-width: 4.5rem; /* Allow airline logos to be wider than flags */
    object-fit: contain; /* Ensure aspect ratio is maintained */
    border: none; /* Remove border for airline company logos */
    /* border-radius can be removed or kept if desired, but border:none makes it less relevant */
}

.route-summary {
    flex-grow: 1;
}

.route-summary .airport-codes {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--md-default-fg-color);
    font-family: 'Roboto Mono', monospace;
}

.route-summary .airport-codes .arrow {
    color: var(--md-default-fg-color--light);
    margin: 0 0.25rem;
}

.route-summary .city-names {
    font-size: 0.8rem;
    color: var(--md-default-fg-color--light);
}

.flight-identifier {
    background-color: var(--md-default-fg-color--lightest); /* A light background for the pill */
    color: var(--md-default-fg-color--dark); /* Darker text for contrast */
    padding: 0.15rem 0.4rem; /* Small padding to create the pill shape */
    border-radius: 0.75rem; /* Rounded corners for the pill */
    font-family: 'Roboto Mono', monospace; /* Monospace font */
    font-size: 0.75rem; /* Slightly smaller font size for the pill */
    margin-right: 0.5rem; /* Space after the pill */
    display: inline-block; /* To allow padding and margin */
    line-height: 1.2; /* Adjust line height for better vertical alignment if needed */
    text-decoration: none; /* Remove underline for links */
}

.mobile-only {
    display: none;
}

.date-flightno {
    text-align: right;
    min-width: 120px; /* Ensure enough space */
}

.flight-date-compact {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--md-default-fg-color);
}

.flight-number-small {
    font-size: 0.8rem;
    color: var(--md-default-fg-color--light);
    font-family: 'Roboto Mono', monospace;
}

.expand-icon {
    font-size: 1rem;
    color: var(--md-default-fg-color--light);
    transition: transform 0.2s ease;
}

.flight-row-expanded-content {
    display: none; /* keep hidden by default */
    border-top: none;
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 8px;
    margin: 0.25rem 1rem 0.75rem; /* top, sides, bottom */
    padding: 0.75rem 1rem; /* uniform padding */
    background: var(--md-default-bg-color);
}

.flight-row.expanded .flight-row-expanded-content {
    display: block;
}

.flight-row-expanded-content .route-section {
    gap: 0.25rem; /* tighter layout */
}

.flight-row-expanded-content .flight-details {
    padding-top: 0.5rem;
    border-top: 1px solid var(--md-default-fg-color--lightest);
}

.flight-row-expanded-content .detail-row {
    /* This is now handled by the base .detail-row style */
    margin-bottom: 0.25rem;
}

/* Optional: slightly smaller font in notes for compactness */
.flight-row-expanded-content .flight-notes {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* Flight Cards */
.flight-card {
    background: var(--md-default-bg-color);
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.flight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.flight-card.upcoming {
    border-left: 4px solid #2196f3;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.05) 0%, transparent 50%);
}

.flight-card.completed {
    border-left: 4px solid #4caf50;
}

.flight-card.canceled {
    border-left: 4px solid #f44336;
    opacity: 0.7;
}

.flight-card.diverted {
    border-left: 4px solid #ff9800;
}

/* Flight Header */
.flight-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.airline-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.airline-flag {
    font-size: 2rem;
    line-height: 1;
}

.airline-details {
    display: flex;
    flex-direction: column;
}

.airline-code {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--md-default-fg-color);
    line-height: 1;
}

.flight-number {
    font-size: 0.9rem;
    color: var(--md-default-fg-color--light);
    font-family: 'Roboto Mono', monospace;
    margin-top: 0.125rem;
}

.flight-date-section {
    text-align: right;
}

.days-until {
    background: #2196f3;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.2;
    text-align: center;
    min-width: 60px;
}

.days-until span {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.9;
}

.flight-date {
    font-size: 0.9rem;
    color: var(--md-default-fg-color--light);
    font-weight: 500;
}

/* Route Section */
.route-section {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.airport-info {
    display: flex;
    flex-direction: column;
}

.airport-info.departure {
    align-items: flex-start;
}

.airport-info.arrival {
    align-items: flex-end;
    text-align: right;
}

.airport-code {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    color: var(--md-default-fg-color);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.airport-name {
    font-size: 0.8rem;
    color: var(--md-default-fg-color--light);
    margin-bottom: 0.5rem;
}

.time-info {
    margin-bottom: 0.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.time-main {
    font-size: 1rem;
    font-weight: 600;
    color: var(--md-default-fg-color);
    font-family: 'Roboto Mono', monospace;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.time-main .date-part {
    opacity: 0.35;
    font-weight: 400;
    font-size: 0.85em;
}

.time-actual {
    font-size: 0.9rem;
    color: #2196f3; /* Keep blue text color */
    font-weight: 500;
    margin-top: 0.125rem;
    background-color: var(--md-default-fg-color--lightest); /* Pilled background like duration-badge */
    padding: 0.15rem 0.5rem; /* Adjust padding for pill shape */
    border-radius: 12px; /* Rounded corners like duration-badge */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
    justify-content: center;
}

.terminal-gate {
    font-size: 0.75rem;
    color: var(--md-default-fg-color--lighter);
}

/* Flight Path */
.flight-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1rem;
}

.duration-badge {
    background: var(--md-default-fg-color--lightest); /* Subtle grey background */
    color: var(--md-default-fg-color);          /* Standard text color for contrast */
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.duration-badge.duration-is-actual {
    color: #2196f3; /* Blue text color, same as .time-actual */
}

.path-line {
    display: flex;
    align-items: center;
    width: 100px;
    margin: 0.25rem 0;
}

.path-line .line {
    flex: 1;
    height: 2px;
    background: var(--md-default-fg-color--light); /* Visible light grey line */
}

.path-line .plane {
    font-size: 1.2rem;
    margin: 0 0.25rem;
    color: var(--md-default-fg-color--light); /* Visible light grey plane icon */
}

.aircraft-info {
    font-size: 0.75rem;
    color: var(--md-default-fg-color--light); /* Visible light grey text */
    text-align: center;
    margin-top: 0.25rem;
}

/* Flight Details */
.flight-details {
    padding-top: 1rem;
    border-top: 1px solid var(--md-default-fg-color--lightest);
}

.detail-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between; /* Align items to start and end */
    align-items: baseline; /* Use baseline alignment for better vertical text alignment */
    gap: 1rem; /* Add a gap for spacing */
    margin-bottom: 0.5rem;
}

.detail-item {
    font-size: 0.8rem;
    color: var(--md-default-fg-color--light);
}

.detail-item .label {
    font-weight: 600;
    color: var(--md-default-fg-color--lighter);
}

.tail-number {
    font-size: 0.75rem;
    color: var(--md-default-fg-color--lighter);
    font-family: 'Roboto Mono', monospace;
    text-align: right;
}

.flight-notes {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(33, 150, 243, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--md-default-fg-color--light);
}

/* Loading and Error States */
.loading-state, .error-state, .empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--md-default-fg-color--lightest);
    border-top: 4px solid var(--md-primary-fg-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-icon, .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.retry-button {
    background: var(--md-primary-fg-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s ease;
}

.retry-button:hover {
    background: var(--md-primary-fg-color--dark);
}

/* Punctuality indicators for past flights */
.punctuality {
    font-size: 0.85rem;
    font-weight: 600;
    cursor: default;
}
.punctuality-early {
    color: #4caf50;
}
.punctuality-ontime {
    color: #2196f3;
}
.punctuality-late {
    color: #f44336;
}

/* Responsive Design */
@media (max-width: 768px) {
    .flights-header h1 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Keep horizontal layout for expanded view, but make it more compact */
    .route-section {
        gap: 0.5rem;
        align-items: flex-start; /* Align columns to the top */
    }
    
    .airport-code {
        font-size: 1.4rem;
    }

    .airport-name {
        font-size: 0.7rem;
    }

    .flight-path {
        padding: 0 0.25rem;
    }
    
    .path-line {
        width: 50px; /* Shorter horizontal line */
    }
    
    .detail-row {
        justify-content: center;
    }
    
    .tail-number {
        text-align: center;
    }

    /* Keep horizontal layout for collapsed view, but make it more compact */
    .flight-row-collapsed {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .route-summary .airport-codes {
        font-size: 1rem;
    }

    .route-summary .city-names {
        font-size: 0.75rem;
    }

    .route-summary .city-names .city-names-text {
        display: none;
    }

    .date-flightno {
        min-width: 90px;
        text-align: right;
    }

    .flight-date-compact {
        font-size: 0.8rem;
    }

    .flight-date-compact.desktop-only {
        display: none;
    }

    .flight-date-compact.mobile-only {
        display: block;
    }

    .relative-date {
        font-size: 0.7rem;
        display: none;
    }

    /* ensure no element sticks out and use more screen width */
    #flights-content {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Dark Mode */
[data-md-color-scheme="slate"] .flight-card {
    background: var(--md-code-bg-color);
    border-color: var(--md-default-fg-color--lightest);
}

[data-md-color-scheme="slate"] .flight-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

[data-md_color_scheme="slate"] .stat-card {
    background: var(--md-code-bg-color);
    border-color: var(--md-default-fg-color--lightest);
}

[data-md_color_scheme="slate"] .stat-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

[data-md_color_scheme="slate"] .flight-row {
    background: var(--md-code-bg-color);
    border-color: var(--md-default-fg-color--lightest);
}

[data-md_color_scheme="slate"] .flight-row:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.relative-date {
    font-size: 0.75rem;
    color: var(--md-default-fg-color--light);
    margin-top: 0.25rem;
    text-align: right;
}

.relative-date.in-flight-status {
    font-weight: 600;
    /* Fallback color */
    color: #2196f3; /* Changed from --md-primary-fg-color to a visible blue */

    /* 
     * Gradient for the shimmer effect, using background color for the "transparent" part.
     * The 'thinkingShimmer' keyframes are defined in extra.css 
     */
    background-image: linear-gradient(to right,
            #2196f3 40%,
            var(--md-default-bg-color) 50%,
            #2196f3 60%
        );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: thinkingShimmer 1.5s infinite linear;
}

