/**
 * API Tester - 科技感未来主题样式
 * @author huazm
 */

/* ==================== CSS 变量和主题 ==================== */
:root {
  /* 默认主题: 深蓝科技 */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-hover: #374151;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-primary: #3b82f6;
  --accent-secondary: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.5);

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #06b6d4;

  --border-color: #374151;
  --border-glow: rgba(59, 130, 246, 0.3);

  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-glow: 0 0 20px var(--accent-glow);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 主题: 紫色星云 */
[data-theme="nebula"] {
  --bg-primary: #0f0a1a;
  --bg-secondary: #1a1028;
  --bg-tertiary: #2d1f4a;
  --accent-primary: #a855f7;
  --accent-secondary: #c084fc;
  --accent-glow: rgba(168, 85, 247, 0.5);
  --border-glow: rgba(168, 85, 247, 0.3);
}

/* 主题: 翠绿矩阵 */
[data-theme="matrix"] {
  --bg-primary: #0a0f0a;
  --bg-secondary: #0f1a0f;
  --bg-tertiary: #1a2f1a;
  --accent-primary: #22c55e;
  --accent-secondary: #4ade80;
  --accent-glow: rgba(34, 197, 94, 0.5);
  --border-glow: rgba(34, 197, 94, 0.3);
}

/* 主题: 赛博橙 */
[data-theme="cyber"] {
  --bg-primary: #0f0a05;
  --bg-secondary: #1a1008;
  --bg-tertiary: #2f1f0a;
  --accent-primary: #f97316;
  --accent-secondary: #fb923c;
  --accent-glow: rgba(249, 115, 22, 0.5);
  --border-glow: rgba(249, 115, 22, 0.3);
}

/* 主题: 冰霜白 */
[data-theme="frost"] {
  --bg-primary: #f0f4f8;
  --bg-secondary: #e2e8f0;
  --bg-tertiary: #cbd5e1;
  --bg-hover: #94a3b8;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #0ea5e9;
  --accent-secondary: #38bdf8;
  --border-color: #94a3b8;
}

/* ==================== 基础样式 ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==================== 粒子背景 ==================== */
#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ==================== 应用容器 ==================== */
.app-container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== 头部导航 ==================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, transparent 100%);
  border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
  font-size: 24px;
  animation: pulse 2s infinite;
}

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

.logo-text {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-secondary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--accent-primary);
  color: white;
  border-radius: 10px;
  font-weight: 600;
}

.header-nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

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

.nav-btn.active {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.theme-btn,
.voice-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}

.theme-btn:hover,
.voice-btn:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
  transform: scale(1.1);
}

.voice-btn.recording {
  animation: recording 1s infinite;
  border-color: var(--error);
}

@keyframes recording {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

/* ==================== 主内容区 ==================== */
.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 24px;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 1200px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

/* ==================== 面板通用样式 ==================== */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel.hidden {
  display: none;
}

/* ==================== URL 栏 ==================== */
.url-bar {
  display: flex;
  gap: 12px;
  padding: 20px;
  background: linear-gradient(
    135deg,
    var(--bg-tertiary) 0%,
    var(--bg-secondary) 100%
  );
  border-bottom: 1px solid var(--border-color);
}

.method-select {
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  min-width: 100px;
  transition: var(--transition);
}

.method-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.url-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.url-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.url-input::placeholder {
  color: var(--text-muted);
}

/* ==================== 发送按钮 ==================== */
.send-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-secondary)
  );
  border: none;
  color: white;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.send-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: 0.5s;
}

.send-btn:hover::before {
  left: 100%;
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px var(--accent-glow);
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.send-btn.loading .btn-text {
  opacity: 0;
}

.send-btn.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ==================== 标签页 ==================== */
.request-tabs,
.response-tabs {
  display: flex;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

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

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

/* ==================== 内容区 ==================== */
.request-content,
.response-content {
  padding: 20px;
  min-height: 200px;
}

.tab-content {
  display: none;
}

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

/* ==================== Key-Value 编辑器 ==================== */
.kv-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.kv-key,
.kv-value {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.kv-key:focus,
.kv-value:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.kv-remove {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}

.kv-remove:hover {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

.add-row-btn {
  margin-top: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.add-row-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ==================== Header 预设 ==================== */
.header-presets-container {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.preset-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.preset-group:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.preset-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  min-width: 90px;
}

.preset-btn {
  padding: 5px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.preset-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.preset-btn.auth-preset {
  border-color: var(--warning);
  color: var(--warning);
}

.preset-btn.auth-preset:hover {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}

/* ==================== Body 编辑器 ==================== */
.body-type-selector {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.body-type-selector label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}

.body-type-selector input[type="radio"] {
  accent-color: var(--accent-primary);
}

.body-editor-container {
  position: relative;
}

.body-editor {
  width: 100%;
  min-height: 200px;
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  border-radius: var(--radius-md);
  resize: vertical;
  transition: var(--transition);
}

.body-editor:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.format-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

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

/* ==================== Auth 配置 ==================== */
.auth-type-selector {
  margin-bottom: 16px;
}

.auth-type-selector select {
  padding: 10px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  min-width: 200px;
}

.auth-config {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-input-group label {
  color: var(--text-secondary);
  font-size: 12px;
}

.auth-input-group input {
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* ==================== 响应面板 ==================== */
.response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.response-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-code {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}

.status-code.success {
  color: var(--success);
}
.status-code.redirect {
  color: var(--warning);
}
.status-code.error {
  color: var(--error);
}

.status-text {
  color: var(--text-secondary);
  font-size: 14px;
}

.response-meta {
  display: flex;
  gap: 20px;
}

.meta-item {
  font-size: 13px;
  color: var(--text-secondary);
}

.meta-label {
  color: var(--text-muted);
}

.response-body,
.response-headers-view {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
}

/* ==================== 历史记录面板 ==================== */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

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

.panel-actions {
  display: flex;
  gap: 12px;
}

.search-input {
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  border-radius: var(--radius-sm);
  width: 200px;
}

.clear-btn {
  padding: 8px 16px;
  background: var(--error);
  border: none;
  color: white;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.clear-btn:hover {
  opacity: 0.8;
}

.history-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 500px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--accent-primary);
}

.history-method {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  min-width: 60px;
  text-align: center;
}

.history-method.get {
  background: #10b98120;
  color: var(--success);
}
.history-method.post {
  background: #3b82f620;
  color: var(--accent-primary);
}
.history-method.put {
  background: #f59e0b20;
  color: var(--warning);
}
.history-method.delete {
  background: #ef444420;
  color: var(--error);
}
.history-method.patch {
  background: #a855f720;
  color: #a855f7;
}

.history-url {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  font-size: 12px;
  color: var(--text-muted);
}

.history-status {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* ==================== 滚动条样式 ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}
