/* ============================================================
   Webhook Inspector — 扁平左右布局（支持深 / 浅主题）
   左侧请求列表，右侧请求内容；无圆角卡片、无阴影。
   ============================================================ */

/* ---------- 深主题（默认） ---------- */
:root {
  --bg-0: #0b1020;
  --bg-1: #0f172a;
  --bg-2: #111827;
  --panel: var(--bg-1);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.4);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --inset-bg: rgba(2, 6, 23, 0.6);
  --band: rgba(148, 163, 184, 0.06);
  --code-bg: #060b18;
  --code-text: #cbd5e1;
  --c-cyan: #38bdf8;
  --c-indigo: #6366f1;
  --c-teal: #22d3ee;
  --m-get: #34d399;
  --m-post: #60a5fa;
  --m-put: #fbbf24;
  --m-delete: #f87171;
  --m-patch: #a78bfa;
  --m-default: #94a3b8;
  --ok: #34d399;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Poppins", "Roboto", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --accent-soft: rgba(99, 102, 241, 0.16);
}

/* ---------- 浅主题 ---------- */
[data-theme="light"] {
  --bg-0: #eef2f9;
  --bg-1: #e7ecf5;
  --bg-2: #dde4ef;
  --panel: #ffffff;
  --border: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.24);
  --text: #0f172a;
  --text-dim: #51607a;
  --inset-bg: rgba(15, 23, 42, 0.045);
  --band: rgba(15, 23, 42, 0.03);
  --code-bg: #f1f5f9;
  --code-text: #1e293b;
  --c-cyan: #0284c7;
  --c-indigo: #4f46e5;
  --c-teal: #0d9488;
  --m-get: #059669;
  --m-post: #2563eb;
  --m-put: #d97706;
  --m-delete: #dc2626;
  --m-patch: #7c3aed;
  --m-default: #64748b;
  --ok: #059669;
  --accent-soft: rgba(79, 70, 229, 0.12);
}

/* 系统偏好为浅色且用户未手动指定时，自动使用浅主题 */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-0: #eef2f9;
    --bg-1: #e7ecf5;
    --bg-2: #dde4ef;
    --panel: #ffffff;
    --border: rgba(15, 23, 42, 0.12);
    --border-strong: rgba(15, 23, 42, 0.24);
    --text: #0f172a;
    --text-dim: #51607a;
    --inset-bg: rgba(15, 23, 42, 0.045);
    --band: rgba(15, 23, 42, 0.03);
    --code-bg: #f1f5f9;
    --code-text: #1e293b;
    --c-cyan: #0284c7;
    --c-indigo: #4f46e5;
    --c-teal: #0d9488;
    --m-get: #059669;
    --m-post: #2563eb;
    --m-put: #d97706;
    --m-delete: #dc2626;
    --m-patch: #7c3aed;
    --m-default: #64748b;
    --ok: #059669;
    --accent-soft: rgba(79, 70, 229, 0.12);
  }
}

* { box-sizing: border-box; }

/* 全局隐藏滚动条（仍保留滚动功能） */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--sans);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-0), var(--bg-1) 60%, var(--bg-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---------- 左右布局 ---------- */
/* 区块之间留出间隙，露出页面渐变背景作为“边界”，靠背景色块区分区域 */
.app {
  display: flex; gap: 0; padding: 16px; height: 100vh; overflow: hidden;
}

/* 可拖拽分隔条 */
.splitter {
  flex: none;
  width: 16px;
  cursor: col-resize;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  touch-action: none;
}
.splitter::after {
  content: "";
  width: 4px; height: 48px;
  border-radius: 999px;
  background: var(--border-strong);
  opacity: 0.45;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.splitter:hover::after,
.splitter.dragging::after { opacity: 1; background: var(--c-cyan); }

/* 左侧栏 */
.sidebar {
  width: 380px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 18px;
  overflow: hidden;
}

.sidebar-top {
  padding: 18px 18px 14px;
  background: var(--band);
}

.url-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--inset-bg);
  border-radius: 10px;
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--c-cyan);
  overflow-x: auto;
  white-space: nowrap;
}
.url-box .method-tag {
  flex: none;
  font-family: var(--sans);
  font-size: 11px; font-weight: 700;
  color: #0b1020; background: var(--c-teal);
  padding: 3px 8px; border-radius: 6px;
}

