/* ───────────────────────────────────────────────────────────────
   Arterias — Component library
   Buttons, cards, forms, tables, badges, nav, toasts, skeletons,
   modals, tabs, avatars, progress.
   ─────────────────────────────────────────────────────────────── */

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  --btn-bg: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease),
    box-shadow var(--dur) var(--ease), background var(--dur) var(--ease),
    border-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.btn[disabled], .btn.is-loading { opacity: 0.6; pointer-events: none; }

.btn-primary {
  background: var(--gradient-brand);
  border: none;
  color: #fff;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.3);
}
.btn-primary:hover { box-shadow: 0 12px 32px rgba(124, 92, 255, 0.45); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-outline { background: transparent; }
.btn-danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: var(--fs-xs); }
.btn-lg { padding: 15px 28px; font-size: var(--fs-base); }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; width: 40px; height: 40px; }

.btn .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.card-hover:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
}
.card-title { font-size: var(--fs-lg); font-weight: 700; }

/* ── Badges & pills ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-brand { background: var(--gradient-brand-soft); color: var(--brand-2); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ── Forms ───────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-soft); }
.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}
.textarea { resize: vertical; min-height: 120px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 44px; }
.input-affix {
  position: absolute; right: 10px;
  background: none; border: none; color: var(--text-mut);
  cursor: pointer; padding: 6px; border-radius: var(--r-sm);
}
.input-affix:hover { color: var(--text); background: var(--surface-2); }
.field-error { color: var(--danger); font-size: var(--fs-xs); }
.field.invalid .input { border-color: var(--danger); }
.hint { font-size: var(--fs-xs); color: var(--text-mut); }

.checkbox { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-sm); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand-1); }

/* Password strength meter */
.strength { height: 6px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.strength > i { display: block; height: 100%; width: 0; transition: width var(--dur) var(--ease), background var(--dur); }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 14px 16px; text-align: left; }
.table thead th {
  background: var(--surface-2);
  color: var(--text-mut);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky; top: 0;
}
.table tbody tr { border-top: 1px solid var(--border); transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--surface); }

/* ── Avatar ──────────────────────────────────────────── */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.avatar-lg { width: 72px; height: 72px; font-size: var(--fs-2xl); }
.avatar-sm { width: 28px; height: 28px; font-size: var(--fs-xs); }

/* ── Progress ────────────────────────────────────────── */
.progress { height: 10px; background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--gradient-brand); border-radius: var(--r-full); transition: width var(--dur-slow) var(--ease); }

/* ── Tabs ────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); overflow-x: auto; }
.tab {
  padding: 10px 16px; background: none; border: none; cursor: pointer;
  color: var(--text-mut); font-weight: 600; font-size: var(--fs-sm);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--brand-1); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: pageIn var(--dur) var(--ease); }

/* ── Navbar ──────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center;
  transition: background var(--dur), border-color var(--dur), backdrop-filter var(--dur);
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(7, 9, 15, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom-color: var(--border);
}
.nav .container { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: var(--fs-lg); }
.brand-mark { width: 32px; height: 32px; }
.nav-links { display: flex; align-items: center; gap: var(--sp-5); }
.nav-links a { color: var(--text-soft); font-size: var(--fs-sm); font-weight: 500; }
.nav-links a:hover { color: var(--text); }
.nav-actions { display: flex; align-items: center; gap: var(--sp-3); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); }

/* ── Toasts ──────────────────────────────────────────── */
.toast-stack {
  position: fixed; top: 84px; right: 24px; z-index: 1000;
  display: flex; flex-direction: column; gap: var(--sp-3);
  max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--brand-1);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: pageIn var(--dur) var(--ease);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast strong { display: block; font-size: var(--fs-sm); }
.toast p { font-size: var(--fs-xs); color: var(--text-mut); }

/* ── Skeletons ───────────────────────────────────────── */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.skeleton::after {
  content: '';
  position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  animation: shimmer 1.4s infinite;
}
.sk-line { height: 12px; margin: 8px 0; }
.sk-title { height: 22px; width: 50%; }
.sk-block { height: 120px; }

/* ── Modal ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(3, 5, 12, 0.7);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: var(--sp-4);
}
.modal-backdrop.open { display: flex; animation: pageIn var(--dur-fast) var(--ease); }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  max-width: 460px; width: 100%;
  box-shadow: var(--shadow-lg);
}

/* ── Misc ────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: var(--sp-5) 0; }
.kbd {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.tag-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-toggle { display: block; }
  .nav.mobile-open .nav-links {
    display: flex; flex-direction: column; gap: var(--sp-4);
    position: absolute; top: var(--header-h); left: 0; right: 0;
    background: var(--bg-elev); padding: var(--sp-5);
    border-bottom: 1px solid var(--border);
  }
}
