/* ================== INPUT GROUP / SAVE BUTTON / SAVED ITEMS ================== */
.input-group {
    position: relative;
}

.save-btn {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
    border: none;
    background: none;
    padding: 5px;
    cursor: pointer;
    color: red;
}

.saved-items {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.saved-item-btn {
    position: relative;
    padding: 2px 20px 2px 8px;
    font-size: 0.9em;
}

.saved-item-btn .remove-btn {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0 4px;
    font-size: 0.8em;
    line-height: 1;
    border: none;
    background: rgba(0, 0, 0, 0.2);
    color: white;
    cursor: pointer;
}

/* ================== FORM CONTROLS ================== */
.form-control {
  border-radius: 8px;
  border-color: var(--border-color);
  padding: 0.6rem 0.75rem;
}

.form-control:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* ================== UNIFIED CARD-FORM (QuickFill + Trip Entry) ================== */

/* Smooth visual state transitions on the card */
#trip_entry_card {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Populated state — form has data, ready to submit */
#trip_entry_card.trip-entry-populated {
    border: 2px solid rgba(13, 110, 253, 0.45) !important;
    box-shadow: 0 0 14px rgba(13, 110, 253, 0.12);
}

/* Editing state — updating an existing trip */
#trip_entry_card.trip-entry-editing {
    border: 2px solid rgba(255, 193, 7, 0.6) !important;
    box-shadow: 0 0 14px rgba(255, 193, 7, 0.13);
}

/* QuickFill Wizard bar — retired (controls moved into card header) */

/* Override layout.css which sets flex:1 on the first card-header child —
   in the trip entry card the LEFT group is fixed-width and the RIGHT group grows */
#trip_entry_card .card-header > *:first-child {
    flex: 0 0 auto;
}

/* Right section of the card header — takes all space left of the title group */
.quickfill-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 0;
    min-width: 0;
}

/* Input inside the right section — grows to fill remaining space */
.quickfill-header-input {
    font-family: monospace;
    font-size: 0.8rem;
    flex: 1 1 0;
    min-width: 0;
    width: 0;   /* override Bootstrap width:100% so flex-grow controls the width */
}

/* Lightning icon in the card header title */
.quickfill-header-icon {
    color: var(--bs-warning, #ffc107);
    font-size: 0.9em;
}

/* OCR section inside the card (collapsed on desktop, always-open on mobile) */
.quickfill-ocr-section {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ── Leg box — full-width input area ── */
.trip-entry-leg {
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    padding: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.07);
}

/* ── Floating labels: compatible with form-control-sm inside form-floating ── */
/* Bootstrap 5 form-floating doesn't officially support form-control-sm;     */
/* these overrides restore correct label positioning for compact inputs.      */
.trip-entry-leg .form-floating > .form-control-sm,
.trip-entry-leg .form-floating > .form-select-sm {
    height: calc(3rem + 2px);
    padding-top: 1.5rem;
    padding-bottom: 0.25rem;
}

/* Labels are always in the floated (small, top-left) position.
   No scale() — labels render at full size for readability.
   !important prevents Bootstrap's :focus~label from overriding. */
.trip-entry-leg .form-floating > label {
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary, #6c757d);
    transform: translateY(-0.45rem) !important;
    transform-origin: 0 0 !important;
    opacity: 1 !important;
    transition: none !important;
}

/* Placeholder hint text is always visible (label is at top, not covering it) */
.trip-entry-leg .form-floating > .form-control::placeholder,
.trip-entry-leg .form-floating > .form-control-sm::placeholder {
    color: #9ca3af !important;
    opacity: 1;
}

/* ── Datetime grid: [Dep Date][Dep Time][Duration spans 2 rows]
                    [Arr chip][Arr Time]                        ── */
.trip-entry-datetime-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 0.5rem;
    row-gap: 0.35rem;
    align-items: start;
}

