/* ============================================================
   GoalSync — design tokens & base styles
   Light + Dark themes. Cobalt accent, ink neutrals.
   ============================================================ */

/* ---------- LIGHT (default) ---------- */
:root {
  --bg:           oklch(0.985 0.004 255);
  --bg-grad:      oklch(0.965 0.008 255);
  --surface:      oklch(1 0 0);
  --surface-2:    oklch(0.975 0.005 255);
  --surface-3:    oklch(0.955 0.007 255);
  --border:       oklch(0.918 0.006 255);
  --border-2:     oklch(0.86 0.01 255);

  --text:         oklch(0.24 0.022 262);
  --text-2:       oklch(0.47 0.018 262);
  --text-3:       oklch(0.62 0.014 262);

  --accent:       oklch(0.535 0.165 258);
  --accent-2:     oklch(0.47 0.18 258);
  --accent-fg:    oklch(0.99 0 0);
  --accent-soft:  oklch(0.95 0.035 258);
  --accent-soft-2:oklch(0.91 0.05 258);
  --accent-line:  oklch(0.8 0.07 258);

  --green:        oklch(0.58 0.13 158);
  --green-soft:   oklch(0.95 0.045 158);
  --green-line:   oklch(0.82 0.07 158);
  --amber:        oklch(0.66 0.13 70);
  --amber-soft:   oklch(0.95 0.05 75);
  --amber-line:   oklch(0.85 0.08 75);
  --red:          oklch(0.575 0.2 26);
  --red-soft:     oklch(0.955 0.03 26);
  --red-line:     oklch(0.86 0.07 26);
  --violet:       oklch(0.56 0.17 300);
  --violet-soft:  oklch(0.95 0.04 300);

  --shadow-sm: 0 1px 2px oklch(0.4 0.03 262 / 0.06), 0 1px 1px oklch(0.4 0.03 262 / 0.04);
  --shadow-md: 0 2px 4px oklch(0.4 0.03 262 / 0.05), 0 4px 12px oklch(0.4 0.03 262 / 0.08);
  --shadow-lg: 0 8px 28px oklch(0.35 0.03 262 / 0.12), 0 2px 8px oklch(0.35 0.03 262 / 0.08);
  --shadow-pop: 0 12px 40px oklch(0.3 0.04 262 / 0.18);

  --r-xs: 6px;  --r-sm: 9px;  --r-md: 13px; --r-lg: 18px; --r-xl: 24px;
  --sb-w: 248px;
  --topbar-h: 60px;

  --font: 'Golos Text', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  color-scheme: light;
}

/* ---------- DARK ---------- */
[data-theme="dark"] {
  --bg:           oklch(0.175 0.012 264);
  --bg-grad:      oklch(0.205 0.016 264);
  --surface:      oklch(0.213 0.014 264);
  --surface-2:    oklch(0.245 0.015 264);
  --surface-3:    oklch(0.275 0.016 264);
  --border:       oklch(0.305 0.016 264);
  --border-2:     oklch(0.375 0.02 264);

  --text:         oklch(0.955 0.005 264);
  --text-2:       oklch(0.74 0.014 264);
  --text-3:       oklch(0.6 0.016 264);

  --accent:       oklch(0.7 0.145 262);
  --accent-2:     oklch(0.76 0.14 262);
  --accent-fg:    oklch(0.16 0.02 264);
  --accent-soft:  oklch(0.32 0.07 262);
  --accent-soft-2:oklch(0.38 0.09 262);
  --accent-line:  oklch(0.46 0.1 262);

  --green:        oklch(0.74 0.14 158);
  --green-soft:   oklch(0.33 0.06 158);
  --green-line:   oklch(0.45 0.09 158);
  --amber:        oklch(0.79 0.13 78);
  --amber-soft:   oklch(0.35 0.05 75);
  --amber-line:   oklch(0.5 0.08 75);
  --red:          oklch(0.7 0.17 26);
  --red-soft:     oklch(0.35 0.08 26);
  --red-line:     oklch(0.5 0.12 26);
  --violet:       oklch(0.72 0.15 300);
  --violet-soft:  oklch(0.34 0.07 300);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 2px 6px oklch(0 0 0 / 0.35), 0 6px 16px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 10px 32px oklch(0 0 0 / 0.5);
  --shadow-pop: 0 16px 48px oklch(0 0 0 / 0.6);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
}
#root { height: 100%; }

