/* ============================================================
   components.css – Buttons, Inputs, Cards, Tabs, Dropdowns
   ============================================================ */

/* ── Primary Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  min-height: 48px;
  transition: background var(--transition-fast), opacity var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}

.btn--primary {
  background: var(--color-accent);
  color: #ffffff;
}

.btn--primary:hover, .btn--primary:active {
  background: var(--color-accent-hover);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover, .btn--secondary:active {
  background: var(--color-surface-2);
}

.btn--danger {
  background: var(--color-danger);
  color: #ffffff;
}

.btn--danger:hover, .btn--danger:active {
  background: var(--color-danger-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn--ghost:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

.btn--full { width: 100%; }
.btn--sm { min-height: 36px; padding: 6px var(--space-md); font-size: var(--font-size-sm); }

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Button Group ── */
.btn-group {
  display: flex;
  gap: var(--space-sm);
}

.btn-group .btn { flex: 1; }

/* ── Form Field ── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.field__label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
}

.field__input {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px var(--space-md);
  font-size: var(--font-size-base);
  color: var(--color-text);
  outline: none;
  min-height: 44px;
  transition: border-color var(--transition-fast);
}

.field__input:focus {
  border-color: var(--color-accent);
}

.field__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  padding-right: 36px;
  cursor: pointer;
}

/* ── Segmented Control (Option Tabs) ── */
.segmented {
  display: flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.segmented__option {
  flex: 1;
  padding: 8px var(--space-sm);
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  text-align: center;
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.segmented__option.active {
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ── Card ── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.card--elevated {
  box-shadow: var(--shadow-sm);
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-md) 0;
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: #ffffff;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
}

/* ── Avatar ── */
.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--color-surface-2);
  flex-shrink: 0;
}

.avatar--sm { width: 32px; height: 32px; }
.avatar--md { width: 48px; height: 48px; }
.avatar--lg { width: 72px; height: 72px; }
.avatar--xl { width: 96px; height: 96px; }

.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-bold);
  flex-shrink: 0;
}

.avatar-initials--sm { width: 32px; height: 32px; font-size: var(--font-size-xs); }
.avatar-initials--md { width: 48px; height: 48px; font-size: var(--font-size-sm); }
.avatar-initials--lg { width: 72px; height: 72px; font-size: var(--font-size-md); }

/* ── Leg Dots ── */
.leg-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.leg-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-leg-dot-empty);
  transition: background var(--transition-base);
}

.leg-dot.filled {
  background: var(--color-accent);
}

/* Set dots – square shape to distinguish from leg dots */
.set-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--color-leg-dot-empty);
  transition: background var(--transition-base);
}

.set-dot.filled {
  background: var(--color-accent);
}

.player-tab__sets {
  margin-top: 2px;
}

/* ── Dart Indicators ── */
/* ── Dart Slots (SVG darts) ── */
.dart-slots {
  display: flex;
  gap: var(--space-md);
  align-items: flex-end;
  justify-content: center;
}

.dart-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 32px;
}

.dart-svg {
  width: 28px;
  height: 28px;
  color: var(--color-text-muted);
  opacity: 0.3;
  transition: color var(--transition-fast), opacity var(--transition-fast);
}

.dart-svg--active {
  color: var(--color-success);
  opacity: 1;
}

.dart-slot__label {
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  min-height: 14px;
  text-align: center;
}

.dart-slot__label--bust {
  color: var(--color-danger);
}

/* ── Toast Notification ── */
.toast {
  position: fixed;
  bottom: calc(var(--keyboard-height) + var(--space-md));
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.toast.visible {
  opacity: 1;
}

/* ── Spinner ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Coming Soon Badge ── */
.coming-soon {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  margin-left: var(--space-xs);
}

/* ── Navigation Bar ── */
.nav-bar {
  display: flex;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-md);
}

.nav-bar__item {
  padding: var(--space-md) var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
}

.nav-bar__item.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl);
  color: var(--color-text-muted);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}
