/* ============================================
   inspectproxy — Developer Tool Aesthetic
   ============================================ */

:root {
  /* Dark terminal-inspired palette */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-card: #1c2128;

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;

  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-glow: rgba(88, 166, 255, 0.15);

  --success: #3fb950;
  --warning: #d29922;
  --error: #f85149;

  --border: #30363d;
  --border-light: #21262d;

  /* Recording red */
  --recording: #f85149;
  --recording-glow: rgba(248, 81, 73, 0.3);
}

* {
  box-sizing: border-box;
}

/* Dark scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) var(--bg-primary);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

*::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

*::-webkit-scrollbar-corner {
  background: var(--bg-primary);
}

body {
  font-family: 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  font-size: 14px;
  line-height: 1.6;
}

button, input, select, textarea {
  font-family: inherit;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   Landing Page
   ============================================ */

#landing-page {
  min-height: 100vh;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(88, 166, 255, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(248, 81, 73, 0.05), transparent);
  padding: 40px 20px;
  overflow-y: auto;
}

.landing-container {
  max-width: 800px;
  margin: 0 auto;
}

/* Hero Section */
.hero {
  text-align: center;
  margin-bottom: 48px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
  font-size: 18px;
  font-weight: 600;
}

.logo-icon {
  color: var(--accent);
  font-size: 20px;
}

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

.hero h1 {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 20px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.hero h1 .highlight {
  color: var(--accent);
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
  font-weight: 400;
}

/* Main Form Card */
.landing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 64px;
}

#create-form {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.input-group {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-prefix {
  color: var(--text-muted);
  margin-right: 8px;
  font-weight: 500;
}

#create-form input {
  flex: 1;
  padding: 14px 0;
  background: transparent;
  border: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
}

#create-form input::placeholder {
  color: var(--text-muted);
}

#create-form button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--recording);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  white-space: nowrap;
}

#create-form button:hover {
  background: #ff6b6b;
  box-shadow: 0 0 20px var(--recording-glow);
}

#create-form button:active {
  transform: scale(0.98);
}

.btn-icon {
  font-size: 10px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#example-apis {
  text-align: center;
}

.example-label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 12px;
}

#api-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.api-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.api-chip:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
  color: var(--accent);
}

.api-chip-icon {
  font-size: 12px;
}

/* Features Section */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 64px;
}

.feature {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.feature-icon {
  font-size: 24px;
  color: var(--accent);
  margin-bottom: 16px;
}

.feature h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.feature p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* How it works */
.how-it-works {
  margin-bottom: 64px;
}

.how-it-works h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  margin: 0 0 32px;
}

.steps {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  flex: 1;
  max-width: 220px;
}

.step-number {
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: var(--bg-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.step-content h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.step-content p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.step-arrow {
  color: var(--text-muted);
  font-size: 20px;
  padding-top: 16px;
}

/* Trust signals */
.trust-signals {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 64px;
  flex-wrap: wrap;
}

.trust-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.trust-icon {
  font-size: 14px;
}

/* Footer */
.landing-footer {
  text-align: center;
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.landing-footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}

.landing-footer a:hover {
  color: var(--accent);
}

/* ============================================
   App Header
   ============================================ */

#header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  gap: 24px;
}

#header h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex-shrink: 0;
}

#header h1 a {
  color: var(--text-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#header h1 a:hover {
  color: var(--accent);
}

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

#session-info {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
  justify-content: space-between;
}

.session-urls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  min-width: 0;
}

.url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.url-label {
  color: var(--text-muted);
  width: 48px;
  flex-shrink: 0;
  text-align: right;
}

.url-value {
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-value a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.url-value a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

#copy-proxy-url {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
  color: var(--text-secondary);
  font-family: inherit;
  transition: all 0.2s;
  flex-shrink: 0;
}

#copy-proxy-url:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--accent);
}

.session-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-header {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-header:hover {
  background: var(--bg-primary);
  border-color: var(--accent);
}

.btn-header-danger {
  color: var(--error);
  border-color: transparent;
  background: rgba(248, 81, 73, 0.1);
}

.btn-header-danger:hover {
  background: rgba(248, 81, 73, 0.2);
  border-color: var(--error);
}

/* ============================================
   Main App Layout
   ============================================ */

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: var(--bg-primary);
}

#traffic-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#resizer {
  width: 4px;
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.2s;
}

#resizer:hover,
#resizer.dragging {
  background: var(--accent);
}

#table-container {
  flex: 1;
  overflow-y: auto;
}

/* ============================================
   Traffic Table
   ============================================ */

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

thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

th,
td {
  padding: 8px 12px;
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
}

