/* ============================================================
   HookLens — dark developer theme
   Brand: Lens Blue primary, Deep Slate surfaces, Live Cyan accent.
   ============================================================ */

:root {
  /* Brand colors */
  --hl-primary:       #2563EB;   /* Lens Blue — buttons, links, focus */
  --hl-primary-hover: #1D4ED8;
  --brand:            #5B9BA2;   /* matches hooklens.svg */
  --hl-accent-cyan:   #06B6D4;   /* Live Cyan — connected, JSON keys */
  --hl-success:       #10B981;   /* Emerald — 200 OK */
  --hl-warning:       #F59E0B;   /* Amber — reconnecting */
  --hl-error:         #F43F5E;   /* Rose — disconnected, errors */

  /* Surfaces */
  --bg:        #0F172A;   /* Deep Slate — main background */
  --surface:   #1E293B;   /* Slate — cards, sidebar */
  --raised:    #334155;   /* Elevated — hover, active items */
  --border:    #334155;
  --border-2:  #475569;

  /* Text */
  --text:      #F8FAFC;   /* Off-white — primary */
  --text-dim:  #94A3B8;   /* Muted — timestamps, secondary */
  --text-mute: #64748B;
  --code-bg:   #0F172A;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  /* Spacing */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  /* Radii */
  --r-sm: 4px; --r-md: 6px; --r-lg: 10px; --r-full: 999px;

  /* Aliases — used by multiple components */
  --accent:   var(--hl-accent-cyan);
  --accent-h: var(--hl-accent-cyan);
  --amber:    var(--hl-warning);

  /* Misc */
  --shadow: 0 1px 3px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- buttons ---------- */

.btn-primary {
  background: var(--hl-primary);
  color: #fff;
  border: none;
  padding: var(--sp-3) var(--sp-5);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--hl-primary-hover); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--border);
  padding: var(--sp-2) var(--sp-3);
  font-size: 13px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font-sans);
}
.btn-secondary:hover { background: var(--border); border-color: var(--border-2); }
.btn-secondary:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: var(--sp-1) var(--sp-2);
  font-size: 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-sans);
}
.btn-ghost:hover { background: var(--raised); color: var(--text); }

/* ---------- brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.brand-logo {
  width: 56px; height: 56px;
  flex-shrink: 0;
}
.brand h1 {
  color: var(--brand);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.app-header .brand-logo { width: 36px; height: 36px; }
.app-header .brand h1 { color: var(--brand); font-size: 16px; margin: 0; }
.app-header .brand { margin: 0; gap: var(--sp-2); }

/* ============================================================
   Landing page
   ============================================================ */

.landing-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  gap: var(--sp-5);
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.landing-brand .brand-logo { width: 48px; height: 48px; }
.landing-brand h1 {
  color: var(--brand);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.landing-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-7);
  box-shadow: var(--shadow);
}


.landing-card .tagline {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: var(--sp-6);
  text-align: center;
}

.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.feature {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-dim);
}
.feature svg {
  width: 16px; height: 16px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}

.result-box { margin-top: var(--sp-6); }

.result-box h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  margin-bottom: var(--sp-3);
}

.url-box {
  display: flex;
  gap: var(--sp-2);
}
.url-box input {
  flex: 1;
  padding: var(--sp-3);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--accent-h);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}
.url-box input:focus { border-color: var(--accent); }

.warning {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--amber);
  font-size: 13px;
  margin: var(--sp-4) 0;
}
.warning svg { width: 15px; height: 15px; flex-shrink: 0; }

.result-box .btn-primary { margin-top: var(--sp-2); }

/* ============================================================
   Dashboard
   ============================================================ */

#bootSplash {
  position: fixed; inset: 0; display: flex; align-items: center;
  justify-content: center; background: var(--bg); z-index: 100;
  transition: opacity 0.25s ease; opacity: 1;
}
.bootSplash-hidden { opacity: 0; pointer-events: none; }
#bootSplash img { width: 96px; height: 96px; opacity: 0.85; }

/* ponytail: splash is JS-controlled, not CSS-hidden, so removing the splash
   cleans up without a paint race. */
.dashboard {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

body.boot-pending #dashboardRoot {
  position: absolute; width: 0; height: 0; overflow: hidden;
  /* position out of flow so the dashboard paints nothing under the splash.
     display:none would also work but triggers a reflow on reveal; this avoids
     that cost. */
}
body.boot-pending #dashboardRoot * { display: none !important; }

