/* ═══════════════════════════════════════════════════════════════
   Trip Trade Simulator — shared styles
   Used by TripTrade_Simulator_Component and its sub-components.
   Reference via:
     <link href="_content/CMTResources.Shared/css/trip-trade-simulator.css"
           rel="stylesheet" />
   ═══════════════════════════════════════════════════════════════ */

.simulator-container {
    max-width: 1200px;
    margin: 0 auto;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 16px;
}

.header-section {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--mud-palette-divider);
}

/* Bootstrap's .text-muted is a fixed gray (#6c757d) that washes out on dark surfaces —
   follow the active theme instead. Opacity is avoided: it multiplies against whatever is
   behind it, so the same rule reads differently on each surface. */
.text-muted {
    color: var(--mud-palette-text-secondary) !important;
}

/* ── Filter toolbar ─────────────────────────────────────────── */
.trip-filters-toolbar {
    padding: 0 4px;
}

.trip-filters-search {
    min-width: 220px;
    flex: 1 1 220px;
}

.trip-filters-sort {
    min-width: 170px;
    flex: 0 1 190px;
}

/* text-secondary, not text-disabled: PaletteDark.TextDisabled is rgba(255,255,255,0.2),
   which measures 1.9:1 — too faint for a count the user is meant to read. */
.showing-past {
    color: var(--mud-palette-text-secondary);
}

/* ── Filter chip row ────────────────────────────────────────── */
.filter-chips-row {
    padding: 0 4px;
}

/* Shared chip shape. Each family sets only its hue below, via --chip-hue, so all of them
   track the active MudBlazor palette instead of carrying baked-in light-mode hex.

   Text is always --mud-palette-text-primary, never the hue and never white. Both of those
   assume a fixed luminance relationship that does not hold across the three themes: the
   hue as text fails in Dark (Primary #1040C1 on a dark tint measures 1.4:1) and white on
   a solid hue fails in Cockpit (white on EFIS green #16E07E measures 1.8:1). Carrying the
   hue in the border and the background tint instead keeps the colour coding while the
   text stays on the theme's own guaranteed contrast pair. */
.filter-chip-all,
.filter-chip-domicile,
.filter-chip-day,
.filter-chip-premium {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 2px solid color-mix(in srgb, var(--chip-hue) 55%, var(--mud-palette-surface));
    background: color-mix(in srgb, var(--chip-hue) 14%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

    .filter-chip-all:hover,
    .filter-chip-domicile:hover,
    .filter-chip-day:hover,
    .filter-chip-premium:hover {
        background: color-mix(in srgb, var(--chip-hue) 26%, var(--mud-palette-surface));
    }

    .filter-chip-all:focus-visible,
    .filter-chip-domicile:focus-visible,
    .filter-chip-day:focus-visible,
    .filter-chip-premium:focus-visible {
        outline: 2px solid var(--mud-palette-primary);
        outline-offset: 2px;
    }

    /* Selected: stronger tint plus a full-strength border, not a solid fill. */
    .filter-chip-all.filter-chip-active,
    .filter-chip-domicile.filter-chip-active,
    .filter-chip-day.filter-chip-active,
    .filter-chip-premium.filter-chip-active {
        background: color-mix(in srgb, var(--chip-hue) 38%, var(--mud-palette-surface));
        border-color: var(--chip-hue);
        color: var(--mud-palette-text-primary);
        font-weight: 700;
    }

    .filter-chip-all .filter-chip-badge,
    .filter-chip-domicile .filter-chip-badge,
    .filter-chip-day .filter-chip-badge,
    .filter-chip-premium .filter-chip-badge {
        background: color-mix(in srgb, var(--chip-hue) 42%, var(--mud-palette-surface));
        color: var(--mud-palette-text-primary);
    }

    /* 48%, not higher: on Cockpit's neon green a 60% tint pulled the badge to 3.3:1. */
    .filter-chip-all.filter-chip-active .filter-chip-badge,
    .filter-chip-domicile.filter-chip-active .filter-chip-badge,
    .filter-chip-day.filter-chip-active .filter-chip-badge,
    .filter-chip-premium.filter-chip-active .filter-chip-badge {
        background: color-mix(in srgb, var(--chip-hue) 48%, var(--mud-palette-surface));
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chip-hue) 70%, transparent);
    }

