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

// Schedule-parity sidebar: the OnlineBoard filter's city/airport selector
// now uses the same visual language as `ScheduleFilter`:
// - plain white `section.frame` (no $blue-extra-light tint),
// - flat accordion headers without PrimeNG chrome (no shadows / borders /
//   pill radii), slightly muted label color, chevron on the right,
// - shared `.filter-content`, `.label--filter`, `.input--filter`,
//   `.calendar-input-wrapper`, `.search-button` rules matching Schedule's.

.online-board-filter {
  section.frame {
    background-color: colors.$white;
  }

  // Accordion tab list — kept so the user can toggle between the
  // "Flight number" and "Route" search modes. Visually it's now just
  // a clickable row, not a pill, so it reads like a subtle divider.
  .p-accordion {
    .p-accordion-tab {
      .p-accordion-header {
        border-radius: 0;
        margin: 0;

        a {
          background: transparent;
          border: none;
          color: colors.$blue;
          border-radius: 0;
          padding: vars.$space-m vars.$space-xl;
          height: auto;
          min-height: 0;
          display: flex;
          align-items: center;
          font-weight: fonts.$font-bold;
          font-size: fonts.$font-size-m;
          cursor: pointer;
          text-decoration: none;

          .p-header {
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;
          }
        }

        // The currently-active tab header reads slightly muted (matches
        // Schedule's plain form label) and drops any pill/shadow chrome.
        &.p-highlight {
          a {
            background: transparent;
            border: none;
            color: colors.$gray;
            font-weight: fonts.$font-medium;
          }
          border-bottom: none;
        }
      }

      .p-accordion-content {
        // Schedule uses a flat white panel — no shadow / bottom border.
        box-shadow: none;
        border-bottom: none;
        padding: 0 vars.$space-xl vars.$space-xl;
        background: colors.$white;
      }

      &:first-child .p-accordion-header a {
        border-radius: vars.$border-radius vars.$border-radius 0 0;
      }

      // Thin hairline between tabs, matching Schedule's subtle section
      // divider above `Популярные разделы`.
      &:not(:last-child) .p-accordion-header {
        border-bottom: 1px solid colors.$border;
      }

      &:last-child .p-accordion-content {
        border-radius: 0 0 vars.$border-radius vars.$border-radius;
        border: none;
      }
    }
  }

  // Mirrors Angular `.label--filter` — 12px regular $gray with
  // $label-margin-bottom under the label. Matches ScheduleFilter.
  .label--filter {
    display: block;
    margin-right: vars.$space-xl;
    @include fonts.font-overflow();
    @include fonts.font-small(colors.$gray);
    margin-bottom: vars.$label-margin-bottom;
  }

  .number-input-composite {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    position: relative;

    .prefix {
      display: flex;
      align-items: center;
      flex-shrink: 0;
      @include shadows.control-border-shadow();
      height: vars.$standard-button-height;
      padding: 0 vars.$space-l;
      font-size: fonts.$font-size-l;
      font-weight: fonts.$font-regular;
      color: colors.$gray;
      transition-duration: 0.2s;
      @include fonts.font-overflow();
      border-right: none;
      border-radius: vars.$border-radius 0 0 vars.$border-radius;
    }

    .button-clear {
      // !important needed to override PrimeNG global button resets
      display: flex !important;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      min-width: 32px !important;
      width: 32px !important;
      height: vars.$standard-button-height !important;
      border: 1px solid colors.$border-input;
      border-left: none;
      border-radius: 0 vars.$border-radius vars.$border-radius 0;
      background: colors.$white;
      color: colors.$light-gray;
      font-size: fonts.$font-size-xl;
      line-height: vars.$standard-button-height;
      cursor: pointer;
      padding: 0;
      overflow: visible !important;

      &:hover {
        color: colors.$text-color;
      }
    }

    &.has-error {
      .prefix,
      .input--flight-number {
        border-color: colors.$red;
      }
    }
  }

  .validation-tooltip {
    background-color: colors.$red;
    color: colors.$white;
    padding: vars.$space-s vars.$space-m;
    border-radius: vars.$border-radius;
    font-size: fonts.$font-size-s;
    margin-bottom: vars.$space-s;
    position: relative;
  }

  // Swap-cities button styling moved to `ui/city-autocomplete/SwapCityButton.scss`
  // so every filter sidebar (OnlineBoard / Schedule / FlightsMap) shares the
  // exact same DOM + CSS. The `.svg--change-city` sizing lives globally in
  // `styles/_icons.scss`.

  .wrapper--time-selector {
    // Schedule uses the compact (inline label + value) layout everywhere,
    // so drop the legacy top margin that OnlineBoard inherited.
    display: flex;
    flex-direction: column;
    gap: vars.$space-s2;

    .time-selector__label-value {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
    }

    .time-selector__label {
      font-size: fonts.$font-size-s;
      color: colors.$light-gray;
      margin: 0;
    }

    .time-selector__value {
      font-size: fonts.$font-size-s;
      color: colors.$text-color;
      font-weight: fonts.$font-medium;
      margin: 0;
    }
  }

  .input {
    &--filter {
      display: flex;
      align-items: center;
      @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();

      &:enabled:hover:not(.p-state-error) {
        border-color: colors.$blue-light;
      }

      &:enabled:focus:not(.p-state-error) {
        box-shadow: 0 0 0 0.2em colors.$focus-shadow;
        border-color: colors.$blue-light;
      }
    }

    &--flight-number {
      display: block !important;
      border-left: 1px dotted colors.$border-input;
      border-radius: 0;
      width: auto !important;
      flex: 1 1 0 !important;
      min-width: 0 !important;
    }

    &--calendar {
      padding-right: 32px;
      background-image: url('/assets/img/calendar.svg');
      background-repeat: no-repeat;
      background-size: 16px 16px;
      background-position: right 8px center;
      cursor: pointer;
    }
  }

  .calendar-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;

    .p-calendar {
      flex: 1;
    }

    .calendar-clear-btn {
      position: absolute;
      // Place X to the left of the calendar icon (icon is ~38px wide)
      right: 38px;
      top: 50%;
      transform: translateY(-50%);
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: transparent;
      border: none;
      color: colors.$light-gray;
      font-size: fonts.$font-size-xl;
      cursor: pointer;
      padding: 0;
      line-height: 1;

      &:hover {
        color: colors.$text-color;
      }
    }
  }

  .filter-content {
    // Vertical rhythm between filter rows — same as Schedule
    // ($space-l / 15px between fields).
    display: flex;
    flex-direction: column;
    gap: vars.$space-l;
  }

  .filter-button {
    margin-top: vars.$space-l;
  }

  // Mirrors Angular `.search-button.color.blue-light` and Schedule's
  // submit button: 48px tall pill with $blue-light background.
  .search-button {
    width: 100%;
    height: vars.$standard-button-height;
    background-color: colors.$blue-light;
    color: colors.$white;
    border: none;
    border-radius: vars.$border-radius;
    padding: 0 vars.$space-l;
    font-size: fonts.$font-size-m;
    font-weight: fonts.$font-bold;
    cursor: pointer;
    transition-duration: 0.2s;

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

    span {
      font-weight: fonts.$font-bold;
      font-size: fonts.$font-size-m;
      color: colors.$white;
    }
  }

  .arrow-icon {
    display: inline-flex;
    align-items: center;
    width: 12px;
    height: 8px;
    transition: transform 0.2s ease;
    color: currentColor;

    svg {
      width: 12px;
      height: 8px;
    }

    &--rotated {
      transform: rotate(180deg);
    }
  }

  // PrimeReact AutoComplete dropdown button — subtle chevron, matches
  // Schedule.
  .p-autocomplete-dropdown {
    background: transparent !important;
    border: none !important;
    color: colors.$gray !important;
    width: 2rem !important;
    padding: 0 !important;

    .p-icon {
      width: 0.75rem;
      height: 0.75rem;
    }
  }

  // PrimeReact Calendar trigger button width override. Background-image,
  // border removal, and p-icon hiding live in the shared rule in
  // `styles/_prime-calendar.scss` so all three filter sidebars look
  // identical.
  .p-datepicker-trigger {
    width: 2rem !important;
    padding: 0 !important;
  }
}
