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

.schedule-flight-body {
  display: flex;
  flex-direction: column;
  background: colors.$white;

  &__leg {
    display: grid;
    grid-template-columns:
      30px 80px 120px 70px minmax(45px, 240px) 100px 70px minmax(45px, 240px);
    align-items: center;
    gap: 0 vars.$space-l;
    padding: vars.$space-l vars.$space-xl;
    font-size: fonts.$font-size-m;
    color: colors.$text-color;
  }

  &__leg-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid colors.$border;
    color: colors.$blue;
    font-weight: fonts.$font-medium;
    font-size: 13px;
  }

  &__leg-flight-number {
    color: colors.$text-color;
    font-weight: fonts.$font-medium;
  }

  &__leg-operator {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  &__leg-aircraft {
    font-size: 11px;
    color: colors.$light-gray;
  }

  &__leg-time {
    text-align: left;

    &--arrival {
      text-align: left;
    }
  }

  &__leg-station {
    min-width: 0;

    &--arrival .station {
      align-items: flex-start;
    }
  }

  &__leg-duration {
    align-self: center;
    border-top: 1px solid colors.$border;
    padding-top: 6px;
    margin-top: 6px;
    text-align: center;
    color: colors.$light-gray;
    font-size: 13px;
  }

  // Connection / intermediate-landing box that sits between two leg
  // rows. Mirrors Angular's `transfer-inline-extended` styling: dashed
  // side borders, white centred pill with the icon + caption + ground
  // time + optional station-change pair.
  &__transfer {
    display: flex;
    justify-content: center;
    position: relative;
    background: colors.$white;
    border-left: 1px dashed colors.$border;
    border-right: 1px dashed colors.$border;
    margin-top: -(vars.$space-s2);
    margin-bottom: -(vars.$space-s2);
    font-size: fonts.$font-size-s;
    color: colors.$text-color;

    &::after {
      content: "";
      position: absolute;
      top: 50%;
      width: 100%;
      border-top: 1px dotted colors.$border;
      z-index: 0;
    }
  }

  &__transfer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 vars.$space-m;
    border-right: 1px solid colors.$border;
    align-self: stretch;

    svg {
      width: 20px;
      height: 7px;
      fill: colors.$orange;
    }
  }

  // The pill itself (icon + content) sits above the dotted through-line.
  &__transfer-icon,
  &__transfer-content {
    background: colors.$white;
    z-index: 1;
  }

  &__transfer-content {
    display: flex;
    align-items: center;
    gap: vars.$space-m;
    padding: vars.$space-s vars.$space-m;
    border: 1px solid colors.$border;
    border-left: 0;
    border-radius: 0 vars.$border-radius vars.$border-radius 0;
  }

  &__transfer-icon {
    border: 1px solid colors.$border;
    border-right: 1px solid colors.$border;
    border-radius: vars.$border-radius 0 0 vars.$border-radius;
  }

  &__transfer-caption {
    font-weight: fonts.$font-medium;
  }

  &__transfer-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    img {
      width: 14px;
      height: 14px;
    }
  }

  &__transfer-stations {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: colors.$light-gray;
  }

  &__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: vars.$space-m;
    padding: vars.$space-l vars.$space-xl;
    border-top: 1px dashed colors.$border;
    background: colors.$white;

    .flight-actions {
      display: flex;
      align-items: center;
      gap: vars.$space-m;
    }
  }

  &__spacer {
    flex: 1;
  }

  // Mirrors Angular `share-button.component.scss`: transparent bg, hover
  // fills with $blue-icon (#e3f0fd), matching the share action buttons
  // across the Angular site.
  &__share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: vars.$border-radius;
    cursor: pointer;
    transition: background-color 0.2s ease;

    img { width: 20px; height: 20px; }

    &:hover { background-color: colors.$blue-icon; }
  }

  &__buy-btn {
    background: colors.$orange;
    color: colors.$white;
    border: none;
    border-radius: vars.$border-radius;
    padding: vars.$space-m 24px;
    font-size: fonts.$font-size-m;
    font-weight: fonts.$font-medium;
    cursor: pointer;
    min-width: 150px;
    transition: background-color 0.2s ease;

    &:hover { background: colors.$orange--hover; }
  }

  &__status-btn {
    background: colors.$blue;
    color: colors.$white;
    border: 1px solid colors.$blue;
    border-radius: vars.$border-radius;
    padding: vars.$space-m 24px;
    font-size: fonts.$font-size-m;
    font-weight: fonts.$font-medium;
    cursor: pointer;
    min-width: 150px;
    transition: background-color 0.2s ease;

    &:hover { background: colors.$blue--hover; }
  }

  // §4.1.14.4.6 – Детали рейса: always-visible outline button (white bg,
  // blue border+text), mirrors Angular's secondary CTA style.
  &__details-btn {
    background: colors.$white;
    color: colors.$blue;
    border: 1px solid colors.$blue;
    border-radius: vars.$border-radius;
    padding: vars.$space-m 24px;
    font-size: fonts.$font-size-m;
    font-weight: fonts.$font-medium;
    cursor: pointer;
    min-width: 150px;
    transition: background-color 0.2s ease, color 0.2s ease;

    &:hover {
      background: colors.$blue;
      color: colors.$white;
    }
  }

  // ----- horizontal timeline (route summary) -----------------------------
  &__timeline {
    padding: vars.$space-l vars.$space-xl vars.$space-m;
    border-bottom: 1px solid colors.$border;
    background: colors.$white;
    color: colors.$text-color;
  }

  &__timeline-row {
    display: flex;
    align-items: flex-start;
    gap: vars.$space-l;
    font-size: fonts.$font-size-m;
  }

  &__timeline-leg {
    display: flex;
    align-items: center;
    flex: 1 1 0;
    gap: vars.$space-s;
    min-width: 0;
  }

  &__timeline-time {
    flex-shrink: 0;

    // Shrink the TimeGroup time labels inside the route timeline and
    // each leg row. The default (30px / light) is reserved for the
    // collapsed summary row; inside the expanded body times read about
    // half that — roughly matching Angular's `time-group size="small"`
    // (16px). Apply to the sub-leg time columns as well.
    .time-group__scheduled,
    .time-group__actual {
      font-size: 15px;
      font-weight: fonts.$font-medium;
      line-height: 1.2;
    }
  }

  &__leg-time {
    .time-group__scheduled,
    .time-group__actual {
      font-size: 15px;
      font-weight: fonts.$font-medium;
      line-height: 1.2;
    }
  }

  // The `section` is the space between two timestamps in the route
  // timeline. A single continuous 1px line runs horizontally across its
  // center (via `::before`). The segment label ("1ч. 25мин.") sits
  // ABOVE the line, and the section-number badge ("[1]") sits ON the
  // line — its white background covers the line so the connector looks
  // continuous (matching Angular's `connecting-flight-body` route bar).
  &__timeline-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
    min-width: 60px;
    color: colors.$light-gray;
    font-size: 13px;
    position: relative;
    padding: 0 vars.$space-s;

    &::before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0;
      right: 0;
      border-top: 1px solid colors.$border;
      z-index: 0;
    }
  }

  // The old structural bars are replaced by the section `::before`; keep
  // the elements in the DOM (so TSX doesn't need to change) but hide them.
  &__timeline-bar {
    display: none;
  }

  // [1]/[2] sits centered on the line. Absolute-position it at 50% so
  // the number box vertically aligns with the connector, with its white
  // background hiding the line behind the box.
  &__timeline-section-num {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    padding: 1px 6px;
    border: 1px solid colors.$border;
    border-radius: vars.$border-radius;
    background: colors.$white;
    color: colors.$text-color;
    font-size: fonts.$font-size-s;
    font-weight: fonts.$font-medium;
  }

  // "1ч. 25мин." label sits BELOW the line — reserve top space equal to
  // the number-badge height (~22px) + a gap so the label clears the line.
  &__timeline-section-dur {
    position: relative;
    z-index: 1;
    margin-top: 22px;
    padding: 0 4px;
    background: colors.$white;
    color: colors.$light-gray;
    font-size: fonts.$font-size-s;
    white-space: nowrap;
  }

  &__timeline-transit {
    flex-shrink: 0;
    color: colors.$text-color;
    font-weight: fonts.$font-medium;
    font-size: 13px;
    padding: 0 vars.$space-s;
  }

  &__timeline-stations {
    display: flex;
    justify-content: space-between;
    gap: vars.$space-l;
    margin-top: vars.$space-s;
    font-size: fonts.$font-size-m;
  }

  &__timeline-station {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;

    &:first-child { text-align: left; }
    &:last-child { text-align: right; }
    &:not(:first-child):not(:last-child) { text-align: center; }
  }

  // Angular renders the route-timeline city names at 22px / 300 (light),
  // measured on the live `connecting-flight-body`. Bumps them well above
  // the surrounding 14px body copy so the three-stop diagram reads like
  // a headline.
  &__timeline-station-city {
    color: colors.$text-color;
    font-size: fonts.$font-size-xl2;
    font-weight: fonts.$font-light;
    line-height: 1.2;
  }

  &__timeline-station-terminal {
    color: colors.$light-gray;
    font-size: fonts.$font-size-s;
  }
}
