@use '../../themes/index' as *;
@use '../../abstracts/index' as *;

/* 
  Button component styles
  Core styling for buttons throughout the application
*/
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-weight: var(--semibold);
  white-space: nowrap;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--duration-normal) var(--easing-ease-out);

  &:disabled,
  &.disabled {
    opacity: 0.55;
    cursor: not-allowed;
  }

  // Sizing
  &.btn-sm {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    gap: 0.3rem;
  }

  &.btn-md {
    font-size: 0.875rem;
    padding: 0.6rem 1.2rem;
    gap: 0.5rem;
  }

  &.btn-lg {
    font-size: 1rem;
    padding: 0.8rem 1.5rem;
    gap: 0.6rem;
  }

  // Icon-only buttons are square, regardless of size
  &.btn-icon-only.btn-sm {
    padding: 0.45rem;
  }

  &.btn-icon-only.btn-md {
    padding: 0.6rem;
  }

  &.btn-icon-only.btn-lg {
    padding: 0.75rem;
  }

  // Variants - flat fill, a plain darken/lighten on hover, no lift or glow
  &.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-heavy);

    &:hover:not(:disabled) {
      background-color: color-mix(in srgb, black 8%, var(--primary-color));
    }

    &:active:not(:disabled) {
      background-color: color-mix(in srgb, black 14%, var(--primary-color));
    }
  }

  &.btn-secondary {
    background-color: var(--border-soft);
    color: var(--text-primary);

    &:hover:not(:disabled) {
      background-color: var(--border);
    }

    &:active:not(:disabled) {
      background-color: color-mix(in srgb, black 10%, var(--border));
    }
  }

  &.btn-success {
    background-color: var(--success);
    color: var(--text-heavy);

    &:hover:not(:disabled) {
      background-color: color-mix(in srgb, black 8%, var(--success));
    }
  }

  &.btn-danger {
    background-color: var(--danger);
    color: var(--text-heavy);

    &:hover:not(:disabled) {
      background-color: color-mix(in srgb, black 8%, var(--danger));
    }
  }

  &.btn-warning {
    background-color: var(--warning);
    color: var(--text-heavy);

    &:hover:not(:disabled) {
      background-color: color-mix(in srgb, black 8%, var(--warning));
    }
  }

  // Loading state
  &.btn-loading {
    position: relative;

    .btn-spinner {
      width: 1em;
      height: 1em;
      position: relative;
      margin-right: 0.5rem;

      .spinner-ring {
        width: 100%;
        height: 100%;
        color: inherit;
      }
    }

    .btn-text {
      opacity: 0.7;
    }
  }

  // Icons
  .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    &.btn-icon-left {
      margin-right: 0.1rem;
    }

    &.btn-icon-right {
      margin-left: 0.1rem;
    }
  }

  // Full width
  &.btn-full {
    width: 100%;
  }
}

// Rating button on game card
.rate-button {
  svg {
    color: var(--elevated-bg);
  }

  &:hover {
    background-color: rgba(255, 255, 255, 0.28);
  }

  &:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
}
