/* ==========================================================================
   main.css — design tokens, reset, layout primitives, buttons, toasts
   --------------------------------------------------------------------------
   THEMING: everything visual comes from the :root custom properties below.
   To reskin the app, edit values in this one block — colors, radius, shadow,
   font, spacing — nothing else in these files hardcodes a color or a radius.
   Components are plain cards (border + shadow + radius) — no custom rule
   system, no display font. Standard, boring, easy to change.
   ========================================================================== */

:root {
  /* ---- brand — the one thing you'll actually want to swap ---------- */
  --accent:        #2563EB;   /* primary actions, links, active states */
  --accent-hover:  #1D4ED8;
  --accent-wash:   #EFF4FF;   /* tinted background for accent-y things */

  /* ---- surfaces ------------------------------------------------------ */
  --bg:            #F8F9FA;   /* page background */
  --surface:       #FFFFFF;   /* cards, modals, inputs */
  --surface-alt:   #F1F3F5;   /* wells: message block, table stripe, skeleton */

  /* ---- text ----------------------------------------------------------- */
  --text:          #1A1D23;   /* headings, primary content */
  --text-2:        #5B6270;   /* body secondary */
  --text-3:        #8A909C;   /* labels, metadata, placeholders */

  /* ---- borders --------------------------------------------------------- */
  --border:        #E2E4E8;
  --border-strong: #CDD1D8;

  /* ---- status colors ---------------------------------------------------- */
  --positive:      #16A34A;
  --positive-wash: #EFFAF3;
  --caution:       #D97706;
  --caution-wash:  #FEF6E7;
  --critical:      #DC2626;
  --critical-wash: #FDEDED;

  /* ---- geometry — one scale, used everywhere ---------------------------- */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 240px;
  --measure: 1040px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .06);

  /* ---- type ------------------------------------------------------------- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;

  --ease: cubic-bezier(.2, .6, .3, 1);
  --dur: 150ms;

  /* ---- legacy aliases — keeps older selectors resolving correctly -------- */
  --color-primary: var(--accent);
  --color-primary-light: var(--accent-wash);
  --color-success: var(--positive);
  --color-warning: var(--caution);
  --color-danger: var(--critical);
  --color-text-primary: var(--text);
  --color-text-secondary: var(--text-2);
  --color-border: var(--border);
  --color-bg: var(--bg);
  --color-surface: var(--surface);
  --color-surface-alt: var(--surface-alt);
  --font-display: var(--font-sans); /* display font retired — same as body */
}

[data-theme="dark"] {
  --accent:        #5B8DEF;
  --accent-hover:  #7BA3F5;
  --accent-wash:   #16233D;

  --bg:            #121316;
  --surface:       #191B1F;
  --surface-alt:   #212328;

  --text:          #F1F2F4;
  --text-2:        #A8ADB7;
  --text-3:        #74798A;

  --border:        #2A2D33;
  --border-strong: #3A3E46;

  --positive:      #4ADE80;
  --positive-wash: #12271A;
  --caution:       #FBBF24;
  --caution-wash:  #2C2210;
  --critical:      #F87171;
  --critical-wash: #2E1616;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
}

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

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

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

[hidden] { display: none !important; }

h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
svg { display: block; }
table { border-collapse: collapse; }

::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* =========================================================== type ==== */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-3);
  line-height: 1;
}

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

.meta {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.5;
}

kbd {
  display: inline-block;
  min-width: 17px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-2);
  text-align: center;
}

code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
}

/* ================================================== card primitive ==== */
/* The one reusable surface. Everything that used to be a "section" of
   ruled text is now just a card — swap --radius / --shadow-sm above and
   every card in the app changes at once. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 20px 22px;
}

/* ========================================================= layout ==== */
.app { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: 32px 36px 80px;
}

.main > .view,
.main > section { max-width: var(--measure); }

.view { animation: rise 200ms var(--ease); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---- workspace: inputs on the left, the message on the right ------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr);
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}

.workspace-col { min-width: 0; }
.workspace-col > .section:first-child { margin-top: 0; }

/* The message stays in view while the left column is filled in. */
.workspace-side { position: sticky; top: 24px; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .workspace-side { position: static; }
  .workspace-col > .section:first-child { margin-top: 20px; }
  .workspace > .workspace-col:first-child > .section:first-child { margin-top: 0; }
}

/* ---- section: a card wrapping a labeled block of content ----------- */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 22px 24px;
  margin-top: 20px;
}
.page-head + .section { margin-top: 24px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-head .eyebrow { display: flex; align-items: center; gap: 8px; }

.section-note { font-size: 12.5px; color: var(--text-3); }

/* ---- page header -------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--text);
}

.page-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.page-sub { font-size: 13.5px; color: var(--text-2); margin-top: 8px; }

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ======================================================== buttons ==== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur);
}

.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt); border-color: var(--border-strong); }

.btn-danger { background: var(--critical); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }

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

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }

/* Text link that behaves like a button. */
.btn-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}
.btn-link:hover { color: var(--accent-hover); text-decoration: underline; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); background: var(--surface-alt); }
.icon-btn.danger:hover { color: var(--critical); background: var(--critical-wash); }

/* ========================================================== tags ===== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-alt);
  white-space: nowrap;
}
.tag svg { width: 12px; height: 12px; }

.tag-accent   { background: var(--accent-wash);   color: var(--accent); }
.tag-caution  { background: var(--caution-wash);  color: var(--caution); }
.tag-critical { background: var(--critical-wash); color: var(--critical); }
.tag-positive { background: var(--positive-wash); color: var(--positive); }

/* ==================================================== empty state ==== */
.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 28px 4px 8px;
  max-width: 44ch;
}
.empty svg { width: 26px; height: 26px; color: var(--text-3); margin-bottom: 6px; }
.empty strong { font-size: 14.5px; font-weight: 600; color: var(--text); }
.empty span { font-size: 13px; color: var(--text-2); }

/* ====================================================== skeletons ==== */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent,
              color-mix(in srgb, var(--surface) 65%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.skeleton-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.skeleton-strip .skeleton { height: 84px; border-radius: var(--radius-lg); }
.skeleton-line { height: 13px; margin-bottom: 10px; }

/* ========================================================= toasts ==== */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 380px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 180ms var(--ease);
}
.toast.leaving { animation: toast-out 150ms var(--ease) forwards; }
.toast .toast-icon { flex: none; display: grid; place-items: center; color: var(--text-3); }
.toast .toast-icon svg { width: 15px; height: 15px; }
.toast.success .toast-icon { color: var(--positive); }
.toast.error   .toast-icon { color: var(--critical); }
.toast.info    .toast-icon { color: var(--accent); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ==================================================== scroll bars ==== */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ===================================================== responsive ==== */
@media (max-width: 1080px) {
  .main { padding: 28px 24px 72px; }
  .page-title { font-size: 21px; }
}

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .main { margin-left: 0; width: 100%; padding: 20px 16px 64px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .toast { max-width: none; }
}

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