/* ============================================================
   SKILL ITBD Tracker — base styles shared by the tracker, login and admin
   Components mirror tools.skillitbd.com (Tailwind + shadcn/ui).
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.25;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
}

img,
video {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

::selection {
  background: rgba(48, 192, 227, 0.35);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.num,
.tnum {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.muted {
  color: var(--text-3);
}

.no-scroll {
  overflow: hidden;
}

/* ── Scrollbars (thin, like the reference) ── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 999px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Icons (Lucide sprite) ── */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-xs {
  width: 14px;
  height: 14px;
}

.icon-lg {
  width: 28px;
  height: 28px;
}

/* ── Wordmark: SKILL (cyan) ITBD (crimson) ── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex: none;
}

.wordmark {
  font-size: 20px;
  font-weight: 700;
  line-height: 28px;
  white-space: nowrap;
  letter-spacing: 0;
}

.wordmark .skill {
  color: var(--brand-ink);
}

.wordmark .itbd {
  color: var(--crimson);
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--brand-700);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

:root[data-theme="light"] .brand-tag {
  color: var(--brand-700);
  border-color: rgba(8, 145, 178, 0.35);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.6;
}

.btn-primary {
  background: var(--brand-600);
  border-color: var(--brand-700);
  color: var(--text-on-brand);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-700);
  color: var(--text-on-brand);
}

.btn-cyan {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: var(--text-on-brand);
}

.btn-cyan:hover:not(:disabled) {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: var(--text-on-brand);
}

.btn-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--text-on-brand);
}

.btn-brand:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: var(--text-on-brand);
}

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
  color: #fff;
}

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

.btn-ghost.danger {
  color: var(--danger);
}

.btn-ghost.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-pill {
  border-radius: 999px;
  padding: 0 24px;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  gap: 6px;
}

.btn-lg {
  height: 44px;
  padding: 0 22px;
  font-size: 15px;
}

.btn.is-loading {
  position: relative;
  color: transparent !important;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-row.center {
  justify-content: center;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--radius-btn);
  color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.link-btn {
  color: var(--brand);
  font-weight: 500;
  text-align: left;
}

.link-btn:hover {
  text-decoration: underline;
}

:root[data-theme="light"] .link-btn {
  color: var(--brand-600);
}

/* ── Form controls ── */
.field {
  display: grid;
  gap: 6px;
}

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.hint {
  font-size: 12px;
  color: var(--text-3);
}

.input,
.select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 10px 1px rgba(0, 188, 212, 0.3);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.select option {
  background: var(--surface);
  color: var(--text);
}

.select-sm {
  height: 32px;
  font-size: 13px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group > .icon {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  pointer-events: none;
}

.input-group > .icon ~ .input {
  padding-left: 38px;
}

.input-group .input-action {
  position: absolute;
  right: 4px;
}

.input-group .input-action ~ .input,
.input-group .input:has(~ .input-action) {
  padding-right: 42px;
}

/* Switch (shadcn): cyan track, dark thumb */
.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.switch span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--surface-2);
  transition: background-color 0.15s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease;
}

:root[data-theme="light"] .switch span::after {
  background: #fff;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.switch input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Range slider (shadcn): 8px gray track, cyan fill, dark thumb with cyan ring */
.range {
  --pct: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--brand) var(--pct), var(--surface-2) var(--pct));
}

.range::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--brand) var(--pct), var(--surface-2) var(--pct));
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  background: var(--bg);
  transition: box-shadow 0.15s ease;
}

.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  background: var(--bg);
}

.range:focus-visible {
  outline: none;
}

.range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(48, 192, 227, 0.35);
}

:root[data-theme="light"] .range::-webkit-slider-thumb {
  background: #fff;
}

:root[data-theme="light"] .range::-moz-range-thumb {
  background: #fff;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius);
  background: var(--input);
  border: 1px solid var(--border);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: var(--brand-600);
  color: #fff;
}

/* ── Cards, badges, chips ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
}

.eyebrow {
  color: var(--brand);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

:root[data-theme="light"] .eyebrow {
  color: var(--brand-600);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge-brand {
  background: var(--brand-soft);
  color: var(--brand);
}

:root[data-theme="light"] .badge-brand {
  color: var(--brand-700);
}

.badge-ok {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.chip:hover {
  border-color: var(--brand);
  color: var(--text);
}

.chip .count {
  color: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chip-cloud,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-row.center {
  justify-content: center;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
}

.dot.ok {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.dot.warn {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}

.dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* ── Spinner, toasts ── */
.spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--surface-2);
  border-top-color: var(--brand);
  animation: spin 0.7s linear infinite;
}

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: grid;
  gap: 8px;
  justify-items: end;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  animation: toast-in 0.2s ease;
  pointer-events: auto;
}

.toast .icon {
  color: var(--brand);
}

.toast.is-error .icon {
  color: var(--danger);
}

/* ── Gradient frame (cyan → crimson) with the reference's glow pulse ── */
.glow-frame {
  padding: 2px;
  border-radius: var(--radius-xl);
  background: var(--brand-gradient);
  box-shadow: var(--shadow);
}

.glow-frame > .glow-inner {
  border-radius: calc(var(--radius-xl) - 2px);
  background: var(--panel);
}

.glow-frame.animate > .glow-inner {
  animation: border-glow 3s ease-in-out infinite;
}

@keyframes border-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(48, 192, 227, 0), 0 0 0 0 rgba(201, 58, 93, 0);
  }
  50% {
    box-shadow: 0 0 30px 6px var(--glow-cyan), 0 0 30px 6px var(--glow-crimson);
  }
}

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

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
