/* ============================================================
   Lockboard — shadcn/ui (zinc) inspired design tokens
   ============================================================ */

:root {
  --radius: 0.6rem;
  --mono-font: "JetBrains Mono";
  --accent-h: 0;
  --accent-s: 0%;
  --accent-l: 98%;

  /* Mist — cool blue-slate dark theme (default) */
  --background: 205 28% 7%;
  --foreground: 200 18% 96%;
  --card: 205 24% 10%;
  --card-foreground: 200 18% 96%;
  --popover: 205 26% 9%;
  --popover-foreground: 200 18% 96%;
  --primary: var(--accent-h) var(--accent-s) var(--accent-l);
  --primary-foreground: 200 45% 10%;
  --secondary: 205 16% 16%;
  --secondary-foreground: 200 18% 96%;
  --muted: 205 16% 16%;
  --muted-foreground: 205 14% 66%;
  --accent: 205 18% 20%;
  --accent-foreground: 200 18% 96%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --border: 205 16% 20%;
  --input: 205 16% 23%;
  --ring: var(--accent-h) var(--accent-s) 65%;

  --ok: 162 60% 45%;
  --warn: 38 92% 55%;
  --info: 199 80% 58%;

  --sidebar: 205 26% 9%;
  --shadow-color: 205 45% 2%;
}

[data-theme="light"] {
  /* Mist — pale misty blue-grey light theme */
  --background: 200 30% 98%;
  --foreground: 205 28% 14%;
  --card: 200 33% 99%;
  --card-foreground: 205 28% 14%;
  --popover: 0 0% 100%;
  --popover-foreground: 205 28% 14%;
  --primary: var(--accent-h) var(--accent-s) var(--accent-l);
  --primary-foreground: 0 0% 100%;
  --secondary: 200 24% 93%;
  --secondary-foreground: 205 22% 20%;
  --muted: 200 24% 93%;
  --muted-foreground: 205 12% 42%;
  --accent: 200 26% 92%;
  --accent-foreground: 205 22% 20%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 98%;
  --border: 200 20% 87%;
  --input: 200 20% 85%;
  --ring: var(--accent-h) var(--accent-s) 45%;

  --ok: 162 62% 36%;
  --warn: 38 92% 42%;
  --info: 199 85% 46%;

  --sidebar: 200 30% 97%;
}

/* Accent presets (driven by Tweaks) */
[data-accent="neutral"][data-theme="dark"] { --accent-h: 190; --accent-s: 48%; --accent-l: 66%; }
[data-accent="neutral"][data-theme="light"] { --accent-h: 192; --accent-s: 60%; --accent-l: 38%; }
[data-accent="neutral"] { --primary-foreground: 200 45% 10%; }
[data-accent="neutral"][data-theme="light"] { --primary-foreground: 0 0% 100%; }
[data-accent="blue"]   { --accent-h: 217; --accent-s: 91%; --accent-l: 60%; }
[data-accent="emerald"]{ --accent-h: 160; --accent-s: 64%; --accent-l: 45%; }
[data-accent="violet"] { --accent-h: 263; --accent-s: 70%; --accent-l: 60%; }
[data-accent="blue"]   { --primary-foreground: 0 0% 100%; }
[data-accent="emerald"]{ --primary-foreground: 0 0% 100%; }
[data-accent="violet"] { --primary-foreground: 0 0% 100%; }

[data-mono="jetbrains"] { --mono-font: "JetBrains Mono"; }
[data-mono="plex"]      { --mono-font: "IBM Plex Mono"; }
[data-mono="space"]     { --mono-font: "Space Mono"; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #root { height: 100%; }

body {
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
}

.mono { font-family: var(--mono-font), ui-monospace, "SF Mono", Menlo, monospace; }

::selection { background: hsl(var(--primary) / 0.25); }

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 99px; border: 3px solid hsl(var(--background)); }
*::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.5); }

/* ---------- Layout primitives ---------- */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.center { align-items: center; justify-content: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: hsl(var(--muted-foreground)); }

