/* ═══════════════════════════════════════════════
   Kling Token Bot — Popup Styles
════════════════════════════════════════════════ */

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

:root {
  --bg: #0d1117;
  --card: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #3fb950;
  --warn: #d29922;
  --danger: #ff4d4d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  width: 360px;
  min-height: 480px;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Header ──────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #161b22 0%, #0d1117 100%);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.logo { width: 32px; height: 32px; border-radius: 8px; }
.app-title { font-size: 13px; font-weight: 700; color: var(--text); }
.app-sub { font-size: 10px; color: var(--accent); font-weight: 500; }

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  transition: background 0.3s;
}
.status-dot.idle    { background: var(--muted); }
.status-dot.active  { background: var(--accent); animation: blink 1.2s ease-in-out infinite; }
.status-dot.success { background: var(--success); }
.status-dot.error   { background: var(--danger); }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Banner ──────────────────────────────────── */
.capture-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(99,102,241,0.12);
  border-bottom: 1px solid rgba(99,102,241,0.25);
  font-size: 11px;
  color: var(--accent-hover);
}
.capture-banner.hidden { display: none; }
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1s ease-in-out infinite;
  flex-shrink: 0;
}

/* ── Tabs ────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab.active {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
  background: rgba(99,102,241,0.06);
}

/* ── Tab content ─────────────────────────────── */
.tab-content { display: none; padding: 12px 14px; }
.tab-content.active { display: block; }

/* ── Stat row ────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.stat-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.stat-box.good  { border-color: rgba(63,185,80,0.3); }
.stat-box.accent { border-color: rgba(99,102,241,0.3); }
.stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-box.good  .stat-val { color: var(--success); }
.stat-box.accent .stat-val { color: var(--accent-hover); }
.stat-lbl {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

/* ── Action row ──────────────────────────────── */
.action-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  align-items: center;
}

.btn-primary {
  flex: 1;
  padding: 7px 10px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  border: none;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.08s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  padding: 7px 10px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ── Result message ──────────────────────────── */
.result-msg {
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 11px;
  margin-bottom: 8px;
}
.result-msg.hidden { display: none; }
.result-msg.ok   { background: rgba(63,185,80,0.12); color: var(--success); border: 1px solid rgba(63,185,80,0.3); }
.result-msg.err  { background: rgba(255,77,77,0.1);  color: var(--danger);  border: 1px solid rgba(255,77,77,0.3); }
.result-msg.info { background: rgba(99,102,241,0.1); color: var(--accent-hover); border: 1px solid rgba(99,102,241,0.3); }

/* ── Token list ──────────────────────────────── */
.section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.token-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.token-list::-webkit-scrollbar { width: 3px; }
.token-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.token-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s;
}
.token-item:hover { border-color: var(--accent); }
.token-item.sent  { border-color: rgba(63,185,80,0.35); }
.token-item.expired { opacity: 0.45; }

.token-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.token-dot.active  { background: var(--success); }
.token-dot.expired { background: var(--danger); }
.token-dot.sent    { background: var(--accent); }

.token-info { flex: 1; min-width: 0; }
.token-email {
  font-size: 11px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.token-meta {
  font-size: 9px; color: var(--muted); margin-top: 1px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.token-exp.good { color: var(--success); }
.token-exp.warn { color: var(--warn); }
.token-exp.bad  { color: var(--danger); }
.token-sent-badge {
  font-size: 9px; color: var(--accent);
  background: rgba(99,102,241,0.15);
  padding: 1px 5px; border-radius: 4px;
}

.token-send-btn {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: all 0.15s;
}
.token-send-btn:hover { border-color: var(--accent); color: var(--accent-hover); }
.token-send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Empty state ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--muted);
}
.empty-icon { font-size: 28px; margin-bottom: 8px; }
.empty-title { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-sub { font-size: 11px; line-height: 1.5; }

/* ── Settings ────────────────────────────────── */
.settings-group { margin-bottom: 12px; }
.setting-label {
  font-size: 11px; font-weight: 600; color: var(--text); margin-bottom: 5px;
}
.setting-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
}
.setting-input:focus { outline: none; border-color: var(--accent); }
.setting-hint { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ── Toggle ──────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
}
.toggle-row input { display: none; }
.toggle-track {
  position: relative; width: 36px; height: 20px;
  background: var(--border); border-radius: 20px;
  transition: background 0.2s; flex-shrink: 0;
}
.toggle-thumb {
  position: absolute; width: 14px; height: 14px;
  background: white; border-radius: 50%;
  top: 3px; left: 3px; transition: transform 0.2s;
}
.toggle-row input:checked + .toggle-track { background: var(--accent); }
.toggle-row input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-text { font-size: 11px; color: var(--muted); }