th:last-child,
td:last-child {
  border-right: none;
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.col-size { text-align: right; }
.col-time { text-align: right; }

/* HTTP Method Colors */
.method-get { color: #58a6ff; font-weight: 600; }
.method-post { color: #3fb950; font-weight: 600; }
.method-put { color: #d29922; font-weight: 600; }
.method-delete { color: #f85149; font-weight: 600; }
.method-patch { color: #a371f7; font-weight: 600; }
.method-head { color: #db61a2; font-weight: 600; }
.method-options { color: #79c0ff; font-weight: 600; }

tr.selected {
  background-color: var(--bg-tertiary);
}

tr:hover:not(.selected) {
  background-color: var(--bg-secondary);
}

#traffic-body tr {
  cursor: pointer;
}

#traffic-body tr:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

#traffic-body tr:focus:not(:focus-visible) {
  outline: none;
}

.status-pending { color: var(--text-muted); font-style: italic; }
.status-error { color: var(--error); }
.status-ok { color: var(--success); }

/* ============================================
   Details Pane
   ============================================ */

#details-pane {
  width: 400px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
}

.tabs-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: flex;
}

.tab {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-weight: 500;
  transition: color 0.2s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

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

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

.tab:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tab:focus:not(:focus-visible) {
  outline: none;
}

.tab-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

.content-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  flex-shrink: 0;
}

#request-query-params {
  flex-shrink: 0;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

#request-query-params:empty {
  display: none;
}

#request-body-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.toggle-group {
  display: flex;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.toggle-btn {
  padding: 4px 10px;
  font-size: 11px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: inherit;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.copy-btn {
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: inherit;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

pre {
  margin: 0;
  font-family: inherit;
  font-size: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  flex: 1;
  overflow: auto;
  color: var(--text-primary);
}

pre.raw-mode {
  font-size: 11px;
}

pre code.hljs {
  display: block;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  background: transparent;
  padding: 0;
  overflow: visible;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Header List (for headers display) */
.header-list {
  font-size: 12px;
}

.header-list summary {
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  outline: none;
  list-style: none;
  color: var(--text-primary);
}

.header-list summary::-webkit-details-marker {
  display: inline-block;
  margin-right: 8px;
}

.header-list summary:hover {
  background: var(--bg-secondary);
}

.header-list details[open] summary .count {
  display: none;
}

.header-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 16px 0;
}

.header-table td,
.header-table th {
  padding: 4px 12px;
  font-size: 11px;
  border-bottom: none;
  vertical-align: top;
  white-space: normal;
  overflow: visible;
}

.header-table .header-name {
  width: 140px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  padding-right: 16px;
}

.header-table .header-value {
  color: var(--text-primary);
  word-break: break-all;
}

.no-headers {
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 12px;
}

#empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Traffic table empty state */
#traffic-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  text-align: center;
  color: var(--text-muted);
}

#traffic-empty-state .empty-icon {
  font-size: 32px;
  color: var(--accent);
  margin-bottom: 16px;
  animation: pulse-slow 2s ease-in-out infinite;
}

@keyframes pulse-slow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

#traffic-empty-state .empty-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

#traffic-empty-state .empty-hint {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 300px;
}

#share-request {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  border-left: 1px solid var(--border);
  color: var(--text-secondary);
}

#share-request:hover {
  background: var(--bg-secondary);
}

/* ============================================
   Dialogs
   ============================================ */

dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 420px;
  background: var(--bg-card);
  color: var(--text-primary);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.dialog-content {
  padding: 24px;
}

.dialog-content h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.dialog-content p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.dialog-content ul {
  margin: 0 0 24px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.dialog-content li {
  margin-bottom: 6px;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-secondary {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

.btn-danger {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: var(--error);
  color: white;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: #ff6b6b;
}

.btn-primary {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

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

/* ============================================
   Image Preview
   ============================================ */

.image-preview {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  background: repeating-conic-gradient(var(--bg-tertiary) 0% 25%, var(--bg-primary) 0% 50%) 50% / 20px 20px;
  border-radius: 8px;
  min-height: 100px;
  overflow: auto;
}

.image-preview img {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .hero h1 {
    font-size: 28px;
  }

  .features {
    grid-template-columns: 1fr;
  }

  .steps {
    flex-direction: column;
    align-items: center;
  }

  .step {
    max-width: 100%;
  }

  .step-arrow {
    transform: rotate(90deg);
    padding: 0;
  }

  #create-form {
    flex-direction: column;
  }

  .trust-signals {
    flex-direction: column;
    gap: 16px;
    align-items: center;
  }
}
