/* ─── Theme Variables ─────────────────────────────────────────────────────── */
/* Light mode matches hookbridge.io brand (green accent, light bg) */

:root {
  --bg-primary: #f7f9f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8f4ec;
  --border: #d7e2d8;
  --text-primary: #0f1d14;
  --text-secondary: #5f6f63;
  --text-muted: #8b9a8f;
  --accent: #1d8f4b;
  --accent-hover: #187a3f;
  --accent-faint: #e8f4ec;
  --success: #1d8f4b;
  --warning: #9a6700;
  --danger: #cf222e;
  --code-bg: #0d1a12;
  --code-text: #d5f2dd;
  --shadow: 0 14px 40px rgba(15, 29, 20, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #0d1a12;
    --bg-secondary: #132218;
    --bg-tertiary: #1a3022;
    --border: #254432;
    --text-primary: #d5f2dd;
    --text-secondary: #8baa94;
    --text-muted: #5a7a63;
    --accent: #3fb950;
    --accent-hover: #56d364;
    --accent-faint: #1a3022;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --code-bg: #0a1410;
    --code-text: #d5f2dd;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  }
}

[data-theme="dark"] {
  --bg-primary: #0d1a12;
  --bg-secondary: #132218;
  --bg-tertiary: #1a3022;
  --border: #254432;
  --text-primary: #d5f2dd;
  --text-secondary: #8baa94;
  --text-muted: #5a7a63;
  --accent: #3fb950;
  --accent-hover: #56d364;
  --accent-faint: #1a3022;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --code-bg: #0a1410;
  --code-text: #d5f2dd;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg-primary: #f7f9f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8f4ec;
  --border: #d7e2d8;
  --text-primary: #0f1d14;
  --text-secondary: #5f6f63;
  --text-muted: #8b9a8f;
  --accent: #1d8f4b;
  --accent-hover: #187a3f;
  --accent-faint: #e8f4ec;
  --success: #1d8f4b;
  --warning: #9a6700;
  --danger: #cf222e;
  --code-bg: #0d1a12;
  --code-text: #d5f2dd;
  --shadow: 0 14px 40px rgba(15, 29, 20, 0.08);
}

/* ─── Reset & Base ────────────────────────────────────────────────────────── */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

code, pre, .mono {
  font-family: "SF Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; width: 100%; }

header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}

.logo:hover { text-decoration: none; color: var(--text-primary); }

.logo-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d8f4b 0%, #1a7f44 100%);
  display: grid;
  place-items: center;
  color: #f7fff5;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

main { flex: 1; padding: 32px 0; }

footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85em;
}

/* ─── Theme Toggle ────────────────────────────────────────────────────────── */

.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-toggle:hover { color: var(--text-primary); background: var(--border); }

/* ─── Landing Page ────────────────────────────────────────────────────────── */

.hero { text-align: center; padding: 60px 0 40px; }

.hero h1 {
  font-size: 2.2em;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.hero p {
  font-size: 1.15em;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto 32px;
}

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 1.05em;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.recent-bin {
  margin-top: 16px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: inline-block;
  font-size: 0.9em;
  color: var(--text-secondary);
}

.recent-bin a { font-weight: 600; }

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

.step {
  text-align: center;
  padding: 20px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9em;
  margin-bottom: 12px;
}

.step h3 { font-size: 1em; margin-bottom: 6px; }
.step p { font-size: 0.85em; color: var(--text-secondary); }

/* ─── Viewer Page ─────────────────────────────────────────────────────────── */

.section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.section h2 {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.url-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
}

.url-display code {
  flex: 1;
  font-size: 0.95em;
  color: var(--accent);
  word-break: break-all;
}

.copy-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  white-space: nowrap;
  transition: all 0.15s;
}

.copy-btn:hover { color: var(--text-primary); background: var(--border); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }

.curl-example {
  position: relative;
}

.curl-example pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.6;
  color: var(--code-text);
}

.curl-example .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* ─── Webhook Feed ────────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar input[type="text"] {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  width: 200px;
}

.toolbar input[type="text"]::placeholder { color: var(--text-muted); }

.btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  transition: background 0.15s;
}

.btn:hover { background: var(--border); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(207, 34, 46, 0.1); }

.status-text { color: var(--text-muted); font-size: 0.85em; margin-left: auto; }

.count-badge {
  background: var(--accent-faint);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8em;
}

/* ─── Webhook Table ───────────────────────────────────────────────────────── */

.wh-table { width: 100%; border-collapse: collapse; }

.wh-table thead th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 8px 12px;
  text-align: left;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.wh-table tbody tr {
  border-bottom: 1px solid var(--bg-tertiary);
  cursor: pointer;
  transition: background 0.1s;
}

.wh-table tbody tr:hover { background: var(--bg-tertiary); }
.wh-table tbody tr.expanded { background: var(--bg-tertiary); }

.wh-table td {
  padding: 8px 12px;
  font-size: 0.85em;
  vertical-align: top;
}

.td-time { color: var(--text-secondary); white-space: nowrap; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.8em; }
.td-method { font-weight: 600; }
.td-method-GET { color: var(--success); }
.td-method-POST { color: var(--accent); }
.td-method-PUT { color: var(--warning); }
.td-method-PATCH { color: var(--warning); }
.td-method-DELETE { color: var(--danger); }
.td-path { color: var(--accent); font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.8em; }
.td-size { color: var(--text-secondary); }

/* ─── Detail Row ──────────────────────────────────────────────────────────── */

.detail-row { display: none; }
.detail-row.open { display: table-row; }

.detail-content {
  padding: 16px;
  border: 1px solid var(--border);
  border-top: none;
  margin: 0 12px 12px;
  border-radius: 0 0 8px 8px;
  background: var(--bg-primary);
}

.detail-section { margin-bottom: 16px; }
.detail-section:last-child { margin-bottom: 0; }

.detail-section h3 {
  color: var(--text-secondary);
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.detail-section pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  font-size: 0.8em;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--code-text);
}

.kv-table { width: 100%; }

.kv-table td {
  padding: 3px 8px;
  font-size: 0.8em;
  border-bottom: 1px solid var(--bg-tertiary);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.kv-table td:first-child {
  color: var(--accent);
  white-space: nowrap;
  width: 1%;
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.75em;
  font-weight: 600;
}

.badge-truncated { background: rgba(207, 34, 46, 0.15); color: var(--danger); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state p { margin-bottom: 4px; }
.empty-state .hint { font-size: 0.85em; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .hero h1 { font-size: 1.6em; }
  .hero p { font-size: 1em; }
  .steps { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input[type="text"] { width: 100%; }
  .status-text { margin-left: 0; }
}