/* ---------- Buttons ---------- */
.btn {
  --h: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 14px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  background: transparent; color: hsl(var(--foreground));
  font: inherit; font-weight: 500; font-size: 13.5px;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .04s, box-shadow .15s;
}
.btn:active { transform: translateY(0.5px) scale(0.995); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring)); }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { background: hsl(var(--primary) / 0.9); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover { background: hsl(var(--secondary) / 0.7); }
.btn-outline { border-color: hsl(var(--border)); background: hsl(var(--background)); }
.btn-outline:hover { background: hsl(var(--accent)); }
.btn-ghost:hover { background: hsl(var(--accent)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover { background: hsl(var(--destructive) / 0.9); }
.btn-sm { --h: 32px; padding: 0 11px; font-size: 13px; }
.btn-icon { --h: 36px; width: 36px; padding: 0; }
.btn-icon.btn-sm { --h: 32px; width: 32px; }
.btn-icon.xs { --h: 28px; width: 28px; }
.btn-icon.xs svg { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ---------- Inputs ---------- */
.field-label { font-size: 13px; font-weight: 500; margin-bottom: 7px; display: block; }
.input, .textarea, .select {
  width: 100%;
  height: 38px; padding: 0 12px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--foreground)); font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 78px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground) / 0.7); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18);
}
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px;
}
.input-group { position: relative; }
.input-group .input { padding-left: 38px; }
.input-group > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: hsl(var(--muted-foreground)); pointer-events: none; }

/* ---------- Card ---------- */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge-ok    { color: hsl(var(--ok)); background: hsl(var(--ok) / 0.12); border-color: hsl(var(--ok) / 0.25); }
.badge-warn  { color: hsl(var(--warn)); background: hsl(var(--warn) / 0.12); border-color: hsl(var(--warn) / 0.25); }
.badge-muted { color: hsl(var(--muted-foreground)); background: hsl(var(--muted) / 0.6); border-color: hsl(var(--border)); }
.badge-outline { color: hsl(var(--muted-foreground)); border-color: hsl(var(--border)); }

/* ---------- Avatar ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 99px; background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground)); font-weight: 600;
  flex: none; overflow: hidden; font-size: 13px;
}

/* ---------- Tooltip-ish kbd ---------- */
kbd {
  font-family: var(--mono-font), monospace; font-size: 11px;
  background: hsl(var(--muted)); border: 1px solid hsl(var(--border));
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: hsl(var(--muted-foreground));
}

/* ---------- Modal / dialog ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: hsl(240 10% 2% / 0.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 20px 20px;
  animation: overlay-in .18s ease;
  overflow-y: auto;
}
@keyframes overlay-in { from { opacity: 0; } }
.dialog {
  width: 100%; max-width: 520px;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -12px hsl(var(--shadow-color) / 0.6);
  animation: dialog-in .2s cubic-bezier(.16,1,.3,1);
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dialog-head { padding: 20px 22px 0; }
.dialog-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.dialog-desc { color: hsl(var(--muted-foreground)); font-size: 13.5px; margin-top: 4px; }
.dialog-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 15px; }
.dialog-foot { padding: 0 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; z-index: 90; bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: hsl(var(--popover)); color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 1px);
  padding: 11px 15px; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 12px 30px -8px hsl(var(--shadow-color) / 0.5);
  animation: toast-in .25s cubic-bezier(.16,1,.3,1);
}
.toast svg { width: 17px; height: 17px; color: hsl(var(--ok)); flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateX(18px); } }

/* ---------- Divider ---------- */
.divider { height: 1px; background: hsl(var(--border)); border: 0; width: 100%; }

/* ---------- Switch ---------- */
.switch {
  position: relative; width: 38px; height: 22px; border-radius: 99px;
  background: hsl(var(--input)); border: none; cursor: pointer; flex: none;
  transition: background .18s;
}
.switch[data-on="true"] { background: hsl(var(--primary)); }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 99px; background: #fff;
  transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch[data-on="true"]::after { transform: translateX(16px); }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
