@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ========== VARIABLES ========== */
:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: #eff6ff;
  --success: #22c55e;
  --success-soft: #f0fdf4;
  --error: #ef4444;
  --error-soft: #fef2f2;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-soft: #1e3a5f;
  --success: #4ade80;
  --success-soft: #14532d;
  --error: #f87171;
  --error-soft: #7f1d1d;
  --code-bg: #0f172a;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

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

svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ========== LAYOUT ========== */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ========== HEADER ========== */
.header {
  text-align: center;
  padding: 20px 0;
}

.logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: var(--primary-soft);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo svg {
  width: 32px;
  height: 32px;
  stroke: var(--primary);
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
}

/* ========== SESSION BAR ========== */
.session-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--success-soft);
  border: 1px solid var(--success);
  border-radius: var(--radius);
}

.session-bar.active { display: flex; }

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

.session-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

/* ========== CARD ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ========== TABS ========== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}


.tab:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ========== FORM ========== */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  position: relative;
}

.input-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper svg {
  position: absolute;
  left: 12px;
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary);
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  padding: 12px 12px 12px 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input-wrapper input::placeholder {
  color: var(--text-secondary);
}

/* ========== DROPDOWN ========== */
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}

.dropdown.hidden { display: none; }

.dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--primary-soft); }

.dropdown-item .badge {
  font-size: 12px;
  padding: 2px 8px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: 999px;
}

/* ========== BUTTONS ========== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary svg {
  width: 20px;
  height: 20px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

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

/* ========== STATUS ========== */
.status {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  min-height: 20px;
}

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

/* ========== MODE SELECTOR ========== */
.mode-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.mode-label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.mode-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mode-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ========== STEPS ========== */
.steps-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
}

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

.step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.step-info {
  display: flex;
  flex-direction: column;
}

.step-title {
  font-weight: 500;
  font-size: 14px;
}

.step-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.step-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}

.step-badge.idle { background: var(--border); color: var(--text-secondary); }
.step-badge.running { background: #fef3c7; color: #b45309; }
.step-badge.ok { background: var(--success-soft); color: var(--success); }
.step-badge.fail { background: var(--error-soft); color: var(--error); }

/* ========== TECH CARD ========== */
.tech-card {
  padding: 0;
}

.tech-card summary {
  padding: 16px 24px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

.tech-card summary:hover {
  color: var(--text);
}

.tech-grid {
  display: grid;
  gap: 16px;
  padding: 0 24px 24px;
}

.tech-block h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 16px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  overflow-x: auto;
  max-height: 300px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* JSON highlighting */
.json-key { color: #7dd3fc; }
.json-string { color: #86efac; }
.json-number { color: #fcd34d; }
.json-boolean { color: #f472b6; }
.json-null { color: #94a3b8; }

/* ========== FOOTER ========== */
.footer {
  text-align: center;
  padding: 20px 0;
}

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

/* ========== THEME TOGGLE ========== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 100;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* ========== OVERLAY ========== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.overlay.active { display: flex; }

.overlay-card {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 48px;
  text-align: center;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}

.pulse-ring {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--primary-soft);
  animation: ring-pulse 1.5s ease-out infinite;
}

@keyframes ring-pulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.pulse-ring svg {
  width: 40px;
  height: 40px;
  stroke: var(--primary);
  z-index: 1;
  animation: icon-pulse 1.5s ease-in-out infinite;
}

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

.overlay-card h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.overlay-card p {
  color: var(--text-secondary);
}

/* ========== UTILITIES ========== */
.hidden { display: none !important; }

/* ========== RESPONSIVE ========== */
@media (max-width: 520px) {
  .container { padding: 24px 16px; }
  .header h1 { font-size: 24px; }
  .card { padding: 20px; }
  .tabs { flex-direction: column; }
  .mode-section { flex-direction: column; align-items: flex-start; }
}
