/**
 * Shared component classes (shadcn-inspired). Used with tokens.css.
 */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border-radius: var(--radius-btn);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25rem;
  min-height: 2.25rem;
  padding: 0.375rem 0.875rem;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -0.01em;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.ui-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.ui-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ui-btn-sm { min-height: 2rem; padding: 0.25rem 0.625rem; font-size: 0.8125rem; }
.ui-btn-lg { min-height: 2.75rem; padding: 0.5rem 1rem; }

.ui-btn-primary {
  background: var(--brand-600);
  color: #fff;
  box-shadow: 0 1px 2px rgb(2 132 199 / 0.35);
}
.ui-btn-primary:hover { background: var(--brand-700); color: #fff; }
.ui-btn-primary:active { transform: translateY(1px); }

.ui-btn-secondary {
  background: var(--bg-elevated);
  color: var(--ink);
  border-color: var(--border);
}
.ui-btn-secondary:hover { background: var(--bg-muted); }

.ui-btn-ghost {
  background: transparent;
  color: var(--ink-muted);
}
.ui-btn-ghost:hover { background: var(--bg-muted); color: var(--ink); }

.ui-btn-destructive {
  background: #e11d48;
  color: #fff;
}
.ui-btn-destructive:hover { background: #be123c; }

.ui-btn-tree {
  background: var(--tree-deep);
  color: #fff;
}
.ui-btn-tree:hover { filter: brightness(1.05); }

.ui-btn-ai {
  background: var(--ai-deep);
  color: #fff;
}
.ui-btn-ai:hover { filter: brightness(1.05); }
.ui-btn-warning {
  background: #d97706;
  color: #fff;
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 9999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
  line-height: 1.25rem;
}
.ui-badge-sky { background: var(--brand-50); color: var(--brand-700); border-color: #bae6fd; }
.ui-badge-tree { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.ui-badge-tree-solid { background: var(--tree-deep); color: #fff; border-color: var(--tree-deep); }
/* Ready = emerald outline, open fill (not mastered solid) */
.ui-badge-ready {
  background: var(--map-ready-fill, #fff);
  color: var(--map-ready-ink, #064e3b);
  border-color: var(--map-ready-border, #059669);
}
.ui-badge-ready-on {
  box-shadow: 0 0 0 2px rgb(5 150 105 / 0.35);
  font-weight: 600;
}
.ui-badge-slate { background: #f1f5f9; color: #475569; }
.ui-badge-amber { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.ui-badge-ai { background: #f5f3ff; color: var(--ai-ink); }
.ui-badge-rose { background: #fff1f2; color: #9f1239; }

html.dark .ui-badge-sky { background: var(--brand-50); color: var(--brand-700); }
html.dark .ui-badge-tree { background: rgba(16, 185, 129, 0.15); color: #a7f3d0; border-color: rgba(52, 211, 153, 0.35); }
html.dark .ui-badge-slate { background: #1e293b; color: #cbd5e1; }
html.dark .ui-badge-ai { background: rgba(139, 92, 246, 0.15); color: var(--ai-ink); }
html.dark .ui-badge-ready { background: var(--map-ready-fill); color: var(--map-ready-ink); border-color: var(--map-ready-border); }
html.dark .ui-nav { box-shadow: 0 1px 0 rgb(0 0 0 / 0.4); }
html.dark .ui-page-title { color: var(--ink); }

.ui-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.ui-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1.25;
}
.ui-page-lede {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
  max-width: 40rem;
  line-height: 1.45;
}

.ui-nav {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgb(15 23 42 / 0.04), 0 8px 24px -16px rgb(15 23 42 / 0.18);
}
.ui-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--ink-muted);
}
.ui-nav-link:hover { background: var(--bg-muted); color: var(--ink); }
.ui-nav-link.is-active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.ui-nav-link .ui-icon { width: 0.95rem; height: 0.95rem; opacity: 0.85; }

.ui-alert {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.ui-alert-info { background: var(--brand-50); border-color: #bae6fd; color: var(--brand-700); }
.ui-alert-success { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.ui-alert-warning { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.ui-alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.ui-alert .ui-btn-ghost { color: inherit; }
html.dark .ui-alert-info { border-color: rgba(14, 165, 233, 0.35); }

.ui-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.5);
  z-index: 50;
}
.ui-dialog-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 32rem;
  width: calc(100% - 2rem);
}

.ui-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.ui-select-menu,
.ui-menu {
  box-sizing: border-box;
  color-scheme: inherit;
  background: var(--bg-elevated, #fff);
  color: var(--ink, #0f172a);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(15 23 42 / 0.12));
  transition: none;
}
html.dark .ui-select-menu,
html.dark .ui-menu {
  background: #0f172a !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}

/* ── Switch ─────────────────────────────────────────────── */
.ui-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
}
.ui-switch[data-disabled],
.ui-switch:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.6;
}
.ui-switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.ui-switch-track {
  position: relative;
  display: inline-block;
  width: 2.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background: #cbd5e1;
  border: 1px solid #94a3b8;
  transition: background-color var(--motion-fast, 150ms) var(--ease-in-out, ease),
    border-color var(--motion-fast, 150ms) var(--ease-in-out, ease);
}
html.dark .ui-switch-track {
  background: #334155;
  border-color: #475569;
}
.ui-switch-thumb {
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.25);
  transform: translateX(0);
  transition: transform var(--motion-fast, 150ms) var(--ease-out, ease);
}
.ui-switch-input:checked + .ui-switch-track {
  background: var(--brand-600);
  border-color: var(--brand-700);
}
.ui-switch-input:checked + .ui-switch-track .ui-switch-thumb {
  transform: translateX(1rem);
}
.ui-switch-input:focus-visible + .ui-switch-track {
  box-shadow: var(--focus);
}
.ui-switch-label {
  font-size: 0.875rem;
  color: var(--ink);
  line-height: 1.3;
}

@media (prefers-reduced-motion: reduce) {
  .ui-btn,
  .ui-switch-track,
  .ui-switch-thumb,
  .ui-dialog-backdrop,
  .ui-dialog-panel {
    transition: none !important;
  }
}