.trip-entry-dep-date  { grid-column: 1; grid-row: 1; }
.trip-entry-dep-time  { grid-column: 2; grid-row: 1; }
.trip-entry-arr-date  { grid-column: 1; grid-row: 2; }
.trip-entry-arr-time  { grid-column: 2; grid-row: 2; }

.trip-entry-duration-cell {
    grid-column: 3;
    grid-row: 1 / span 2;
    display: flex;
    align-items: stretch;
    justify-content: center;
    align-self: stretch;
}

/* ── Arrival date chip — read-only, same height as form-control-sm ── */
.arrival-date-chip {
    height: calc(3rem + 2px);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.035);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    color: var(--text-secondary, #6c757d);
    font-weight: 600;
    cursor: default;
    user-select: none;
    pointer-events: none;
    padding: 0 0.75rem;
    white-space: nowrap;
}

.arrival-date-chip .bi {
    font-size: 0.85rem;
    opacity: 0.65;
    flex-shrink: 0;
}

/* ── Inline badge: Duration (datetime grid) and Type (station grid) ── */
.trip-entry-inline-badge {
    text-align: center;
    padding: 0.45rem 0.65rem;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    min-width: 80px;
    white-space: nowrap;
}

.trip-entry-inline-badge .badge-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    opacity: 0.65;
    margin-bottom: 0.2rem;
}

.trip-entry-inline-badge .badge-value {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary, #333);
}

/* Duration badge fills the full height of its 2-row cell */
.trip-entry-duration-cell .trip-entry-inline-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ── Station grid: [Dep Stn][→][Arr Stn][Type] ── */
.trip-entry-station-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    column-gap: 0.5rem;
    row-gap: 0;
    align-items: start;
}

.trip-station-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* → arrow: pad to visually center with input height */
.station-arrow {
    padding-top: calc((3rem + 2px) / 2 - 0.6em);
    font-size: 1rem;
    line-height: 1;
    align-self: start;
}

.trip-entry-type-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    padding-top: 0;
}

/* ── Station Home / Away badge ── */
.station-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 5px;
    padding: 0.1rem 0.45rem;
    margin-top: 0.2rem;
    width: fit-content;
    transition: opacity 0.15s ease;
}

.station-type-badge.home {
    background-color: rgba(25, 135, 84, 0.1);
    color: #198754;
    border: 1px solid rgba(25, 135, 84, 0.25);
}

.station-type-badge.away {
    background-color: rgba(13, 110, 253, 0.08);
    color: #0d6efd;
    border: 1px solid rgba(13, 110, 253, 0.2);
}

/* ── OCR dynamic tip container ── */
#ocr_tip .alert {
    font-size: 0.875rem;
    border-left-width: 4px;
}

/* ── Mobile overrides for the entry card grids ── */
@media (max-width: 999px) {
    /* Datetime: collapse to 2 columns, Duration goes below as full-width */
    .trip-entry-datetime-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto auto !important;
    }
    .trip-entry-dep-date  { grid-column: 1; grid-row: 1; }
    .trip-entry-dep-time  { grid-column: 2; grid-row: 1; }
    .trip-entry-arr-date  { grid-column: 1; grid-row: 2; }
    .trip-entry-arr-time  { grid-column: 2; grid-row: 2; }
    .trip-entry-duration-cell {
        grid-column: 1 / -1;
        grid-row: 3;
        align-items: stretch;
    }
    .trip-entry-duration-cell .trip-entry-inline-badge {
        flex-direction: row;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.35rem 0.65rem;
    }
    /* Station: collapse to 1 column, Type goes below */
    .trip-entry-station-grid {
        grid-template-columns: 1fr auto 1fr !important;
        grid-template-rows: auto auto !important;
    }
    .trip-entry-type-cell {
        grid-column: 1 / -1;
        grid-row: 2;
        padding-top: 0.35rem;
        justify-content: center;
    }
    .station-arrow {
        padding-top: calc((3rem + 2px) / 2 - 0.6em);
    }
}

/* ================== END UNIFIED CARD-FORM ================== */
