/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-surface: #1a1d27;
  --bg-hover: #22263a;
  --bg-active: #2a2f47;
  --border: #2e3347;
  --text: #e2e8f0;
  --text-muted: #7c8ba1;
  --text-dim: #4a5568;
  --accent: #4f46e5;
  --accent-hover: #6056f5;
  --accent-light: #312e81;
  --success: #10b981;
  --danger: #ef4444;
  --danger-light: #3f1a1a;
  --warning: #f59e0b;
  --method-get: #10b981;
  --method-post: #3b82f6;
  --method-put: #f59e0b;
  --method-patch: #8b5cf6;
  --method-delete: #ef4444;
  --method-head: #6366f1;
  --method-options: #ec4899;
  --method-default: #6b7280;
  --radius: 6px;
  --radius-lg: 10px;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --sidebar-width: 280px;
  --header-height: 56px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== HEADER ===== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.header-url-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  min-width: 0;
}

.url-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.webhook-url {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-hover);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
  font-family: var(--font-sans);
}

.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}

.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; }

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger-ghost:hover { background: var(--danger-light); }

.btn-sm { padding: 4px 8px; font-size: 12px; }

/* ===== LAYOUT ===== */
.layout {
  display: flex;
  height: 100vh;
  padding-top: var(--header-height);
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
}

.sidebar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.request-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.request-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.request-list::-webkit-scrollbar { width: 4px; }
.request-list::-webkit-scrollbar-track { background: transparent; }
.request-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== REQUEST ITEM ===== */
.request-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.request-item:hover { background: var(--bg-hover); }
.request-item.active { background: var(--bg-active); }
.request-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.request-item-left { flex: 1; min-width: 0; }

.request-method {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.method-GET    { color: var(--method-get);     background: rgba(16,185,129,0.12); }
.method-POST   { color: var(--method-post);    background: rgba(59,130,246,0.12); }
.method-PUT    { color: var(--method-put);     background: rgba(245,158,11,0.12); }
.method-PATCH  { color: var(--method-patch);   background: rgba(139,92,246,0.12); }
.method-DELETE { color: var(--method-delete);  background: rgba(239,68,68,0.12);  }
.method-HEAD   { color: var(--method-head);    background: rgba(99,102,241,0.12); }
.method-OPTIONS{ color: var(--method-options); background: rgba(236,72,153,0.12); }
.method-OTHER  { color: var(--method-default); background: rgba(107,114,128,0.12); }

.request-path {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.request-time {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.request-delete-btn {
  opacity: 0;
  transition: opacity 0.1s;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
}
.request-delete-btn:hover { color: var(--danger); background: var(--danger-light); }
.request-delete-btn svg { width: 12px; height: 12px; }
.request-item:hover .request-delete-btn { opacity: 1; }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px 20px;
  text-align: center;
  color: var(--text-dim);
  gap: 8px;
}

.empty-icon svg { width: 48px; height: 48px; }

.empty-state p { font-size: 13px; }

.empty-hint {
  color: var(--text-dim);
  font-size: 12px !important;
  margin-top: 4px;
  line-height: 1.6;
}

/* ===== DETAIL PANEL ===== */
.detail-panel {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-dim);
}

.detail-placeholder svg { opacity: 0.3; }
.detail-placeholder p { font-size: 14px; }

/* ===== DETAIL CONTENT ===== */
.detail-content { padding: 20px; }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-header-left { min-width: 0; flex: 1; }

.detail-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-self: flex-start;
}

.detail-method-url {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-method {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.detail-url {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.detail-meta {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.detail-meta span { display: flex; align-items: center; gap: 4px; }

.section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kv-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 12px;
}

.kv-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.kv-table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

.kv-table td {
  padding: 6px 10px;
  vertical-align: top;
}

.kv-key {
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  width: 35%;
  font-weight: 500;
}

.kv-value {
  font-family: var(--font-mono);
  color: var(--text);
  word-break: break-all;
}

.code-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.6;
}

.code-block.json { color: #a5d6ff; }
.code-block.xml  { color: #c8e6c9; }

.no-data {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  padding: 4px 0;
}

/* ===== LOADING ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  z-index: 999;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.form-group { display: flex; flex-direction: column; gap: 4px; }

.form-group-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color 0.15s;
  width: 100%;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-dim);
}

input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  z-index: 999;
  transition: transform 0.25s ease;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== NEW REQUEST PULSE ===== */
@keyframes pulse {
  0% { background: var(--accent-light); }
  100% { background: transparent; }
}

.request-item.new-request { animation: pulse 1.2s ease-out; }

/* ===== SCROLLBARS ===== */
.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-track { background: transparent; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  :root { --sidebar-width: 100%; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; height: 240px; border-right: none; border-bottom: 1px solid var(--border); }
  .header-url-wrapper { display: none !important; }
}

/* ===== AUTH SCREEN ===== */
.auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.auth-brand .brand-icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.auth-brand .brand-name {
  font-size: 17px;
  font-weight: 600;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-google:hover { background: #f1f3f4; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-dim);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-submit { width: 100%; margin-top: 2px; }

.auth-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
}

.auth-hint {
  margin-top: 20px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}

/* ===== HEADER USER ===== */
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.user-email {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