/* ---------- header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.app-header .brand h1 { color: var(--brand); font-size: 16px; margin: 0; }
.app-header .brand { margin: 0; gap: var(--sp-2); }

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--raised);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-mute);
  display: inline-block;
}
.status-pill.connected    { color: var(--hl-success); }
.status-pill.connected    .status-dot {
  background: var(--hl-success);
  animation: hl-pulse 2s infinite;
}
.status-pill.reconnecting { color: var(--hl-warning); }
.status-pill.reconnecting .status-dot { background: var(--hl-warning); animation: hl-pulse 1.2s infinite; }
.status-pill.disconnected,
.status-pill.error         { color: var(--hl-error); }
.status-pill.disconnected  .status-dot,
.status-pill.error         .status-dot { background: var(--hl-error); }

@keyframes hl-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); opacity: 1; }
  50%      { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); opacity: 0.6; }
}

.count-badge {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ---------- webhook URL bar ---------- */
.url-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.url-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  white-space: nowrap;
}
.url-bar input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--accent-h);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}

/* ---------- content layout ---------- */
.content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

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

.list-toolbar {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-box {
  flex: 1;
  position: relative;
}
.search-box svg {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-mute);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-7);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search-box input::placeholder { color: var(--text-mute); }
.search-box input:focus { border-color: var(--accent); }

.request-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2);
}

.request-item {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.request-item + .request-item { margin-top: var(--sp-1); }
.request-item:hover { background: var(--raised); }
.request-item.selected {
  background: var(--raised);
  border-color: var(--accent);
}

.method-badge {
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  flex-shrink: 0;
  min-width: 48px;
  text-align: center;
}
.method-badge.get    { background: rgba(59,130,246,0.15);  color: #60a5fa; }
.method-badge.post   { background: rgba(16,185,129,0.15);  color: var(--accent-h); }
.method-badge.put    { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.method-badge.patch  { background: rgba(168,85,247,0.15);  color: #c084fc; }
.method-badge.delete { background: rgba(239,68,68,0.15);   color: #f87171; }
.method-badge.other  { background: rgba(154,163,178,0.15); color: var(--text-dim); }

.item-main { flex: 1; min-width: 0; }
.item-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
}
.item-time {
  font-size: 12px;
  color: var(--text-mute);
  font-family: var(--font-mono);
}
.size-badge {
  font-size: 10px;
  color: var(--text-mute);
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 1px var(--sp-2);
  border-radius: var(--r-sm);
}
.item-preview {
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- detail pane ---------- */
.detail-pane {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  gap: var(--sp-3);
}
.detail-empty svg { width: 40px; height: 40px; opacity: 0.4; }

.detail-card {
  margin: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-top {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.detail-top .method-badge { min-width: auto; }
.detail-top h2 {
  font-size: 15px;
  font-weight: 600;
}
.detail-top .ts {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-mute);
  font-family: var(--font-mono);
}

.detail-path {
  padding: var(--sp-2) var(--sp-5);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.15);
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 var(--sp-2);
  flex-shrink: 0;
}
.tab {
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.12s, border-color 0.12s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-h); border-bottom-color: var(--accent); }

.tab-panel { display: none; padding: var(--sp-4) var(--sp-5); }
.tab-panel.active { display: block; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.section-head .lbl {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
}

.code-block {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.code-block pre {
  margin: 0;
  padding: var(--sp-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

/* JSON syntax tokens */
.tok-key   { color: var(--hl-accent-cyan); }
.tok-str   { color: var(--hl-success); }
.tok-num   { color: #fbbf24; }
.tok-bool  { color: #c084fc; }
.tok-null  { color: var(--text-mute); }

.kv-list { display: flex; flex-direction: column; }
.kv-row {
  display: grid;
  grid-template-columns: minmax(120px, 240px) 1fr;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
}
.kv-row:nth-child(odd) { background: rgba(255,255,255,0.02); }
.kv-key { color: #7dd3fc; word-break: break-all; }
.kv-val { color: var(--text-dim); word-break: break-all; }

/* ponytail: replaces inline styles so CSP can drop 'unsafe-inline' */
.kv-empty { color: var(--text-mute); padding: var(--sp-3); }

/* ---------- empty states ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  color: var(--text-mute);
  padding: var(--sp-7);
  text-align: center;
  height: 100%;
}
.empty-state svg { width: 32px; height: 32px; opacity: 0.4; }
.empty-state .big { font-size: 14px; color: var(--text-dim); }
.empty-state .small { font-size: 12px; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }
