/* HookDash — Developer-focused dark theme */

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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --green: #238636;
  --blue: #1f6feb;
  --orange: #d29922;
  --red: #da3633;
  --gray: #8b949e;
  --radius: 6px;
  --mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', Consolas, monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
#app {
  max-width: 1400px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.logo span {
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: #2ea043;
  border-color: #2ea043;
}

.btn-accent {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn-accent:hover {
  background: #388bfd;
  border-color: #388bfd;
}

.btn-sm {
  padding: 3px 10px;
  font-size: 12px;
}

/* Main layout */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left panel */
.panel-left {
  width: 40%;
  min-width: 320px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Right panel */
.panel-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Endpoint URL bar */
.endpoint-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.endpoint-url {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

.copy-btn {
  flex-shrink: 0;
  position: relative;
}

.copy-feedback {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.copy-feedback.show {
  opacity: 1;
}

/* Request list */
.request-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.request-list::-webkit-scrollbar {
  width: 6px;
}

.request-list::-webkit-scrollbar-track {
  background: transparent;
}

.request-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.request-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  animation: fadeSlideIn 0.25s ease-out;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.request-item:hover {
  background: var(--surface);
}

.request-item.selected {
  background: var(--surface);
  border-left: 2px solid var(--accent);
  padding-left: 14px;
}

.method-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  min-width: 56px;
  text-align: center;
}

.method-GET { background: var(--green); }
.method-POST { background: var(--blue); }
.method-PUT { background: var(--orange); }
.method-PATCH { background: var(--orange); }
.method-DELETE { background: var(--red); }
.method-HEAD, .method-OPTIONS, .method-OTHER { background: var(--gray); }

.request-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.request-content-type {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-info {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Detail panel */
.detail-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.detail-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.detail-content::-webkit-scrollbar {
  width: 6px;
}

.detail-content::-webkit-scrollbar-track {
  background: transparent;
}

.detail-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 20px;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Tab content */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Key-value table (headers, query params) */
.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.kv-table th {
  text-align: left;
  padding: 6px 12px 6px 0;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kv-table td {
  padding: 6px 12px 6px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.kv-table td:first-child {
  color: var(--accent);
  white-space: nowrap;
  width: 1%;
  padding-right: 24px;
}

/* Code block / JSON display */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* JSON syntax highlighting */
.json-key { color: #ff7b72; }
.json-string { color: #a5d6ff; }
.json-number { color: #79c0ff; }
.json-boolean { color: #ff7b72; }
.json-null { color: var(--text-muted); }

/* Analysis section */
.analysis-section {
  margin-top: 16px;
}

.analysis-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
}

.analysis-result h1,
.analysis-result h2,
.analysis-result h3 {
  color: var(--text);
  margin: 16px 0 8px;
  font-size: 14px;
}

.analysis-result h1:first-child,
.analysis-result h2:first-child,
.analysis-result h3:first-child {
  margin-top: 0;
}

.analysis-result strong {
  color: var(--text);
}

.analysis-result code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 3px;
}

.analysis-result pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.analysis-result pre code {
  background: none;
  padding: 0;
}

.analysis-result ul, .analysis-result ol {
  padding-left: 20px;
  margin: 4px 0;
}

.analysis-result li {
  margin: 2px 0;
}

.analysis-result p {
  margin: 6px 0;
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.3;
}

.empty-state h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.empty-state p {
  font-size: 14px;
  max-width: 360px;
  line-height: 1.6;
}

/* Welcome screen (no endpoint created) */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
  text-align: center;
  padding: 40px;
}

.welcome h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.welcome p {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 400px;
  line-height: 1.6;
}

.welcome-subtitle {
  font-size: 15px !important;
  max-width: 460px !important;
}

.btn-lg {
  padding: 10px 28px;
  font-size: 15px;
}

.welcome-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
  text-align: left;
  max-width: 380px;
  width: 100%;
}

.welcome-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.welcome-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.welcome-step-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

.welcome-step-text strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.welcome-step-text span {
  font-size: 12px;
  color: var(--text-muted);
}

.welcome-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.welcome-feature {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

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

/* SSE connection status indicator */
.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gray);
}

.status-dot.connected {
  background: var(--green);
}

.status-dot.disconnected {
  background: var(--red);
}

/* Request count badge */
.request-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* Meta row in detail */
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

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

.detail-meta-item span:first-child {
  color: var(--text-muted);
}

.detail-meta-item span:last-child {
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

/* Replay section */
.replay-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.replay-input {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.replay-input:focus {
  border-color: var(--accent);
}

.replay-textarea {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text);
  resize: vertical;
  min-height: 120px;
  max-height: 400px;
  outline: none;
  transition: border-color 0.15s;
  white-space: pre-wrap;
  word-break: break-word;
}

.replay-textarea:focus {
  border-color: var(--accent);
}

.replay-response {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.replay-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.replay-status-badge {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  color: #fff;
}

.replay-status-ok { background: var(--green); }
.replay-status-warn { background: var(--orange); }
.replay-status-error { background: var(--red); }

.replay-duration {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.replay-error {
  font-size: 13px;
  color: var(--red);
}

/* Notification section */
.notif-section {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.notif-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.notif-active {
  font-size: 11px;
  color: var(--green);
  font-weight: 500;
}

.notif-off {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.notif-body {
  display: flex;
  gap: 6px;
  align-items: center;
}

.notif-input {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.notif-input:focus {
  border-color: var(--accent);
}

.notif-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.notif-help {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* Response Config */
.resp-section {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.resp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  cursor: pointer;
}

.resp-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.resp-hint {
  font-size: 11px;
}

.resp-config-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resp-row {
  display: flex;
  gap: 8px;
}

.resp-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.resp-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.resp-input-sm {
  width: 80px;
  flex: none !important;
}

.resp-body-input {
  font-family: var(--mono);
  font-size: 12px;
  min-height: 48px;
  max-height: 100px;
  resize: vertical;
}

.resp-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* Auth Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-footer a {
  color: var(--accent);
  text-decoration: none;
}

.modal-footer a:hover {
  text-decoration: underline;
}

/* Form elements */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-error {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 10px;
  min-height: 18px;
}

.btn-block {
  display: block;
  width: 100%;
  padding: 10px;
  font-size: 14px;
}

/* Account menu */
.account-wrapper {
  position: relative;
}

.account-btn {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  display: none;
  z-index: 100;
}

.account-menu.show {
  display: block;
}

.account-menu-item {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}

.account-menu-item:hover {
  background: var(--surface-hover);
}

.account-menu-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.account-menu-item:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Settings page */
.settings-page {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 40px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
}

.settings-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.settings-section {
  margin-bottom: 28px;
}

.settings-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-help {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.settings-help code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
}

.settings-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.settings-label {
  color: var(--text-muted);
  min-width: 100px;
}

.settings-value {
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.key-create-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.new-key-display {
  background: var(--bg);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.new-key-label {
  font-size: 12px;
  color: var(--green);
  margin-bottom: 6px;
  font-weight: 500;
}

.new-key-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.new-key-value code {
  font-family: var(--mono);
  font-size: 12px;
  flex: 1;
  word-break: break-all;
  color: var(--text);
}

.endpoints-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.endpoint-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}

.endpoint-list-item:hover {
  border-color: var(--accent);
}

.endpoint-list-id {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
}

.endpoint-list-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  main {
    flex-direction: column;
  }

  .panel-left {
    width: 100%;
    min-width: 0;
    height: 45%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel-right {
    height: 55%;
  }

  header {
    padding: 10px 14px;
  }

  .endpoint-bar {
    padding: 10px 12px;
  }
}