/* ── Guide ───────────────────────────────────── */
.guide-step {
  display: flex; gap: 10px; margin-bottom: 12px; align-items: flex-start;
}
.guide-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(99,102,241,0.2); border: 1px solid rgba(99,102,241,0.4);
  color: var(--accent-hover); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.guide-title { font-size: 11px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.guide-desc  { font-size: 10px; color: var(--muted); line-height: 1.5; }
.guide-desc code {
  background: var(--card); border: 1px solid var(--border);
  padding: 1px 4px; border-radius: 3px; font-size: 10px; color: var(--accent-hover);
}

.guide-tip {
  background: rgba(210,153,34,0.1);
  border: 1px solid rgba(210,153,34,0.3);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 10px;
  color: #d29922;
  line-height: 1.5;
  margin-top: 4px;
}

/* ── Bot Tab Premium Styling ────────────────── */
.bot-card-ext {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bot-header-ext {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bot-title-ext {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.badge-ext {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}
.badge-idle    { background: rgba(139, 148, 158, 0.15); color: var(--muted); }
.badge-running { background: rgba(99, 102, 241, 0.15); color: var(--accent-hover); animation: blink 1.2s ease-in-out infinite; }
.badge-success { background: rgba(63, 185, 80, 0.15); color: var(--success); }
.badge-error   { background: rgba(255, 77, 77, 0.15); color: var(--danger); }

.bot-hint-ext {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
.bot-control-ext {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.interval-row-ext {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.select-ext {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.select-ext:focus {
  outline: none;
  border-color: var(--accent);
}
.bot-btn-row-ext {
  display: flex;
  gap: 8px;
}
.bot-status-details-ext div {
  line-height: 1.4;
}

/* ── Wizard Tab ─────────────────────────────── */
.wizard-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wizard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wizard-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.wizard-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
.wizard-control {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}
.wizard-count-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.wizard-btn-row {
  display: flex;
  gap: 8px;
}
.wiz-btn-start {
  flex: 1;
  background: linear-gradient(135deg, #10b981, #059669) !important;
  font-size: 12px !important;
  padding: 9px 12px !important;
}
.wiz-btn-start:hover { opacity: 0.9; }
.wiz-btn-stop {
  flex: 1;
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  border-color: #ef4444 !important;
  font-size: 12px !important;
  padding: 9px 12px !important;
}

/* Progress */
.wizard-progress {
  background: rgba(99,102,241,0.06);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 8px;
  padding: 10px;
}
.wizard-progress.hidden { display: none; }
.wiz-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 6px;
}
.wiz-progress-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.wiz-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #10b981);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.wiz-stats-row {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: var(--muted);
}
.wiz-stats-row span { display: flex; align-items: center; gap: 3px; }

/* Log */
.wizard-log-header {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.wizard-log {
  max-height: 160px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 10px;
  font-family: 'Consolas', 'Monaco', monospace;
  color: var(--muted);
  line-height: 1.6;
}
.wizard-log::-webkit-scrollbar { width: 3px; }
.wizard-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.wiz-log-line {
  padding: 2px 8px;
  border-bottom: 1px solid rgba(48,54,61,0.4);
  word-break: break-all;
}
.wiz-log-line:last-child { border-bottom: none; }
.wiz-log-line.error { color: var(--danger); }
.wiz-log-line.success { color: var(--success); }
.wiz-log-line.info { color: var(--accent-hover); }

