@use '../abstracts' as *;

// Базовая сетка карточек; медиазапросы колонок — в pages/_doctors.scss
.doctors-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch; // все карточки в строке — одной высоты (по самой высокой)
}

// Карточка в сетке (не путать с блоками детальной страницы врача)
.doctors-grid .doctor-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%; // растягиваемся на высоту ячейки грида
  min-width: 0; // иначе карточку распирает
  border-radius: $radius-md;
  overflow: clip;
  background: $color-doctor-card-bg;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  color: inherit;

  &:hover {
    box-shadow: 0 6px 24px rgba($color-doctor-cta, 0.14);
    transform: translateY(-2px);
  }

  // padding только у __info
  @include between($bp-md, $until-1439) {
    padding: 0;
  }

  // ---- Фото ----
  &__photo {
    position: relative;
    height: 208px;
    flex-shrink: 0;
    background: $color-bg-filter;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: top center;
      display: block;
      transition: transform 0.4s ease;
    }
  }

  &:hover &__photo img {
    transform: scale(1.03);
  }

  // Бейдж стажа поверх превью
  &__badge {
    position: absolute;
    top: 164px;
    right: 20px;
    bottom: auto;
    background: $color-white;
    color: $color-blue;
    font-size: 14px;
    font-weight: 600;
    line-height: normal;
    padding: 4px 8px;
    border-radius: $radius-sm;
    white-space: nowrap;
  }

  // ---- Информация: padding 20px только здесь; у .doctor-card снаружи — 0 (768–1440) ----
  &__info {
    padding: 20px;
    flex: 1 1 auto; // забираем оставшееся место под фото
    min-height: 0; // корректная усадка flex внутри грида
    display: flex;
    flex-direction: column;
    gap: 15px;
  }

  // Имя + специальность: внутри блока gap 10 (как в макете)
  &__lead {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  &__name {
    margin: 0;

    a {
      color: rgba($color-black, 0.9);
      font-family: $font-heading;
      font-size: 18px;
      font-style: normal;
      font-weight: 700;
      line-height: $line-height-tight;
      text-decoration: none;

      @include between($bp-md, $until-991) {
        line-height: 1;
      }
    }
  }

  &__spec {
    font-size: $font-size-sm;
    line-height: $line-height-tight;
    color: $color-text-secondary;
    margin: 0;

    @include between($bp-md, $until-991) {
      line-height: 1.2;
    }
  }

  // ---- Помогает при ----
  &__helps {
    display: flex;
    flex-direction: column;
    gap: 4px;
    line-height: $line-height-tight;
    font-size: $font-size-sm;
    margin: 0;
  }

  &__helps-title {
    margin: 0;
    color: $color-black;
    font-family: $font-main;
    font-size: $font-size-sm;
    font-style: normal;
    font-weight: 500;
    line-height: $line-height-tight;

    @include sm {
      line-height: 1;
    }
  }

  &__helps-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;

    li {
      color: $color-black;
      font-family: $font-main;
      font-size: $font-size-sm;
      font-style: normal;
      font-weight: 400;
      line-height: $line-height-tight;
      padding-left: 3px;

      &::before {
        content: '• ';
      }

      @include between($bp-md, $until-991) {
        line-height: 1.26;
      }

      @include sm {
        line-height: 1.29;
      }
    }
  }

  // ---- Клиника ----
  &__clinic {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    line-height: normal;
    color: $color-text;
    margin: 0;

    @include between($bp-md, $until-991) {
      line-height: 1;
    }
  }

  &__clinic-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: $color-blue;
    flex-shrink: 0;
  }

  // ---- Кнопки ----
  // Ряд кнопок: крупнее gap на десктопе, плотнее на планшете
  &__actions {
    display: flex;
    align-items: flex-start; // как в макете: контейнер items-start
    gap: 20px;
    padding: 0;
    margin-top: auto; // кнопки в один ряд по нижнему краю при разной высоте текста

    // Figma node 22:836: Roboto SemiBold 16px / normal, px 20 py 10, radius 8, gap 20
    .btn {
      min-height: 0;
      height: auto;
      padding: 10px 20px;
      font-family: $font-main;
      font-size: 16px;
      font-weight: 600; // SemiBold
      line-height: normal;
      border-radius: $radius-sm;
      min-width: 0;
    }

    .btn--blue {
      flex: 1 0 0;
      background-color: $color-doctor-cta;
      color: $color-white;
      border: 1px solid $color-doctor-cta;
    }

    .btn--outline {
      flex: 1 0 0;
      background-color: transparent;
      border: 1px solid $color-doctor-cta;
      color: $color-doctor-cta;

      &:hover {
        background-color: $color-doctor-cta;
        color: $color-white;
        opacity: 1;
      }
    }

    @include md {
      gap: 10px;
    }

    @include between($bp-md, $until-991) {
      .btn--blue {
        line-height: 1;
      }
    }

    @include sm {
      .btn {
        line-height: 1.1;
      }
    }
  }
}

// ≤576: блок информации — как на десктопе (20px); кнопки — колонкой на всю ширину
@include sm {
  .doctors-grid .doctor-card {
    padding: 0;
    &__info {
      padding: 20px;
    }

    &__actions {
      flex-direction: column;
      gap: 10px;

      .btn--blue,
      .btn--outline {
        width: 100%;
        flex: none;
        justify-content: center;
      }
    }
  }
}
