@use '../styles/variables' as *;

.sf {
  background: var(--clr-surface, #{$color-surface});
  border: 1px solid var(--clr-border, #{$color-border});
  border-radius: $radius-xl;
  padding: $spacing-6;
  margin-bottom: $spacing-6;

  &__header {
    display: flex;
    align-items: flex-start;
    gap: $spacing-3;
    margin-bottom: $spacing-5;
  }

  &__header-icon {
    color: $primary-500;
    flex-shrink: 0;
    margin-top: 3px;
  }

  &__title {
    font-size: $font-size-lg;
    font-weight: $font-weight-semibold;
    color: var(--clr-text, #{$color-text-primary});
    margin: 0 0 $spacing-1;
  }

  &__subtitle {
    font-size: $font-size-sm;
    color: var(--clr-text-secondary, #{$color-text-secondary});
    margin: 0;
  }

  &__loading-badge {
    display: inline-block;
    background: $primary-100;
    color: $primary-700;
    border-radius: $radius-full;
    padding: 0 $spacing-2;
    font-size: $font-size-xs;
    font-weight: $font-weight-medium;
  }

  &__form {
    display: flex;
    flex-direction: column;
    gap: $spacing-4;
  }

  &__row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: $spacing-3;

    @media (max-width: 900px) {
      grid-template-columns: 1fr 1fr;
    }
    @media (max-width: 600px) {
      grid-template-columns: 1fr;
    }
  }

  &__field {
    display: flex;
    flex-direction: column;
    gap: $spacing-1;
  }

  &__label {
    font-size: $font-size-xs;
    font-weight: $font-weight-medium;
    color: var(--clr-text-secondary, #{$color-text-secondary});
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  &__input,
  &__select {
    width: 100%;
    padding: $spacing-2 $spacing-3;
    border: 1px solid var(--clr-border, #{$color-border});
    border-radius: $radius-base;
    font-size: $font-size-sm;
    font-family: $font-family-base;
    color: var(--clr-text, #{$color-text-primary});
    background: var(--clr-surface, #{$color-surface});
    outline: none;
    transition: border-color $transition-fast, box-shadow $transition-fast;

    &:focus {
      border-color: $primary-400;
      box-shadow: 0 0 0 3px rgba($primary-400, 0.15);
    }
  }

  &__btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: $spacing-2;
    padding: $spacing-2 $spacing-5;
    background: var(--clr-primary, #{$color-primary});
    color: #fff;
    border: none;
    border-radius: $radius-base;
    font-size: $font-size-sm;
    font-weight: $font-weight-semibold;
    font-family: $font-family-base;
    cursor: pointer;
    transition: background $transition-fast, opacity $transition-fast;

    &:hover:not(:disabled) {
      background: var(--clr-primary-hover, #{$color-primary-hover});
    }
    &:disabled {
      opacity: 0.55;
      cursor: not-allowed;
    }
  }

  &__wasm-error {
    padding: $spacing-4;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: $radius-base;
    color: #991b1b;
    font-size: $font-size-sm;
  }

  // ── Results ───────────────────────────────────────────────────────────────

  &__results {
    margin-top: $spacing-5;
    border-top: 1px solid var(--clr-border, #{$color-border});
    padding-top: $spacing-5;
  }

  &__empty {
    font-size: $font-size-sm;
    color: var(--clr-text-secondary, #{$color-text-secondary});
    text-align: center;
    padding: $spacing-8 0;
  }

  &__count {
    font-size: $font-size-xs;
    color: var(--clr-text-secondary, #{$color-text-secondary});
    margin-bottom: $spacing-3;
  }

  &__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: $spacing-3;
  }

  // ── Slot card ─────────────────────────────────────────────────────────────

  &__card {
    background: var(--clr-surface-raised, #{$gray-50});
    border: 1px solid var(--clr-border, #{$color-border});
    border-radius: $radius-lg;
    padding: $spacing-3;
    display: flex;
    flex-direction: column;
    gap: $spacing-2;
    transition: box-shadow $transition-fast;

    &:hover {
      box-shadow: $shadow-md;
    }

    &--best {
      border-color: $primary-400;
      background: $primary-50;
      box-shadow: 0 0 0 2px rgba($primary-400, 0.25);
    }
  }

  &__tag {
    display: inline-block;
    font-size: 10px;
    font-weight: $font-weight-semibold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: $primary-600;
    background: $primary-100;
    border-radius: $radius-full;
    padding: 2px 8px;
    align-self: flex-start;

    .sf__card--best & {
      background: $primary-500;
      color: #fff;
    }
  }

  &__card-date {
    display: flex;
    align-items: center;
    gap: $spacing-1;
    font-size: $font-size-xs;
    color: var(--clr-text, #{$color-text-primary});
    font-weight: $font-weight-medium;
  }

  &__dow {
    color: var(--clr-text-secondary, #{$color-text-secondary});
    font-weight: $font-weight-normal;
    margin-left: 2px;
  }

  &__card-time {
    display: flex;
    align-items: center;
    gap: $spacing-1;
    font-size: $font-size-base;
    font-weight: $font-weight-semibold;
    color: var(--clr-text, #{$color-text-primary});
  }

  &__days {
    font-size: $font-size-xs;
    color: var(--clr-text-secondary, #{$color-text-secondary});
    margin: 0;
  }

  &__bar {
    height: 4px;
    background: var(--clr-border, #{$color-border});
    border-radius: $radius-full;
    overflow: hidden;
  }

  &__bar-fill {
    height: 100%;
    background: linear-gradient(90deg, $primary-400, $primary-600);
    border-radius: $radius-full;
    transition: width 0.4s ease;
  }

  &__book {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: $spacing-1;
    padding: $spacing-1 $spacing-2;
    background: var(--clr-primary, #{$color-primary});
    color: #fff;
    border: none;
    border-radius: $radius-base;
    font-size: $font-size-xs;
    font-weight: $font-weight-semibold;
    font-family: $font-family-base;
    cursor: pointer;
    transition: background $transition-fast;

    &:hover {
      background: var(--clr-primary-hover, #{$color-primary-hover});
    }
  }
}
