@use "../../../styles/variables" as vars;
@use "../../../styles/fonts" as fonts;
@use "../../../styles/colors" as colors;
@use "../../../styles/screen" as screen;
@use "../../../styles/shadows" as shadows;

.flights-map-start-page {
  section.frame {
    padding: 0;
    overflow: hidden;
  }

  .page-title {
    width: auto;
    display: inline-block;
    max-width: 100%;
    white-space: normal !important;
  }

  h1.text--white {
    @include fonts.font-overflow();

    @include screen.smTablet {
      font-size: fonts.$font-size-xxxl--tablet;
      margin-bottom: vars.$space-m + vars.$space-s;
      overflow: visible;
      white-space: normal;
    }

    @include screen.mobile {
      font-size: fonts.$font-size-xxxl--mobile;
      margin-bottom: vars.$space-m + vars.$space-s;
      margin-top: vars.$space-m;
      overflow: visible;
      white-space: normal;
    }
  }

  .flights-map-start {
    &__map-wrapper {
      position: relative;
      min-height: 800px;
    }

    &__map {
      width: 100%;
      height: 800px;
    }

    &__spinner,
    &__loader,
    &__error {
      padding: vars.$space-xl;
      text-align: center;
      color: colors.$light-gray;
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 200px;
    }

    &__error {
      color: colors.$red;
    }
  }

  // Mirrors Angular `no-directions-sheet.component.scss` — a translucent
  // grey overlay over the map with a white centered info card. Surfaced
  // when the API returns no routes for the current filter selection.
  .no-directions-sheet {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(180, 180, 180, 0.302);
    z-index: 1000;
    pointer-events: all;
  }

  .no-directions-card {
    background: colors.$white;
    padding: 16px 18px;
    border-radius: 5px;
    max-width: 520px;
    width: min(520px, 100%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(0, 0, 0, 0.08);

    p {
      margin: 0;
      font-size: fonts.$font-size-m;
      line-height: 1.4;
      color: rgba(0, 0, 0, 0.78);
      text-align: center;
    }
  }

  // Mirrors Angular `loader-sheet.component.scss` 1:1: 60×60 ring loader
  // in brand blue ($extra-blue/#2b62ab), a rotating half-mask for the
  // animated arc, and a plane glyph in the center.
  .page-loader__loader {
    position: relative;
    width: 60px;
    height: 60px;
    color: #2b62ab;

    .loader-circle {
      position: absolute;
      inset: 0;
      margin: 0;
      width: 60px;
      height: 60px;
      border-radius: 50%;
      box-shadow: inset 0 0 0 2px currentColor;
    }

    .loader-line-mask {
      position: absolute;
      inset: 0;
      width: 30px;
      height: 60px;
      margin: 0;
      overflow: hidden;
      transform-origin: 30px 30px;
      animation: flights-map-rotate 1.2s infinite linear;

      .loader-line {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
      }
    }

    svg {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }

    @keyframes flights-map-rotate {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
  }

  // Mirrors Angular `loader-sheet` host: translucent overlay that
  // covers the map container while the API request is in-flight.
  .loading-sheet {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(180, 180, 180, 0.302);
    z-index: 1000;
    pointer-events: all;
  }
}

// Filter panel styling for content-left column
.flights-map-filter {
  @include shadows.box-shadow-small;
  background-color: colors.$white;
  border-radius: vars.$border-radius;
  padding: vars.$space-xl;
  display: flex;
  flex-direction: column;
  // Match OnlineBoard + Schedule filter row gap ($space-l = 15px) — Angular's
  // `.filter-content` uses $space-l everywhere.
  gap: vars.$space-l;

  .flights-map-filter-header {
    padding: vars.$space-m 0;

    h3 {
      margin: 0;
    }

    // TZ §4.1.24.2 R7: mobile version must not show the filter label
    // "Найдите свой маршрут". Desktop/tablet retain it.
    @include screen.mobile {
      display: none;
    }
  }

  &__field {
    display: flex;
    flex-direction: column;
    gap: vars.$space-s;

    label {
      @include fonts.font-small(colors.$gray);
      margin-bottom: vars.$label-margin-bottom;
    }

    input[type="text"],
    input[type="date"] {
      @include shadows.control-border-shadow();
      height: vars.$standard-button-height;
      padding: 0 vars.$space-l;
      padding-left: vars.$space-m !important;
      font-size: fonts.$font-size-l;
      font-weight: fonts.$font-regular;
      color: colors.$text-color;
      width: 100%;
      transition-duration: 0.2s;
      @include fonts.font-overflow();

      &:focus {
        outline: none;
        border-color: colors.$blue-light;
        box-shadow: 0 0 0 0.2em colors.$focus-shadow;
      }
    }
  }

  // Swap-cities button moved to shared `SwapCityButton` component —
  // classes `.change-container` + `.button-change` are now global.

  &__info {
    padding: vars.$space-s 0;

    p {
      @include fonts.font-small(colors.$gray);
      line-height: 1.5;
      margin: 0;
    }
  }

  &__title {
    font-size: fonts.$font-size-xl;
    font-weight: fonts.$font-bold;
    color: colors.$text-color;
    margin: 0 0 vars.$space-s;
  }

  &__toggles {
    display: flex;
    flex-direction: column;
    gap: vars.$space-m;
    padding: vars.$space-s 0;
  }

  // Visual toggle switch matching Angular's p-inputswitch. Hides the
  // native checkbox and renders a pill + sliding knob via <span>.
  &__toggle {
    display: flex;
    align-items: center;
    gap: vars.$space-m;
    cursor: pointer;
    @include fonts.font-small(colors.$gray);

    input[type="checkbox"] {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
  }

  // Track dimensions mirror Angular `toggle-switch` (42×24 with a 20px
  // thumb). Keeping the same geometry avoids a visible size mismatch
  // against the Angular reference in the parity screenshots.
  &__switch {
    display: inline-block;
    width: 42px;
    height: 24px;
    background: colors.$border;
    border-radius: 24px;
    position: relative;
    transition: background-color 0.2s ease;
    flex-shrink: 0;

    &::before {
      content: "";
      position: absolute;
      top: 2px;
      left: 2px;
      width: 20px;
      height: 20px;
      background: colors.$white;
      border-radius: 50%;
      transition: transform 0.2s ease;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    }
  }

  input[type="checkbox"]:checked + &__switch {
    background: colors.$blue;

    &::before {
      transform: translateX(18px);
    }
  }

  &__toggle--disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none;
  }
}

// PrimeReact Calendar trigger inside the map filter — styling (background
// icon, no border, no seam) comes from shared `styles/_prime-calendar.scss`.

// Leaflet city tooltips: text-only with white text-shadow halo, matching
// Angular's _leaflet-popup.scss treatment.
.leaflet-tooltip.city-label {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
  font-family: 'Inter', 'Roboto', Arial, sans-serif;
  color: colors.$text-color;
  font-size: fonts.$font-size-s;
  font-weight: fonts.$font-medium;
  letter-spacing: 1px;
  text-shadow:
    -1px 0 rgba(255, 255, 255, 0.53),
    1px 0 rgba(255, 255, 255, 0.53),
    0 1px rgba(255, 255, 255, 0.53),
    0 -1px rgba(255, 255, 255, 0.53);

  &::before { display: none; }
}
