/* ============================================================
   M.A.T.T. — Base Stylesheet
   Fonts: Sora (body) + JetBrains Mono (code)
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg:         #080b12;
  --surface:    #0f1320;
  --surface-2:  #171c2e;
  --border:     #1f2437;
  --border-2:   #2a3050;

  /* Text */
  --text:       #dde1f5;
  --text-dim:   #4d566e;
  --text-mid:   #8892aa;

  /* Semantic */
  --danger:     #ef4444;
  --success:    #10b981;
  --warning:    #f59e0b;

  /* Elevation */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.5);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.6);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.7);

  /* Motion */
  --transition: 0.15s ease;

  /* Layout */
  --radius:     10px;
  --radius-sm:  6px;
  --radius-lg:  14px;

  /* Typography */
  --font:       'Sora', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'Courier New', monospace;
}

/* ── Body ───────────────────────────────────────────────────── */
body {
  background: var(--bg);
  /* Subtle noise texture via SVG */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Links ──────────────────────────────────────────────────── */
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { text-decoration: underline; opacity: 0.85; }

/* ── Layout ─────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 248px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, var(--accent, #6366f1) 40%, transparent);
  opacity: 0.15;
  pointer-events: none;
}

.sidebar-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent, #6366f1);
  text-shadow: 0 0 20px color-mix(in srgb, var(--accent, #6366f1) 40%, transparent);
}

.sidebar-header p {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover { background: var(--border); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface-2); color: var(--text); }

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── SVG icons ──────────────────────────────────────────────── */
.icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-sm { width: 12px; height: 12px; }
.icon-md { width: 16px; height: 16px; }
.icon-lg { width: 18px; height: 18px; }

/* ── Forms & inputs ─────────────────────────────────────────── */
input, textarea, select {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #6366f1) 15%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }

select option { background: var(--surface); }

/* ── Buttons ────────────────────────────────────────────────── */
button, .btn {
  background: var(--accent, #6366f1);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  letter-spacing: 0.01em;
}
button:hover, .btn:hover {
  background: var(--accent-dim, #4f52c8);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent, #6366f1) 25%, transparent);
}
button:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: none;
}

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 0 16px rgba(239,68,68,0.2); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
  border-left: 3px solid;
}
.alert-error {
  background: rgba(239,68,68,0.08);
  border-color: var(--danger);
  color: #fca5a5;
}
.alert-success {
  background: rgba(16,185,129,0.08);
  border-color: var(--success);
  color: #6ee7b7;
}

/* ── Utility ─────────────────────────────────────────────────── */
.text-dim { color: var(--text-dim); }
.text-mid { color: var(--text-mid); }
.text-sm  { font-size: 12px; }
.text-xs  { font-size: 11px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }

/* ── Scrollbars ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }

/* ── Markdown content ────────────────────────────────────────── */
.md h1, .md h2, .md h3 { margin: 14px 0 6px; font-weight: 600; line-height: 1.3; }
.md h1 { font-size: 1.3em; }
.md h2 { font-size: 1.15em; }
.md h3 { font-size: 1em; }
.md p { margin: 6px 0; }
.md p:first-child { margin-top: 0; }
.md p:last-child  { margin-bottom: 0; }
.md ul, .md ol { padding-left: 20px; margin: 6px 0; }
.md li { margin: 3px 0; }
.md li > p { margin: 0; }
.md code {
  background: rgba(0,0,0,0.35);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: color-mix(in srgb, var(--accent, #6366f1) 80%, var(--text));
}
.md pre {
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
}
.md pre code { background: none; padding: 0; font-size: 0.85em; color: var(--text); }
.md blockquote {
  border-left: 2px solid var(--accent, #6366f1);
  padding-left: 12px;
  color: var(--text-mid);
  margin: 8px 0;
  font-style: italic;
}
.md strong { font-weight: 700; }
.md em { font-style: italic; }
.md a { color: var(--accent, #6366f1); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 12px; }
.md th, .md td { border: 1px solid var(--border-2); padding: 6px 10px; text-align: left; }
.md th { background: rgba(0,0,0,0.25); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-mid); }

/* ── Card component ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}

/* ── Badge ───────────────────────────────────────────────────── */
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-superuser {
  background: color-mix(in srgb, var(--accent, #6366f1) 20%, transparent);
  color: var(--accent, #6366f1);
  border: 1px solid color-mix(in srgb, var(--accent, #6366f1) 40%, transparent);
}
.badge-user { background: var(--border); color: var(--text-mid); border: 1px solid var(--border-2); }
.badge-inactive { background: rgba(239,68,68,0.1); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