/* Info, not Secondary: PaletteDark.Secondary is #0d1f33 — a near-black navy used as the
   alerts header background, not an accent. As a chip hue it disappears in dark mode. */
.filter-chip-all {
    --chip-hue: var(--mud-palette-info);
}

.filter-chip-domicile {
    --chip-hue: var(--mud-palette-primary);
}

.filter-chip-day {
    --chip-hue: var(--mud-palette-success);
}

.filter-chip-premium {
    --chip-hue: var(--mud-palette-warning);
}

.filter-chip-text {
    line-height: 1;
}

.filter-chip-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

/* ── Date block ─────────────────────────────────────────────── */
.date-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--mud-palette-dark);
    color: var(--mud-palette-dark-text);
    line-height: 1.1;
}

.date-block-past {
    opacity: 0.5;
}

.date-day-name {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.date-day-number {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
}

.date-month {
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--mud-palette-warning);
}

/* ── Trip row ───────────────────────────────────────────────── */
.trip-row {
    border-left: 4px solid transparent;
    transition: border-color 0.2s, background-color 0.2s;
    margin-bottom: 4px;
}

    .trip-row:hover {
        background-color: var(--mud-palette-action-default-hover);
    }

.trip-row-selected {
    border-left-color: var(--mud-palette-primary) !important;
}

.trip-row-partial {
    border-left-color: var(--mud-palette-info) !important;
}

.trip-row-past {
    opacity: 0.6;
}

.trip-row-legal-blocked {
    opacity: 0.5;
    background-color: var(--mud-palette-background-grey) !important;
}

.trip-header-row:hover {
    background-color: var(--mud-palette-action-default-hover);
}

/* ── Trip summary layout ────────────────────────────────────── */
.trip-date-range {
    font-size: 0.88rem;
    color: var(--mud-palette-text-primary);
    line-height: 1.4;
}

.trip-meta-row {
    margin-top: 2px;
}

.trip-meta-label {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

    .trip-meta-label strong {
        font-weight: 700;
        color: var(--mud-palette-text-primary);
    }

.trip-meta-sep {
    font-size: 0.65rem;
    color: var(--mud-palette-text-secondary);
    margin: 0 1px;
}

/* FDP max the acclimation lookup could not resolve exactly — flagged, not silently exact.
   Text is text-primary, not warning-text: MudBlazor's *-text vars are white, which is
   unreadable on the pale amber tint this sits on in light mode. */
.fdp-estimated {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0 5px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--mud-palette-warning) 20%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
}

    .fdp-estimated .mud-icon-root {
        color: var(--mud-palette-warning);
    }

.duty-summary-checkinout {
    display: none;
}

.trip-day-label {
    font-size: 0.72rem;
    font-weight: 600;
}

.trip-map-btn {
    border-radius: 16px;
    padding: 2px 10px;
    font-size: 0.7rem;
    min-width: auto;
    text-transform: none;
}

.trip-summary-text {
    font-family: monospace;
    font-size: 0.85rem;
}

/* ── Flight details table ───────────────────────────────────── */
.flight-details-container {
    background: var(--mud-palette-background-grey);
}

.flight-detail-table th {
    font-size: 0.75rem;
    padding: 4px 8px !important;
    background: var(--mud-palette-dark);
    color: var(--mud-palette-dark-text);
}

.flight-detail-table td {
    padding: 4px 8px !important;
    font-size: 0.8rem;
    font-family: monospace;
}

.flight-row-hotel {
    background-color: var(--mud-palette-background-grey);
}

