﻿.components-reconnect-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.components-reconnect-dialog {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    text-align: center;
}

.components-rejoining-animation,
.components-reconnect-slideUp {
    animation: none !important;
    height: auto !important;
    width: auto !important;
    top: auto !important;
    left: auto !important;
}

/* a11y: نمایش واضح فوکوس کیبورد */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible, [role="button"]:focus-visible, [role="link"]:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* a11y: احترام به تنظیم کاهش حرکت سیستم‌عامل */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Instant feedback for result-item arrows (see scripts/instant-feedback.js): flip immediately on click,
   before the Blazor server round-trip finishes. Removed automatically when Blazor re-renders the arrow. */
.flight-iniranitem-arrow[data-pending]:not(.active-more-detail),
.flight-item-arrow[data-pending]:not(.active-more-detail),
.train-item-arrow[data-pending]:not(.active-more-detail) { transform: rotate(180deg); }
.flight-iniranitem-arrow.active-more-detail[data-pending],
.flight-item-arrow.active-more-detail[data-pending],
.train-item-arrow.active-more-detail[data-pending] { transform: rotate(0deg); }
.flight-iniranitem-arrow, .flight-item-arrow, .train-item-arrow { touch-action: manipulation; transition: transform .15s ease-in-out; }

/* ───────── CLS (layout shift) hardening ───────── */
/* font stack: metric-matched fallback while IRANSansX loads (see font.css) */
body { font-family: IRANSansX, "IRANSansX-Fallback", Tahoma, sans-serif; }

/* arrow icon glyphs: fixed box so the late-loading icon font can never change the arrow size */
.icon-angle-small-down, .icon-angle-small-up, .icon-angle-small-left, .icon-angle-small-right { display: inline-block; width: 1em; height: 1em; }
.flight-iniranitem-arrow, .flight-item-arrow, .train-item-arrow { box-sizing: border-box; flex: 0 0 auto; }

/* Flight row height derived from CSS (flight-pages.css), no DevTools measurement yet:
   desktop = border 2 + padding 16 + tallest cell 50 (logo max-width 50, 1:1) = 68px; mobile (<=768px) = 2 + 16 + logo 36 = 54px.
   If a real row measures differently, change the two numbers below. */
/*
  TODO: Tune skeleton heights to match real row height exactly.
  How to measure:
  1. Open DevTools on a live flight results page.
  2. Inspect a fully loaded flight item row.
  3. Check its computed height (e.g., 142px).
  4. Update the min-height values below to match that exact number.
  (Do the same for a train row, and for the mobile breakpoint.)
*/
.cls-skeleton-flight { min-height: 68px; }
.cls-skeleton-train { min-height: 130px; }
@media (max-width: 768px) {
    .cls-skeleton-flight { min-height: 54px; }
    .cls-skeleton-train { min-height: 170px; }
}

/* result images: reserve their box even before the bitmap arrives */
.airline-logo-img { aspect-ratio: 1 / 1; object-fit: contain; }
.train-item-logo { min-height: 40px; }
.hotelnw-itm-img img { aspect-ratio: 3 / 2; object-fit: cover; }

/* banner placeholder: shown ONLY while banner data is still loading (components pass IsLoading); with no banner the area collapses */
.cls-banner-skeleton { min-height: 300px; border-radius: 8px; background: linear-gradient(90deg, #eef1f5 25%, #e1e5ea 37%, #eef1f5 63%); background-size: 400% 100%; animation: cls-shimmer 1.4s ease infinite; }
@keyframes cls-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Captcha: fixed box + scaled image => zero layout shift whatever the real image size is.
   Flight captcha is generated server-side at 100x36; the Raja (train) captcha size is unknown, so the box is 150x50. */
.cls-captcha-box { width: 150px; max-width: 100%; aspect-ratio: 150 / 50; overflow: hidden; }
.cls-captcha-box--flight { width: 100px; aspect-ratio: 100 / 36; }
.cls-captcha-box img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* Reserve / Buy button instant feedback (see scripts/instant-feedback.js).
   Shown on click, before the Blazor server round-trip; removed when Blazor re-renders the button (e.g. adds its own "loading" class). */
.iniranitem-cta[data-pending], .flight-item-btn[data-pending], .train-item-btn[data-pending], .button-btn[data-pending], #btnReserve[data-pending] {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
    animation: cls-btn-pulse 1s ease-in-out infinite; /* fallback: visible even if the spinner has no contrast */
}
.iniranitem-cta[data-pending]::after, .flight-item-btn[data-pending]::after, .train-item-btn[data-pending]::after, .button-btn[data-pending]::after, #btnReserve[data-pending]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor; /* follows the button text colour: visible on light and dark buttons */
    border-top-color: transparent;
    border-radius: 50%;
    animation: cls-btn-spin 0.6s linear infinite;
}
@keyframes cls-btn-spin { to { transform: rotate(360deg); } }
@keyframes cls-btn-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 0.4; } }

/* Flight results: reserve the list area and keep the row cells stable when late content arrives */
.flight-content { min-height: 300px; } /* ~3 skeleton rows (3 x (68 + 10 margin)) + spinner */
.flight-iniranitem-price { min-height: 1.4em; }
@media (min-width: 769px) {
    .flight-iniranitem-class-num, .flight-iniranitem-free-fl { min-height: 48px; justify-content: center; }
}

/* ───────── Mobile pickers: location list (origin/destination) + calendar modal ─────────
   Root causes found in cheap-airplane-ticket.css / calendar.css:
   1. z-index: calendar 50 and location list 501 sat BELOW the sticky header (1000), so they were covered/clipped.
   2. height: 100% / calc(100vh - 140px): 100vh is taller than the visible area on mobile browsers (address bar),
      so the bottom of the list/calendar was cut off.
   3. location list: .listchn-ct-cont had max-height:100% inside a column that also holds the search head -> last items unreachable.
   Page stylesheets load after main.css, hence !important (scoped to these selectors + media queries only). */
@media (max-width: 550px) {
    .listchn.active {
        position: fixed !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100vh !important;   /* fallback for old browsers */
        height: 100dvh !important;
        z-index: 9999 !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .listchn.active .listchn-ct { height: 100% !important; min-width: 0 !important; }
    .listchn.active .listchn-ct-cont {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
@media (min-width: 551px) and (max-width: 768px) {
    .listchn.active { max-width: calc(100vw - 16px); z-index: 9999 !important; }
    .listchn.active .listchn-ct { min-width: 0 !important; }
}
@media (max-width: 768px) {
    .calendarMod {
        inset: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 9999 !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .calendarMod .calendarBackdrop { inset: 0; height: 100vh; height: 100dvh; }
    .calendarMod-p { height: 100vh !important; height: 100dvh !important; max-height: 100dvh; }
    /* .calendarMod-content-data (the scrolling months) is no longer a fixed calc(100dvh - 140px):
       calendar.scss lays the modal out as header + arrows + a scroll area that fills the rest,
       so the last month is never cut off when the header wraps to more lines. */
}
