/* ============================================================
   FoxChat — design system (base tokens, shell, components)
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #08070e;
  --bg-soft: #0d0b16;
  --surface: #121019;
  --surface-2: #17141f;
  --surface-3: #1d1929;
  --line: #262232;
  --line-soft: #ffffff0f;
  --text: #f4f2fa;
  --muted: #a39daf;
  --faint: #746e81;
  --purple: #8b5cff;
  --accent: #8b5cff;
  --accent-2: #b45cff;
  --accent-3: #ff5ca0;
  --pink: #ff5ca0;
  --green: #37d39e;
  --amber: #ffb347;
  --blue: #4ca5ff;
  --grad: linear-gradient(135deg, #8b5cff, #b45cff 52%, #ff5ca0);
  --grad-soft: linear-gradient(135deg, #8b5cff33, #ff5ca022);
  --ring: 0 0 0 3px #8b5cff33;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --shadow-1: 0 12px 40px #00000055;
  --shadow-2: 0 30px 80px #00000070;
  --maxw: 1200px;
  --header-h: 72px;
  font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: hidden; }
[id] { scroll-margin-top: 90px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 600px at 78% -8%, #2a1a5e3d, transparent 60%),
    radial-gradient(900px 520px at 12% 6%, #5e1a4a30, transparent 55%),
    var(--bg);
}

/* Subtle dotted grid behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(#ffffff0a 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(circle at 50% 0%, #000 0, transparent 72%);
  opacity: .5;
}

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

/* ---------------- Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(22px, calc((100vw - var(--maxw)) / 2));
  border-bottom: 1px solid var(--line-soft);
  background: #08070ecc;
  backdrop-filter: blur(20px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -.4px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--grad); box-shadow: 0 8px 24px #8b5cff45; font-size: 18px; }
.brand-mark-text { font-size: 12px; font-weight: 900; letter-spacing: .4px; }
.brand span b { font-weight: 800; background: linear-gradient(90deg, #cdbcff, #ff8fc4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.status-pill { display: inline-flex; align-items: center; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; background: #ffffff06; }
.status-pill i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 8px; box-shadow: 0 0 10px var(--green); }

/* ---------------- Shell ---------------- */
.shell { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 40px 22px 90px; }
.shell.dashboard-shell { max-width: 1320px; padding-top: 28px; }

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

/* ---------------- Buttons ---------------- */
.button {
  border: 0;
  border-radius: 13px;
  padding: 13px 20px;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: var(--grad);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  box-shadow: 0 12px 30px #8b5cff33;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease, filter .18s ease;
}
.button:hover { transform: translateY(-2px); box-shadow: 0 16px 40px #8b5cff4a; }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.button.secondary { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); box-shadow: none; }
.button.secondary:hover { border-color: #4a3f6e; }
.button.ghost-button { background: #ffffff07; border: 1px solid var(--line); color: var(--text); box-shadow: none; }
.button.ghost-button:hover { border-color: #4a3f6e; background: #ffffff0e; }
.button.danger { background: #2a141d; border: 1px solid #5c2640; color: #ff9dc3; box-shadow: none; }
.button.danger:hover { background: #381825; border-color: #7a3252; }
.button.sm { padding: 9px 14px; font-size: 13px; border-radius: 11px; }
.button.block-button { width: 100%; margin-top: 16px; }

.icon-button { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 9px 13px; cursor: pointer; font-size: 12.5px; font-weight: 600; transition: .16s; }
.icon-button:hover { border-color: #4a3f6e; }
.icon-button.ghost { background: transparent; }
.icon-button.ghost:hover { border-color: var(--accent); color: #fff; }
.icon-button.spinning { opacity: .6; pointer-events: none; }

/* ---------------- Cards ---------------- */
.card {
  position: relative;
  background: linear-gradient(160deg, var(--surface), #100e17);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-1);
}
.card h2 { font-size: 18px; margin: 0 0 7px; letter-spacing: -.3px; }
.card-sub { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head h2 { margin: 0 0 6px; }
.card-head .card-sub { margin: 0; }
.card-icon { flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; font-size: 16px; font-weight: 800; background: var(--grad-soft); border: 1px solid var(--line); color: #cdbcff; }

.field-label { display: block; font-size: 12px; font-weight: 700; color: #cbc6d6; margin: 0 0 8px; }
.input { width: 100%; min-width: 0; background: #0b0a12; border: 1px solid var(--line); color: var(--text); border-radius: 11px; padding: 12px 14px; outline: 0; transition: .16s; }
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: var(--ring); }

.link-box { display: flex; align-items: center; gap: 10px; background: #0b0a12; border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 13px; }
.link-box code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #c4bfd0; font-size: 11.5px; flex: 1; min-width: 0; font-family: "SFMono-Regular", ui-monospace, monospace; }
.tag { font-size: 10px; padding: 5px 8px; border-radius: 999px; font-weight: 800; letter-spacing: .4px; flex: 0 0 auto; }
.tag.live { color: #79ecc2; background: #123329; }
.tag.test { color: #d2c2ff; background: #281f44; }

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

.eyebrow { display: inline-flex; align-items: center; color: #c2b2ff; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 1.6px; }
.gradient-text { background: linear-gradient(90deg, #c9b6ff, #ff86c2); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------------- Toast ---------------- */
.toast { position: fixed; z-index: 60; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #1b1826; border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; font-size: 13px; box-shadow: var(--shadow-2); transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Dashboard head ---------------- */
.dashboard-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.profile { display: flex; gap: 14px; align-items: center; }
.profile img, .avatar-fallback { width: 50px; height: 50px; border-radius: 15px; background: var(--grad); display: grid; place-items: center; font-weight: 800; object-fit: cover; }
.profile h1 { font-size: 23px; margin: 0 0 3px; letter-spacing: -.5px; }
.profile p { margin: 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 10px; }

@media (max-width: 560px) {
  .shell { padding: 28px 15px 70px; }
  .status-pill { display: none; }
  .card { padding: 18px; }
  .profile h1 { font-size: 19px; }
}