.hotel-row-text {
    font-style: italic;
    opacity: 0.7;
}

.flight-row-selected {
    background-color: var(--mud-palette-success-lighten) !important;
}

.flight-row-legal-blocked {
    opacity: 0.45;
    background-color: var(--mud-palette-background-grey) !important;
}

    .flight-row-legal-blocked td {
        color: var(--mud-palette-text-disabled) !important;
    }

.flight-row-schedule-blocked {
    background-color: color-mix(in srgb, var(--mud-palette-error) 15%, transparent) !important;
}

    .flight-row-schedule-blocked td {
        color: var(--mud-palette-text-secondary) !important;
    }

/* The 10-column leg table does not fit a phone; scroll is the safety net under the
   column hiding in the responsive block below. */
.flight-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Per-flight validation rows (green / yellow / red) ────── */
.flight-row-legal {
    background-color: rgba(76, 175, 80, 0.08);
}

.flight-row-warning {
    background-color: rgba(255, 152, 0, 0.10);
}

.flight-row-error {
    background-color: rgba(244, 67, 54, 0.10);
}

.flight-reason-warning td {
    background-color: rgba(255, 152, 0, 0.05);
    border-top: none;
}

.flight-reason-error td {
    background-color: rgba(244, 67, 54, 0.05);
    border-top: none;
}

.per-flight-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.duty-summary-row td {
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-divider);
}

/* ── Selection summary ──────────────────────────────────────── */
.selection-summary {
    border-left: 4px solid var(--mud-palette-primary);
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-left: 4px solid var(--mud-palette-primary);
}

/* ── Impact grid ────────────────────────────────────────────── */
.impact-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px 0;
}

.impact-item {
    text-align: center;
    padding: 8px 4px;
    border-radius: 8px;
    background: var(--mud-palette-background-grey);
}

/* ── Swap dialog trip rows ──────────────────────────────────── */
.swap-trip-row {
    border-left: 4px solid transparent;
    transition: all 0.2s;
    margin-bottom: 4px;
}

    .swap-trip-row:hover:not(.swap-trip-past) {
        background-color: var(--mud-palette-action-default-hover);
        border-left-color: var(--mud-palette-warning-lighten);
    }

.swap-trip-selected {
    border-left-color: var(--mud-palette-warning) !important;
    background-color: var(--mud-palette-warning-lighten);
}

.swap-trip-past {
    opacity: 0.5;
    background-color: var(--mud-palette-grey-lighten-4);
}

/* ── Blocked schedule entries (UMTG, SIM, PC etc.) ──────────── */
.swap-blocked-entry {
    border-left: 4px solid var(--mud-palette-text-disabled);
    opacity: 0.55;
    background-color: var(--mud-palette-background-grey);
    margin-bottom: 4px;
}

.swap-blocked-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Overnight display ──────────────────────────────────────── */
.overnight-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    margin: 4px 0;
    border-radius: 6px;
    background: var(--mud-palette-background-grey);
    border: 1px dashed var(--mud-palette-lines-default);
}

.overnight-icon {
    color: var(--mud-palette-info);
}

.overnight-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
    letter-spacing: 0.02em;
}

/* ── Crew card ──────────────────────────────────────────────── */
.crew-card {
    text-align: center;
    min-height: 160px;
}

/* ── Calendar grid ──────────────────────────────────────────── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-header {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 6px 2px;
    background: var(--mud-palette-dark);
    color: var(--mud-palette-dark-text);
    text-transform: uppercase;
}

.calendar-cell {
    min-height: 80px;
    padding: 4px;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
    vertical-align: top;
    overflow: hidden;
}

.calendar-cell-outside {
    opacity: 0.4;
    background: var(--mud-palette-background-grey);
}

/* Tint plus a full-strength border, not --mud-palette-primary-lighten as a fill: MudBlazor's
   "lighten" of a saturated primary is still saturated, so the day number landed at 1.5:1 in
   light and 1.3:1 in cockpit. */
