/* ============================================================
   FoxChat — design system core
   Tokens + primitives shared by the landing, dashboard and admin.
   OBS overlays never load this file.
   ============================================================ */

:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #09080f;
  --bg-subtle: #0d0c14;
  --surface: #131118;
  --surface-2: #18151f;
  --surface-3: #1e1a28;
  --surface-hover: #1b1824;
  --line: #272334;
  --line-strong: #3a3450;
  --line-soft: #ffffff0f;

  /* text */
  --text: #f3f1f9;
  --text-2: #b6b0c4;
  --text-3: #8b8499;
  --muted: #b6b0c4;   /* legacy alias */
  --faint: #8b8499;   /* legacy alias */

  /* brand */
  --primary: #8b5cf6;
  --primary-hover: #9d75ff;
  --primary-active: #7c4fe0;
  --accent: #8b5cf6;  /* legacy alias, required by settings.css / alerts.css */
  --cyan: #2dd4c8;
  --purple: #8b5cf6;

  /* status */
  --success: #3ecf9a;
  --warning: #f0b153;
  --danger: #f2688c;
  --info: #5aa7ff;
  --green: #3ecf9a;   /* legacy alias */
  --amber: #f0b153;   /* legacy alias */
  --blue: #5aa7ff;    /* legacy alias */
  --pink: #f2688c;    /* legacy alias */

  --grad: linear-gradient(135deg, #8b5cf6, #6e8bff 55%, #2dd4c8);
  --grad-soft: linear-gradient(135deg, #8b5cf62b, #2dd4c81f);
  --ring: 0 0 0 3px #8b5cf655;

  /* geometry */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px #00000052, 0 10px 30px #00000038;
  --shadow-2: 0 24px 70px #00000075;

  /* motion */
  --dur-1: .15s;
  --dur-2: .22s;
  --ease: cubic-bezier(.2, .7, .3, 1);

  /* layout */
  --maxw: 1160px;
  --panel-maxw: 1360px;
  --header-h: 56px;

  font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html {
  min-height: 100%;
  overflow-y: auto;
  scroll-behavior: smooth;
}
body {
  /* `clip` does not create a second scroll container, unlike `hidden`. */
  overflow-x: clip;
}
[id] { scroll-margin-top: calc(var(--header-h) + 18px); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
}

button, input, select, textarea { font: inherit; }
a { color: inherit; }
::selection { background: #8b5cf655; color: #fff; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

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

/* ---------------- Shell / loading ---------------- */
.shell { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 0 22px 80px; }
.shell.dashboard-shell { max-width: none; padding: 0; }
.shell.landing-page { max-width: none; padding: 0; }

.loading-card { height: 70vh; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--text-2); }
.spinner { width: 26px; height: 26px; border: 3px solid #ffffff14; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Buttons ---------------- */
.button {
  border: 0;
  border-radius: var(--radius);
  padding: 11px 18px;
  min-height: 40px;
  font-weight: 650;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6, #7c4fe0);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 20px #8b5cf62e;
  transition: background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.button:hover { background: linear-gradient(135deg, #9d75ff, #8b5cf6); box-shadow: 0 8px 26px #8b5cf642; }
.button:active { transform: translateY(1px); box-shadow: 0 4px 14px #8b5cf62e; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.button:focus-visible { box-shadow: var(--ring), 0 6px 20px #8b5cf62e; }

.button.secondary { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); box-shadow: none; }
.button.secondary:hover { background: var(--surface-3); border-color: var(--line-strong); }
.button.ghost-button { background: transparent; border: 1px solid var(--line); color: var(--text-2); box-shadow: none; }
.button.ghost-button:hover { border-color: var(--line-strong); color: var(--text); background: #ffffff08; }
.button.danger { background: #2b141d; border: 1px solid #5c2640; color: #ff9dc3; box-shadow: none; }
.button.danger:hover { background: #381825; border-color: #7a3252; }
.button.sm { padding: 8px 13px; min-height: 34px; font-size: 13px; border-radius: 10px; }
.button.block-button { width: 100%; margin-top: 14px; }
.button .line-icon { width: 16px; height: 16px; }
.button[aria-busy="true"] { opacity: .6; pointer-events: none; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 13px;
  min-height: 36px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.icon-button:hover { border-color: var(--line-strong); background: var(--surface-3); }
.icon-button.ghost { background: transparent; }
.icon-button.ghost:hover { border-color: var(--primary); color: #fff; }
.icon-button.spinning { opacity: .6; pointer-events: none; }
.icon-button:disabled { opacity: .45; cursor: not-allowed; }
.icon-button .line-icon { width: 15px; height: 15px; }

/* ---------------- Cards ---------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-1);
}
.card h2 { font-size: 17px; margin: 0 0 6px; letter-spacing: -.2px; }
.card-sub { color: var(--text-2); font-size: 13.5px; line-height: 1.55; margin: 0 0 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.card-head h2 { margin: 0 0 5px; }
.card-head .card-sub { margin: 0; }
.card-icon { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--grad-soft); border: 1px solid var(--line); color: #cdbcff; }

.field-label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin: 0 0 7px; }
.input { width: 100%; min-width: 0; min-height: 40px; background: #0d0c13; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 13px; outline: 0; transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease); }
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px #f2688c40; }

.link-box { display: flex; align-items: center; gap: 10px; background: #0d0c13; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 7px 7px 12px; }
.link-box code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #c4bfd0; font-size: 12px; flex: 1; min-width: 0; font-family: "SFMono-Regular", ui-monospace, monospace; }
.tag { display: inline-flex; align-items: center; font-size: 10.5px; padding: 4px 8px; border-radius: 999px; font-weight: 750; letter-spacing: .4px; flex: 0 0 auto; }
.tag.live { color: #79ecc2; background: #12332944; border: 1px solid #3ecf9a3d; }
.tag.test { color: #d2c2ff; background: #281f4466; border: 1px solid #8b5cf63d; }

.connected { display: inline-flex; align-items: center; gap: 9px; color: #6fe2bb; font-size: 13px; font-weight: 600; }
.connected::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px #3ecf9a88; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: #c2b2ff; font-weight: 750; font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; }
.eyebrow-mini { color: #9e89ff; font-size: 10px; font-weight: 800; letter-spacing: 1.1px; text-transform: uppercase; }

/* ---------------- Status chip ---------------- */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  min-height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff06;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.status-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }
.status-chip.is-ok { border-color: #3ecf9a3d; color: #8ce8c6; background: #12332933; }
.status-chip.is-ok i { background: var(--success); box-shadow: 0 0 8px #3ecf9a88; }
.status-chip.is-warn { border-color: #f0b1533d; color: #f2c986; background: #3826123e; }
.status-chip.is-warn i { background: var(--warning); }
.status-chip.is-err { border-color: #f2688c42; color: #ff9dbb; background: #34121e44; }
.status-chip.is-err i { background: var(--danger); }
.status-chip.is-live { border-color: #f2688c55; color: #ff9dbb; background: #34121e44; }
.status-chip.is-live i { background: #ff5c86; box-shadow: 0 0 9px #ff5c86; animation: chip-pulse 1.6s infinite; }
.status-chip.is-info { border-color: #5aa7ff3d; color: #9dc7ff; background: #12233c44; }
.status-chip.is-muted { border-color: #ffffff14; color: var(--text-3); background: #ffffff08; }
.status-chip.is-muted i { background: var(--text-3); }
@keyframes chip-pulse { 50% { opacity: .55; } }

/* ---------------- Banner (page-level problems) ---------------- */
.banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13.5px;
}
.banner > .banner-ico { flex: 0 0 auto; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.banner > div { flex: 1 1 260px; min-width: 0; }
.banner strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.banner p { margin: 0; color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.banner .button { flex: 0 0 auto; }
.banner.is-warn { border-color: #f0b15340; background: #f0b1530f; }
.banner.is-warn .banner-ico { background: #f0b15322; color: var(--warning); }
.banner.is-danger { border-color: #f2688c40; background: #f2688c0e; }
.banner.is-danger .banner-ico { background: #f2688c22; color: var(--danger); }
.banner.is-info { border-color: #5aa7ff36; background: #5aa7ff0d; }
.banner.is-info .banner-ico { background: #5aa7ff21; color: var(--info); }
.banner .banner-ico .line-icon { width: 17px; height: 17px; }

/* ---------------- Stat tile ---------------- */
.stat-tile {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.stat-tile b { font-size: 21px; font-weight: 750; letter-spacing: -.3px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-tile span { color: var(--text-2); font-size: 12.5px; }
.stat-tile small { color: var(--text-3); font-size: 12px; }
.stat-tile.is-live b { color: #ff8fb0; }

/* ---------------- Empty / error states ---------------- */
.empty-state, .error-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 30px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-2);
}
.empty-state .line-icon, .error-state .line-icon { width: 26px; height: 26px; color: var(--text-3); }
.empty-state strong, .error-state strong { color: var(--text); font-size: 14px; }
.empty-state p, .error-state p { margin: 0; max-width: 420px; font-size: 13px; line-height: 1.55; }
.error-state { border-color: #f2688c4d; }
.error-state .line-icon { color: var(--danger); }
.empty-state .button, .error-state .button { margin-top: 8px; }

/* ---------------- Skeleton ---------------- */
.skeleton { display: grid; gap: 10px; }
.sk-line, .sk-block { border-radius: 8px; background: linear-gradient(100deg, #ffffff08 40%, #ffffff12 50%, #ffffff08 60%); background-size: 200% 100%; animation: sk-shimmer 1.4s infinite linear; }
.sk-line { height: 13px; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-block { height: 90px; }
@keyframes sk-shimmer { to { background-position: -200% 0; } }

/* ---------------- Copy field ---------------- */
.copy-field { display: flex; align-items: center; gap: 8px; min-width: 0; background: #0d0c13; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 6px 6px 12px; }
.copy-field code { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #c4bfd0; font-size: 12px; font-family: "SFMono-Regular", ui-monospace, monospace; }
.copy-field code.is-masked { letter-spacing: 2px; color: var(--text-3); }
.copy-field .icon-button { min-height: 32px; padding: 6px 11px; border-radius: 8px; flex: 0 0 auto; }
.copy-field .icon-button.is-copied { border-color: #3ecf9a66; color: #8ce8c6; }

/* ---------------- Dialog (confirm / modal) ---------------- */
.fc-dialog { border: 0; padding: 0; background: transparent; max-width: min(440px, calc(100vw - 32px)); width: 100%; }
.fc-dialog::backdrop { background: #05040acc; backdrop-filter: blur(4px); }
.fc-dialog-shell { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); padding: 22px; display: grid; gap: 10px; }
.fc-dialog-shell h3 { margin: 0; font-size: 16px; letter-spacing: -.2px; }
.fc-dialog-shell p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.fc-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.fc-dialog[open] { animation: dialog-in .18s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------- Toast ---------------- */
.toast { position: fixed; z-index: 70; left: 50%; bottom: 26px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; max-width: min(480px, calc(100vw - 32px)); background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 11px 17px; font-size: 13px; font-weight: 550; box-shadow: var(--shadow-2); transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Line icons ---------------- */
.line-icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.line-icon.is-fill { fill: none; stroke: none; }
