/* ============================================
   ОСНОВНЫЕ СТИЛИ — ТЁМНАЯ ТЕМА (Chrome DevTools)
   ============================================ */

:root {
  --bg-primary: #1e1e1e;
  --bg-secondary: #252526;
  --bg-tertiary: #2d2d2d;
  --bg-hover: #2a2d2e;
  --bg-selected: #094771;
  --bg-header: #333333;
  --bg-stripe: #222223;
  --border: #3c3c3c;
  --border-light: #4a4a4a;
  --text-primary: #d4d4d4;
  --text-secondary: #999999;
  --text-muted: #666666;
  --accent-blue: #569cd6;
  --accent-green: #4ec9b0;
  --accent-yellow: #dcdcaa;
  --accent-orange: #ce9178;
  --accent-red: #f44747;
  --accent-purple: #c586c0;
  --accent-cyan: #9cdcfe;
  --status-green: #73c991;
  --status-yellow: #cca700;
  --status-red: #f14c4c;
  --font-mono: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
}

/* ============================================
   ВЕРХНЯЯ ПАНЕЛЬ
   ============================================ */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 40px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.target-badge {
  background: rgba(78, 201, 176, 0.15);
  color: var(--accent-green);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-text {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
}

.btn-icon {
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon.active {
  color: var(--accent-red);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 8px;
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-box:focus-within {
  border-color: var(--accent-blue);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 12px;
  padding: 5px 0;
  width: 100%;
  outline: none;
  font-family: var(--font-sans);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-shortcut {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Фильтры по типу */
.filter-buttons {
  display: flex;
  gap: 2px;
}

.filter-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-sans);
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.filter-btn.active {
  color: var(--accent-blue);
  background: rgba(86, 156, 214, 0.15);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent-blue);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

.stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.stats-divider {
  color: var(--border-light);
}

.conn-status {
  font-size: 10px;
  transition: color 0.3s;
}

.conn-status.connected {
  color: var(--status-green);
}

.conn-status.disconnected {
  color: var(--status-red);
}

/* ============================================
   ОСНОВНАЯ ОБЛАСТЬ
   ============================================ */

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.requests-panel {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
}

/* ============================================
   ТАБЛИЦА ЗАПРОСОВ
   ============================================ */

.requests-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.requests-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.requests-table th {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 5px 10px;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.requests-table th:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sort-arrow {
  font-size: 9px;
  margin-left: 2px;
}

.col-status { width: 60px; }
.col-method { width: 65px; }
.col-protocol { width: 55px; }
.col-host { width: 170px; }
.col-path { width: auto; }
.col-type { width: 65px; }
.col-size { width: 75px; }
.col-time { width: 75px; }

.requests-table td {
  padding: 3px 10px;
  border-bottom: 1px solid rgba(60, 60, 60, 0.4);
  border-right: 1px solid rgba(60, 60, 60, 0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  cursor: pointer;
}

.requests-table tbody tr {
  transition: background 0.08s;
}

.requests-table tbody tr:nth-child(even) {
  background: var(--bg-stripe);
}

.requests-table tbody tr:hover {
  background: var(--bg-hover) !important;
}

.requests-table tbody tr.selected {
  background: var(--bg-selected) !important;
}

.requests-table tbody tr.pending {
  opacity: 0.5;
}

.requests-table tbody tr.error td {
  color: var(--accent-red);
}

.requests-table tbody tr.api-highlight td:first-child {
  border-left: 2px solid var(--accent-green);
}

/* Статус коды */
.status-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  min-width: 32px;
  text-align: center;
}

.status-badge.s2xx { background: rgba(115, 201, 145, 0.15); color: var(--status-green); }
.status-badge.s3xx { background: rgba(204, 167, 0, 0.15); color: var(--status-yellow); }
.status-badge.s4xx { background: rgba(241, 76, 76, 0.15); color: var(--status-red); }
.status-badge.s5xx { background: rgba(241, 76, 76, 0.25); color: var(--status-red); }
.status-badge.pending { background: rgba(150, 150, 150, 0.15); color: var(--text-muted); }

.method-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.method-badge.get { color: var(--accent-green); }
.method-badge.post { color: var(--accent-yellow); }
.method-badge.put { color: var(--accent-orange); }
.method-badge.delete { color: var(--accent-red); }
.method-badge.patch { color: var(--accent-purple); }
.method-badge.connect { color: var(--text-muted); }
.method-badge.options { color: var(--accent-cyan); }
.method-badge.head { color: var(--text-secondary); }

.cell-protocol {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.cell-path {
  color: var(--text-primary);
}

.cell-host {
  color: var(--text-secondary);
}

.cell-host.is-api {
  color: var(--accent-green);
  font-weight: 500;
}

.cell-type {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 500;
}

.cell-size,
.cell-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

/* Пустое состояние */
.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
  max-width: 480px;
}

.empty-state h3 {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: 14px;
  font-weight: 500;
}

.empty-state p {
  margin-top: 8px;
}

.empty-state .sub {
  font-size: 12px;
  margin-top: 6px;
}

.empty-state code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-blue);
}

.empty-state.hidden {
  display: none;
}

.setup-steps {
  margin-top: 24px;
  text-align: left;
}

.setup-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(60, 60, 60, 0.3);
  font-size: 12px;
  color: var(--text-secondary);
}

.setup-step:last-child {
  border-bottom: none;
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(86, 156, 214, 0.2);
  color: var(--accent-blue);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ============================================
   ПАНЕЛЬ ДЕТАЛЕЙ
   ============================================ */

.details-panel {
  width: 520px;
  min-width: 350px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow: hidden;
  position: relative;
}

.details-panel.hidden {
  display: none;
}

.details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.details-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 4px;
}

.details-tabs {
  display: flex;
}

.detail-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: var(--font-sans);
  transition: all 0.15s;
  white-space: nowrap;
}

.detail-tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.detail-tab.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

.details-url-bar {
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: all;
  flex-shrink: 0;
}

.details-url-bar:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.details-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Секции деталей */
.detail-section {
  border-bottom: 1px solid var(--border);
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  cursor: pointer;
  user-select: none;
}

.detail-section-header:hover {
  background: var(--bg-hover);
}

.section-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.detail-section-body {
  padding: 4px 12px;
}

.detail-section:not(.open) .detail-section-body,
.detail-section:not(.open) .code-block {
  display: none;
}

.btn-copy {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 3px;
  opacity: 0.5;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  color: var(--text-secondary);
}

.btn-copy:hover {
  opacity: 1;
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-format {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.6;
}

.btn-format:hover {
  opacity: 1;
}

/* Заголовки (ключ-значение) */
.header-row {
  display: flex;
  padding: 3px 0;
  font-size: 12px;
  line-height: 1.5;
  border-bottom: 1px solid rgba(60, 60, 60, 0.3);
}

.header-row:last-child {
  border-bottom: none;
}

.header-row:hover {
  background: rgba(86, 156, 214, 0.05);
}

.header-key {
  color: var(--accent-purple);
  font-family: var(--font-mono);
  font-size: 11px;
  min-width: 180px;
  max-width: 180px;
  flex-shrink: 0;
  word-break: break-all;
  padding-right: 8px;
  cursor: pointer;
}

.header-key:hover {
  text-decoration: underline;
}

.header-value {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  word-break: break-all;
  flex: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 2px;
  transition: background 0.1s;
}

.header-value:hover {
  background: rgba(86, 156, 214, 0.1);
}

/* Общая информация */
.general-row {
  display: flex;
  padding: 3px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(60, 60, 60, 0.3);
}

.general-row:last-child {
  border-bottom: none;
}

.general-key {
  color: var(--text-secondary);
  min-width: 160px;
  font-weight: 500;
}

.general-value {
  color: var(--text-primary);
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: 11px;
  user-select: all;
}

.general-value.status-ok { color: var(--status-green); }
.general-value.status-warn { color: var(--status-yellow); }
.general-value.status-err { color: var(--status-red); }

/* Блок кода */
.code-block {
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-primary);
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  background: var(--bg-primary);
  cursor: text;
  user-select: text;
}

.code-block.empty {
  color: var(--text-muted);
  font-style: italic;
}

.curl-block {
  color: var(--accent-green);
}

/* Превью */
.preview-content {
  padding: 12px;
  overflow: auto;
  max-height: calc(100vh - 200px);
}

.preview-content .json-view {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.json-key { color: var(--accent-purple); }
.json-string { color: var(--accent-orange); }
.json-number { color: var(--accent-green); }
.json-boolean { color: var(--accent-blue); }
.json-null { color: var(--text-muted); }

/* Тайминг */
.timing-content {
  padding: 16px;
}

.timing-bar-container {
  margin-bottom: 16px;
}

.timing-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.timing-bar {
  height: 20px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  overflow: hidden;
  position: relative;
}

.timing-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  padding-left: 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: white;
  font-weight: 600;
}

.timing-total {
  margin-top: 12px;
  padding: 10px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  text-align: center;
}

/* ============================================
   RESIZE BAR
   ============================================ */

.resize-bar {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background 0.15s;
  z-index: 100;
}

.resize-bar:hover,
.resize-bar.active {
  background: var(--accent-blue);
}

/* ============================================
   CONTEXT MENU
   ============================================ */

.context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 200px;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.context-menu.hidden {
  display: none;
}

.context-menu-item {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}

.context-menu-item:hover {
  background: var(--accent-blue);
  color: white;
}

.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============================================
   TOAST УВЕДОМЛЕНИЯ
   ============================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent-blue);
  color: white;
  padding: 8px 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 3000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   СКРОЛЛБАРЫ (СТИЛИЗАЦИЯ)
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   АНИМАЦИИ
   ============================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-1px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.requests-table tbody tr {
  animation: fadeIn 0.15s ease;
}

.pending .status-badge {
  animation: pulse 1.5s infinite;
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */

@media (max-width: 1200px) {
  .details-panel {
    width: 400px;
    min-width: 300px;
  }
}

@media (max-width: 900px) {
  .filter-buttons {
    display: none;
  }
  .stats {
    display: none;
  }
  .checkbox-label {
    display: none;
  }
}