.calendar-cell-today {
    border: 2px solid var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 18%, var(--mud-palette-surface));
}

.calendar-cell-blocked {
    background-color: color-mix(in srgb, var(--mud-palette-error) 15%, transparent);
}

.calendar-day-num {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--mud-palette-text-primary);
}

/* Trip-length colours are classes rather than inline hex so a theme can restyle them.
   d1..d5 are 1-day through 5-day trips; anything longer falls back to the base rule.

   Tinted fill with theme text, not a solid fill with white text: MudBlazor's *-text vars
   are all white, and Cockpit's Success (#18E884) and Warning (#FFB300) are bright enough
   that white on them lands around 1.9:1. A tint over the surface keeps the day-length
   coding while the text stays on the theme's own contrast pair. The left bar carries the
   colour at full strength so the coding survives the lower saturation. */
.calendar-event {
    display: flex;
    flex-direction: column;
    padding: 2px 4px;
    margin-bottom: 2px;
    border-radius: 4px;
    border-left: 3px solid var(--event-hue, var(--mud-palette-primary));
    background: color-mix(in srgb, var(--event-hue, var(--mud-palette-primary)) 24%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
    font-size: 0.62rem;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.2s;
    overflow: hidden;
}

    .calendar-event:hover {
        background: color-mix(in srgb, var(--event-hue, var(--mud-palette-primary)) 38%, var(--mud-palette-surface));
    }

    .calendar-event:focus-visible {
        outline: 2px solid var(--mud-palette-primary);
        outline-offset: 1px;
    }

.calendar-event-d1 {
    --event-hue: var(--mud-palette-success);
}

.calendar-event-d2 {
    --event-hue: var(--mud-palette-warning);
}

.calendar-event-d3 {
    --event-hue: var(--mud-palette-info);
}

.calendar-event-d4 {
    --event-hue: var(--mud-palette-error);
}

.calendar-event-d5 {
    --event-hue: var(--mud-palette-secondary);
}

.calendar-event-pairing {
    font-weight: 700;
    font-size: 0.65rem;
}

.calendar-event-time {
    font-size: 0.58rem;
    opacity: 0.9;
}

.calendar-event-info {
    font-size: 0.55rem;
    opacity: 0.85;
}

.calendar-event-cont {
    font-size: 0.58rem;
    font-style: italic;
    opacity: 0.8;
}

.calendar-more {
    font-size: 0.58rem;
    text-align: center;
    color: var(--mud-palette-text-secondary);
    cursor: default;
}

/* ── Cockpit (EFIS) accents ─────────────────────────────────── */
.theme-cockpit .simulator-container {
    border-color: #103A2A;
}

.theme-cockpit .overnight-display {
    border-color: #1c5c3e;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
    .impact-summary-grid {
        grid-template-columns: 1fr;
    }

    .trip-date-range {
        font-size: 0.78rem;
    }

    .trip-meta-label {
        font-size: 0.65rem;
    }

    /* Report/release drop out of the leg table on phones — both are restated on the
       duty-day summary row, which is revealed here, so nothing is actually lost. */
    .col-ci, .col-co {
        display: none;
    }

    .duty-summary-checkinout {
        display: inline;
    }

    .trip-filters-search, .trip-filters-sort {
        flex: 1 1 100%;
        min-width: 0;
    }

    .filter-chip-all, .filter-chip-domicile, .filter-chip-day, .filter-chip-premium {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .filter-chip-badge {
        min-width: 18px;
        height: 18px;
        font-size: 0.65rem;
    }

    .calendar-cell {
        min-height: 50px;
        padding: 2px;
    }

    .calendar-event {
        font-size: 0.55rem;
        padding: 1px 2px;
    }

    .calendar-event-info {
        display: none;
    }

    .overnight-display {
        padding: 4px 8px;
    }

    .overnight-text {
        font-size: 0.7rem;
    }
}
