/* CC Analytics AI Gateway — dashboard app shell. Deliberately separate from
   style.css: this is a developer-platform surface, not a marketing page —
   its own dark-first technical palette, its own density, per the AI Gateway
   architecture spec. Scoped under .aig-* / #aigApp to never bleed into the
   rest of the site if both stylesheets are ever loaded together. */

#aigApp {
  --bg: #0B0E14; --surface: #12161F; --surface-2: #171C27; --surface-hover: #1D2330; --surface-selected: #1B2A33;
  --border: #262D3A; --border-strong: #333C4C;
  --heading: #F1F4F9; --text: #DCE1EA; --muted: #8E97AB; --subtle: #5F6A80;
  --accent: #3FC2D6; --accent-fg: #04222A; --accent-soft: #12313A;
  --success: #4CC98A; --success-bg: #123023;
  --warning: #E0A93F; --warning-bg: #332A12;
  --danger: #E17E7E; --danger-bg: #331A1A;
  --radius-control: 6px; --radius-surface: 10px; --radius-card: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --font-sans: 'Inter', -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  position: fixed; inset: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 13.5px; line-height: 1.5;
  display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 100%;
}

#aigApp *, #aigApp *::before, #aigApp *::after { box-sizing: border-box; }
#aigApp a { color: inherit; text-decoration: none; }
#aigApp button { font-family: inherit; cursor: pointer; }
#aigApp code, #aigApp .mono { font-family: var(--font-mono); }
#aigApp :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Sidebar ---------- */
.aig-sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
.aig-brand { padding: 20px 18px 16px; border-bottom: 1px solid var(--border); }
.aig-brand .name { font-weight: 700; font-size: 14.5px; color: var(--heading); }
.aig-brand .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.aig-nav { padding: 14px 10px; flex: 1; }
.aig-nav-group { margin-bottom: 18px; }
.aig-nav-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); padding: 0 10px; margin-bottom: 6px; }
.aig-nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--radius-control);
  color: var(--muted); font-size: 13px; border-left: 2px solid transparent; background: none; border-top: none; border-right: none; border-bottom: none; width: 100%; text-align: left;
}
.aig-nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.aig-nav-item:hover { background: var(--surface-hover); color: var(--text); }
.aig-nav-item.active { background: var(--surface-selected); color: var(--heading); border-left-color: var(--accent); font-weight: 600; }
.aig-sidebar-foot { padding: 12px 10px; border-top: 1px solid var(--border); }
.aig-sidebar-foot .aig-nav-item { color: var(--muted); }

/* ---------- Header ---------- */
.aig-main { display: grid; grid-template-rows: 56px 1fr; min-width: 0; }
.aig-header {
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: rgba(18,22,31,.85); backdrop-filter: blur(6px);
}
.aig-header h1 { font-size: 15px; font-weight: 600; color: var(--heading); margin: 0; }
.aig-header-right { display: flex; align-items: center; gap: 14px; }
.aig-status { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.aig-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); }
.aig-status-dot.ok { background: var(--success); }
.aig-status-dot.bad { background: var(--danger); }
.aig-content { overflow-y: auto; padding: 24px 28px 60px; }

/* ---------- Primitives ---------- */
.aig-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.aig-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.aig-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .aig-grid-4 { grid-template-columns: repeat(2, 1fr); } .aig-grid-2 { grid-template-columns: 1fr; } }

.aig-metric-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--subtle); }
.aig-metric-value { font-size: 24px; font-weight: 700; color: var(--heading); margin-top: 8px; font-variant-numeric: tabular-nums; }
.aig-metric-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.aig-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px;
  border-radius: var(--radius-control); font-size: 12.5px; font-weight: 600; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}
.aig-btn:hover { background: var(--surface-hover); }
.aig-btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.aig-btn.primary:hover { filter: brightness(1.08); }
.aig-btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.aig-btn.danger:hover { background: var(--danger-bg); }
.aig-btn:disabled { opacity: .5; cursor: not-allowed; }
.aig-btn-sm { height: 26px; padding: 0 10px; font-size: 11.5px; }

.aig-input, .aig-select {
  height: 34px; padding: 0 10px; border-radius: var(--radius-control); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-size: 13px; font-family: inherit; width: 100%;
}
.aig-input:focus, .aig-select:focus { border-color: var(--accent); }
.aig-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.aig-field { margin-bottom: 14px; }

.aig-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-surface); }
.aig-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.aig-table th { text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.aig-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.aig-table tr:last-child td { border-bottom: none; }
.aig-table tr:hover td { background: var(--surface-hover); }

.aig-badge { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.aig-badge.active { color: var(--success); background: var(--success-bg); }
.aig-badge.revoked { color: var(--danger); background: var(--danger-bg); }
.aig-badge.test { color: var(--warning); background: var(--warning-bg); }

.aig-empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13px; }
.aig-empty .icon { font-size: 28px; margin-bottom: 10px; opacity: .5; }

.aig-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.aig-page-header h2 { font-size: 18px; margin: 0; color: var(--heading); }
.aig-page-header p { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

/* ---------- Onboarding / connect gate ---------- */
.aig-connect { max-width: 420px; margin: 80px auto; text-align: center; }
.aig-connect .aig-card { text-align: left; }

/* ---------- Playground ---------- */
.aig-playground { display: grid; grid-template-columns: 1fr 280px; gap: 16px; height: calc(100vh - 160px); min-height: 480px; }
@media (max-width: 900px) { .aig-playground { grid-template-columns: 1fr; height: auto; } }
.aig-chat-panel { display: flex; flex-direction: column; }
.aig-chat-log { flex: 1; overflow-y: auto; padding: 4px 2px; }
.aig-chat-msg { max-width: 80%; padding: 10px 13px; border-radius: 10px; margin-bottom: 10px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.aig-chat-msg.user { background: var(--accent-soft); color: var(--heading); margin-left: auto; }
.aig-chat-msg.assistant { background: var(--surface-2); color: var(--text); }
.aig-chat-msg.system-note { background: none; color: var(--subtle); font-family: var(--font-mono); font-size: 11px; text-align: center; max-width: 100%; }
.aig-chat-form { display: flex; gap: 8px; margin-top: 12px; }
.aig-chat-form .aig-input { flex: 1; }
.aig-meta-list { font-size: 11.5px; color: var(--muted); }
.aig-meta-list dt { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; font-size: 9.5px; color: var(--subtle); margin-top: 10px; }
.aig-meta-list dd { margin: 2px 0 0; color: var(--text); }

.aig-toast { position: fixed; bottom: 20px; right: 20px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-surface); padding: 12px 16px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.4); max-width: 340px; z-index: 50; }
.aig-toast.error { border-color: var(--danger); color: var(--danger); }

[hidden] { display: none !important; }