::selection { background: var(--accent-soft-2); color: var(--text); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

h1,h2,h3,h4,p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- typography helpers ---------- */
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.t-display { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.t-h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.t-h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.t-h3 { font-size: 14.5px; font-weight: 600; }
.t-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.t-muted { color: var(--text-2); }
.t-faint { color: var(--text-3); }
.t-sm { font-size: 13px; }
.t-xs { font-size: 12px; }

/* ============================================================
   PRIMITIVES
   ============================================================ */

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
  white-space: nowrap; transition: all .15s ease; user-select: none;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn-subtle { background: transparent; color: var(--text-2); }
.btn-subtle:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.btn-danger:hover { background: var(--red); color: white; }
.btn-sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 14.5px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 31px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-block { width: 100%; }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-sm);
}
.card-hover { transition: all .16s ease; cursor: pointer; }
.card-hover:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* badges / pills */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 23px; padding: 0 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge svg { width: 13px; height: 13px; }
.badge .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge-accent { background: var(--accent-soft); color: var(--accent-2); }
.badge-green  { background: var(--green-soft); color: var(--green); }
.badge-amber  { background: var(--amber-soft); color: var(--amber); }
.badge-red    { background: var(--red-soft); color: var(--red); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-outline { background: transparent; border: 1px solid var(--border-2); color: var(--text-2); }

/* inputs */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, .textarea, .select {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 13.5px; transition: all .14s ease;
}
.input { height: 40px; }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.select { height: 40px; appearance: none; 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='%23888' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px;
}
.search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-sm);
}
.search svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.search input { border: none; background: none; outline: none; color: var(--text); width: 100%; font-size: 13.5px; }
.search input::placeholder { color: var(--text-3); }

/* avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 99px; font-weight: 600; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-2);
  font-size: 12px; width: 32px; height: 32px;
  border: 1.5px solid var(--surface);
}

/* progress bar */
.pbar { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.pbar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .5s cubic-bezier(.2,.7,.3,1); }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; color: var(--text-2);
  height: 30px; padding: 0 13px; border-radius: var(--r-xs);
  font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  transition: all .14s ease;
}
.seg button svg { width: 15px; height: 15px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button:not(.active):hover { color: var(--text); }

/* divider */
.hr { height: 1px; background: var(--border); border: none; margin: 0; }

/* tooltip-ish chip row */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }

/* skeleton */
.skel { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: skel 1.3s infinite; border-radius: var(--r-xs); }
@keyframes skel { to { background-position: -200% 0; } }

/* fade / slide in */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .35s cubic-bezier(.2,.7,.3,1) forwards; }
.fade-in { animation: fadeIn .3s ease forwards; }

/* blinking caret for streaming */
.caret::after { content: ''; display: inline-block; width: 8px; height: 1.1em; vertical-align: text-bottom; margin-left: 2px; background: var(--accent); border-radius: 1px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* spinner */
.spin { width: 18px; height: 18px; border: 2.5px solid var(--border-2); border-top-color: var(--accent); border-radius: 99px; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* modal */
.overlay { position: fixed; inset: 0; background: oklch(0.2 0.02 262 / 0.45); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 60; animation: fadeIn .18s ease; padding: 24px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: 100%; max-width: 540px; max-height: 88vh; overflow: auto; animation: pop .22s cubic-bezier(.2,.8,.3,1); }

/* dropdown menu */
.menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--r-xs); font-size: 13px; color: var(--text); cursor: pointer; transition: background .12s; }
.menu-item:hover { background: var(--surface-2); }
.menu-item svg { width: 16px; height: 16px; color: var(--text-2); }
.menu-item.danger { color: var(--red); }
.menu-item.danger svg { color: var(--red); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 0; }

/* table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.tbl tbody tr:last-child td { border-bottom: none; }

/* generic flex utils used inline-sparingly */
.stack { display: flex; flex-direction: column; }
.between { display: flex; align-items: center; justify-content: space-between; }

/* focus ring for keyboard a11y */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