.url-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; justify-content: center; }
.url-row .btn,
.url-row .btn.primary,
.url-row .btn.ghost { background: #e9eef6; color: #0f172a; flex: 1 1 0; min-width: 84px; }
.url-row .btn:hover,
.url-row .btn.primary:hover,
.url-row .btn.ghost:hover { background: #d8e0ea; color: #0f172a; }

.sidebar-meta {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-dim);
}
.sidebar-meta .poll-state { display: flex; align-items: center; gap: 7px; }
.sidebar-meta .poll-state .live {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  animation: pulse 1.6s ease-in-out infinite;
}
.sidebar-meta .poll-state.stopped .live { background: var(--m-delete); animation: none; }
.sidebar-meta .updated { font-size: 13px; color: var(--text-dim); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.req-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; background: var(--band);
}
.req-head h2 { font-size: 14px; margin: 0; font-weight: 600; }
.req-head .count {
  font-size: 12px; color: var(--text-dim);
  background: var(--inset-bg); padding: 3px 9px; border-radius: 999px;
}

.req-list { flex: 1; overflow-y: auto; padding: 10px; }

.req-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer; transition: background 0.15s ease;
  margin-bottom: 4px;
}
.req-item:hover { background: var(--band); }
.req-item.active { background: rgba(56, 189, 248, 0.16); }
/* 选中态左侧用背景色块作为强调，不用边框/阴影 */
.req-item.active::before {
  content: ""; position: absolute; left: 0; top: 14%; bottom: 14%;
  width: 4px; border-radius: 999px; background: var(--c-cyan);
}
.req-item.enter { animation: slideIn 0.45s cubic-bezier(0.21, 1, 0.3, 1); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}
.req-item .path { flex: 1; min-width: 0; }
.req-item .path .p { font-family: var(--mono); font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-item .path .t { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* 方法徽标 */
.badge {
  flex: none;
  font-family: var(--sans);
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  padding: 4px 9px; min-width: 56px; text-align: center;
  color: #07111f; border-radius: 7px;
}
.badge.GET { background: var(--m-get); }
.badge.POST { background: var(--m-post); }
.badge.PUT { background: var(--m-put); }
.badge.DELETE { background: var(--m-delete); }
.badge.PATCH { background: var(--m-patch); }
.badge.HEAD, .badge.OPTIONS, .badge.OTHER { background: var(--m-default); }

/* 右侧内容区 */
.content { flex: 1; overflow-y: auto; padding: 22px 26px; background: var(--panel); border-radius: 18px; }
.content .empty {
  display: grid; place-items: center; height: 100%; text-align: center; color: var(--text-dim);
}
.content .empty .big { font-size: 46px; margin-bottom: 10px; opacity: 0.7; }
.content .empty p { font-size: 14px; line-height: 1.7; }
.content .empty code { font-family: var(--mono); color: var(--c-cyan); }

.detail-body { padding: 4px 2px; }
.detail-title { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.detail-title .url { font-family: var(--mono); font-size: 13px; color: var(--text-dim); word-break: break-all; }

/* meta 条 */
.meta-chip {
  font-size: 12px; color: var(--text-dim);
  background: var(--inset-bg);
  border-radius: 999px;
  padding: 6px 11px;
}
.meta-chip b { color: var(--text); font-weight: 600; }

/* 选项卡（分段控件，靠背景块区分选中态） */
.tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  background: var(--inset-bg);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}
.tab-btn {
  font-family: var(--sans);
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); background: var(--panel); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-copy { margin-left: auto; background: var(--panel); }

/* 表格（去掉横线，用交替底色区分行） */
.kv-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; border-radius: 10px; overflow: hidden; }
.kv-table tr:nth-child(even) td { background: var(--band); }
.kv-table td { padding: 8px 12px; vertical-align: top; cursor: pointer; transition: background 0.15s ease; }
.kv-table tr td:hover { background: #dff4fe; }
.kv-table tr td.cell-copied { background: #eae9fc; color: #0f172a; }
.kv-table td.k { font-family: var(--mono); color: var(--c-teal); width: 210px; word-break: break-all; }
.kv-table td.v { font-family: var(--mono); color: var(--text); word-break: break-all; }
.kv-empty { color: var(--text-dim); font-size: 13px; padding: 4px 0; }

/* 代码块 */
.code {
  position: relative;
  background: var(--code-bg);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--code-text);
  overflow-x: auto;
  white-space: pre;
  max-height: 420px;
}
.code .tok-key { color: #7dd3fc; }
.code .tok-str { color: #86efac; }
.code .tok-num { color: #fcd34d; }
.code .tok-bool { color: #c4b5fd; }
.code .tok-null { color: #f9a8d4; }

/* 复制控件 */
.copy-zone { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.copy-btn {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  background: var(--inset-bg);
  border: none;
  padding: 6px 11px; border-radius: 8px; cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.copy-btn:hover { color: var(--text); background: var(--band); }
.copy-btn.copied { color: var(--ok); background: rgba(52, 211, 153, 0.16); }

/* 按钮 */
.btn {
  font-family: var(--sans);
  font-size: 13px; font-weight: 600;
  color: var(--text);
  background: rgba(148, 163, 184, 0.12);
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}
.btn:hover { background: rgba(148, 163, 184, 0.22); }
.btn.primary { background: var(--c-indigo); color: #fff; }
.btn.primary:hover { background: var(--c-cyan); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--band); }
.btn.small { padding: 7px 11px; font-size: 12px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #dff4fe; color: #0f172a;
  border-radius: 12px;
  padding: 12px 20px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all 0.3s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .ic { color: var(--ok); margin-right: 8px; }

/* 窄屏：上下堆叠 */
@media (max-width: 860px) {
  .app { flex-direction: column; height: auto; overflow: visible; }
  .splitter { display: none; }
  .sidebar { width: 100% !important; }
  .content { overflow-y: visible; padding: 18px; }
  body { background-attachment: scroll; }
}
