@use "tokens" as *;

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid $border;
  margin-bottom: $space-5;

  @container content (min-width: #{$bp-sm}) {
    gap: $space-1;
  }

  &__tab {
    display: inline-flex;
    align-items: center;
    gap: $space-1;
    padding: $space-1 $space-2;
    border: none;
    background: none;
    font-family: $k-font-sans;
    font-size: $fs-12;
    font-weight: $k-fw-medium;
    color: $text-3;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    flex: 1;
    min-width: 0;
    justify-content: center;

    // Estrecho: las tabs con icono se quedan SOLO con el icono — el texto
    // desaparece (la etiqueta, visually hidden más abajo, sigue en el DOM
    // accesible y el botón lleva title; antes se apilaban icono + etiqueta
    // pequeña).
    &--has-icon {
      padding: $space-1;
    }

    @container content (min-width: #{$bp-sm}) {
      flex: none;
      min-width: auto;
      padding: $space-2;

      &--has-icon {
        gap: $space-1;
        padding: $space-2;
      }
    }

    @container content (min-width: #{$bp-md}) {
      font-size: $fs-14;
      gap: $space-2;
      padding: $space-2 $space-3;

      &--has-icon {
        gap: $space-2;
        padding: $space-2 $space-3;
      }
    }

    &:hover {
      color: $text-1;
    }

    &--active {
      color: $accent-600;
      border-bottom-color: $accent-500;
    }
  }

  &__icon {
    flex-shrink: 0;
  }

  &__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    // En estrecho, la etiqueta de una tab CON icono desaparece VISUALMENTE
    // (patrón visually-hidden, no display:none: sigue en el árbol de
    // accesibilidad y da nombre al botón; el title del botón cubre el
    // hover). De $bp-sm para arriba vuelve al flujo, en línea con el icono.
    .tabs__tab--has-icon & {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      padding: 0;
      clip-path: inset(50%);

      @container content (min-width: #{$bp-sm}) {
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        clip-path: none;
      }
    }
  }

  &__count {
    font-size: $fs-12;
    font-weight: $k-fw-semibold;
    background: $surface-2;
    color: $text-2;
    padding: 0 $space-2;
    border-radius: $radius-pill;
    line-height: 1.6;
    flex-shrink: 0;

    // En estrecho con iconos, oculta el contador
    .tabs__tab--has-icon & {
      display: none;

      @container content (min-width: #{$bp-sm}) {
        display: inline;
      }
    }

    .tabs__tab--active & {
      background: $accent-100;
      color: $accent-600;
    }
  }
}
