/* ═══════════════════════════════════════════════════════════
   VulnScan Dashboard — Dark Security Theme
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg: #0a0e14;
  --bg-card: #11161e;
  --bg-hover: #161c26;
  --border: #1e2632;
  --text: #e0e6ed;
  --text-dim: #7a8694;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --critical: #ef4444;
  --high: #f97316;
  --medium: #eab308;
  --low: #22c55e;
  --info: #6b7280;
  --success: #22c55e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── 헤더 ────────────────────────────────────────────────── */
.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
.logo { font-size: 22px; font-weight: 700; }
.subtitle { color: var(--text-dim); font-size: 13px; }
.header-right { display: flex; gap: 8px; }
.api-key-input {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 6px 10px; border-radius: 6px;
  font-size: 13px; width: 180px; font-family: 'JetBrains Mono', monospace;
}
.btn-small {
  background: var(--accent); color: white; border: none;
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.btn-small:hover { background: var(--accent-hover); }

.btn-download {
  background: var(--success); color: white; text-decoration: none;
  padding: 6px 14px; border-radius: 6px; font-size: 13px;
  font-weight: 600; display: inline-flex; align-items: center; gap: 4px;
  transition: opacity 0.2s;
}
.btn-download:hover { opacity: 0.85; }

.download-section {
  margin-top: 40px; padding: 24px; border: 1px dashed var(--border);
  border-radius: 12px; background: var(--bg-card);
}
.download-section h3 {
  font-size: 16px; margin-bottom: 16px; color: var(--text);
}
.btn-download-lg {
  background: var(--success); color: white; text-decoration: none;
  padding: 12px 28px; border-radius: 10px; font-size: 16px;
  font-weight: 600; display: inline-block; transition: opacity 0.2s;
}
.btn-download-lg:hover { opacity: 0.85; }
.download-guide {
  margin-top: 14px; font-size: 13px; color: var(--text-dim); line-height: 1.8;
}
.download-guide code {
  background: var(--bg); padding: 2px 8px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; color: var(--accent);
}

/* ── 최근 스캔 이력 (첫 화면) ─────────────────────────────── */
.recent-scans-section {
  margin: 40px auto 0; max-width: 700px; text-align: left;
  padding: 20px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-card);
}
.recent-scans-section h3 {
  font-size: 16px; margin-bottom: 14px; color: var(--text);
}
.recent-scan-list { max-height: 320px; overflow-y: auto; }
.recent-scan-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.2s; border-radius: 8px;
}
.recent-scan-item:hover { background: var(--bg-hover); }
.recent-scan-item:last-child { margin-bottom: 0; }
.recent-scan-date { font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; min-width: 130px; }
.recent-scan-url { flex: 1; font-size: 14px; color: var(--text); }
.recent-scan-score { font-size: 18px; font-weight: 700; font-family: 'JetBrains Mono', monospace; min-width: 40px; text-align: right; }
.recent-scan-grade { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.recent-scan-findings { font-size: 11px; color: var(--text-dim); }
.recent-scan-empty { text-align: center; padding: 30px; color: var(--text-dim); font-size: 14px; }

.recent-scan-more {
  text-align: center; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border);
}
.recent-scan-more a { color: var(--accent); font-size: 13px; text-decoration: none; cursor: pointer; }
.recent-scan-more a:hover { text-decoration: underline; }

/* ── 스캔 입력 ────────────────────────────────────────────── */
.scan-input-section {
  padding: 32px 24px; max-width: 1200px; margin: 0 auto;
}
.scan-input-box { display: flex; gap: 12px; max-width: 700px; margin: 0 auto; }
.url-input {
  flex: 1; padding: 14px 18px; font-size: 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; outline: none;
  transition: border-color 0.2s;
}
.url-input:focus { border-color: var(--accent); }
.btn-scan {
  padding: 14px 28px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: white; border: none;
  border-radius: 10px; cursor: pointer; transition: background 0.2s;
}
.btn-scan:hover { background: var(--accent-hover); }
.btn-scan:disabled { opacity: 0.5; cursor: wait; }

.scan-status {
  text-align: center; margin-top: 16px; color: var(--text-dim); font-size: 14px;
}
.scan-status.error { color: var(--critical); }
.scan-status.success { color: var(--success); }

/* ── 빈 상태 ──────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 80px 24px; color: var(--text-dim);
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ── 대시보드 ──────────────────────────────────────────────── */
.dashboard { max-width: 1200px; margin: 0 auto; padding: 0 24px 40px; }

/* ── 요약 카드 ────────────────────────────────────────────── */
.summary-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 24px;
}
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; text-align: center;
}
.card-label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.card-value { font-size: 28px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.card-grade { font-size: 11px; font-weight: 600; margin-top: 4px; text-transform: uppercase; }

.card-risk { border-color: var(--medium); grid-column: span 2; }
.card-risk .card-value { font-size: 36px; }
.card-critical { border-color: var(--critical); }
.card-critical .card-value { color: var(--critical); }
.card-high { border-color: var(--high); }
.card-high .card-value { color: var(--high); }
.card-medium { border-color: var(--medium); }
.card-medium .card-value { color: var(--medium); }
.card-low { border-color: var(--low); }
.card-low .card-value { color: var(--low); }

.risk-bar {
  height: 4px; background: var(--border); border-radius: 2px; margin-top: 10px; overflow: hidden;
}
.risk-bar-fill {
  height: 100%; width: 0%; border-radius: 2px; transition: width 0.5s ease;
}

/* ── 탭 ──────────────────────────────────────────────────── */
.tab-nav {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px; flex-wrap: wrap;
}
.tab-btn {
  padding: 10px 18px; background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab-btn:hover { color: var(--text); background: var(--bg-hover); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── 취약점 목록 ──────────────────────────────────────────── */
.findings-list { display: flex; flex-direction: column; gap: 12px; }
.finding-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; border-left: 4px solid var(--info);
}
.finding-item.severity-critical { border-left-color: var(--critical); }
.finding-item.severity-high { border-left-color: var(--high); }
.finding-item.severity-medium { border-left-color: var(--medium); }
.finding-item.severity-low { border-left-color: var(--low); }
.finding-item.severity-info { border-left-color: var(--info); }

.finding-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.severity-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase;
}
.severity-badge.critical { background: var(--critical); color: white; }
.severity-badge.high { background: var(--high); color: white; }
.severity-badge.medium { background: var(--medium); color: black; }
.severity-badge.low { background: var(--low); color: black; }
.severity-badge.info { background: var(--info); color: white; }

.finding-title { font-weight: 600; font-size: 15px; }
.finding-category {
  margin-left: auto; font-size: 11px; color: var(--text-dim);
  background: var(--bg); padding: 2px 8px; border-radius: 4px;
}
.finding-desc { font-size: 14px; color: var(--text); margin-bottom: 8px; line-height: 1.5; }
.finding-evidence {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  background: var(--bg); padding: 8px 12px; border-radius: 6px;
  color: var(--text-dim); margin-bottom: 8px; overflow-x: auto;
}
.finding-remediation {
  font-size: 13px; color: var(--success); display: flex; gap: 6px;
}
.finding-remediation::before { content: "💡"; }

/* ── 리포트 콘텐츠 ────────────────────────────────────────── */
.report-content {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 24px; line-height: 1.7; font-size: 14px;
  max-height: 75vh; overflow-y: auto;
}

/* ── 리포트 다운로드 버튼 ─────────────────────────────────── */
.report-actions {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.btn-dl {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px;
  font-weight: 500; transition: all 0.2s;
}
.btn-dl:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }
.btn-dl:active { transform: scale(0.98); }
.report-content h1, .report-content h2, .report-content h3 {
  margin: 20px 0 10px; color: var(--text);
}
.report-content h1 { font-size: 22px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.report-content h2 { font-size: 18px; color: var(--accent); }
.report-content h3 { font-size: 16px; }
.report-content p { margin-bottom: 12px; }
.report-content ul, .report-content ol { margin: 10px 0 10px 24px; }
.report-content li { margin-bottom: 6px; }
.report-content table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
}
.report-content th, .report-content td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 13px;
}
.report-content th { background: var(--bg-hover); }
.report-content code {
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  background: var(--bg); padding: 2px 6px; border-radius: 4px; color: var(--accent);
}
.report-content pre {
  background: var(--bg); border: 1px solid var(--border);
  padding: 14px; border-radius: 8px; overflow-x: auto; margin: 12px 0;
  white-space: pre-wrap; word-wrap: break-word; line-height: 1.5;
}
.report-content pre code { background: none; padding: 0; color: var(--text); }
.report-content blockquote {
  border-left: 3px solid var(--medium); padding-left: 14px;
  color: var(--text-dim); margin: 12px 0;
}

.loading {
  text-align: center; padding: 40px; color: var(--text-dim); font-size: 14px;
}
.loading::after {
  content: ""; display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  margin-left: 10px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 헤더 분석 ─────────────────────────────────────────────── */
.header-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.header-item:last-child { border-bottom: none; }
.header-name { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--accent); }
.header-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-dim); }
.header-status { font-size: 18px; }
.header-status.ok { color: var(--success); }
.header-status.fail { color: var(--critical); }

/* ── 이력 ──────────────────────────────────────────────────── */
.history-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: background 0.2s;
}
.history-item:hover { background: var(--bg-hover); }
.history-date { font-size: 12px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.history-url { font-size: 14px; flex: 1; }
.history-score { font-size: 18px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }

/* ── 일괄 스캔 ─────────────────────────────────────────────── */
.batch-section { padding: 10px 0; }
.batch-desc { color: var(--text-dim); font-size: 14px; margin-bottom: 16px; }
.batch-textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 12px; font-size: 13px;
  font-family: 'JetBrains Mono', monospace; resize: vertical; margin-bottom: 12px;
}
.batch-options { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.batch-input {
  width: 70px; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 4px 8px; border-radius: 4px; font-size: 13px;
}
.batch-options label { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }

.batch-status { margin-top: 20px; }
.batch-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.batch-progress-bar { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.batch-progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.batch-stats { display: flex; gap: 20px; align-items: center; font-size: 13px; margin-bottom: 16px; flex-wrap: wrap; }
.batch-stats strong { color: var(--accent); font-family: 'JetBrains Mono', monospace; }

.batch-high-risk { margin-top: 16px; }
.batch-high-risk-item {
  background: var(--bg); border: 1px solid var(--border); border-left: 4px solid var(--critical);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 8px; display: flex;
  align-items: center; gap: 12px; cursor: pointer; transition: background 0.2s;
}
.batch-high-risk-item:hover { background: var(--bg-hover); }
.batch-high-risk-item.grade-DANGER { border-left-color: var(--critical); }
.batch-high-risk-item.grade-WARNING { border-left-color: var(--high); }
.batch-high-risk-item.grade-CAUTION { border-left-color: var(--medium); }
.batch-high-risk-score { font-size: 24px; font-weight: 700; font-family: 'JetBrains Mono', monospace; min-width: 50px; }
.batch-high-risk-url { flex: 1; font-size: 14px; }
.batch-high-risk-grade { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; }
.batch-high-risk-findings { font-size: 11px; color: var(--text-dim); }

/* ── 반응형 ──────────────────────────────────── */
@media (max-width: 768px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .card-risk { grid-column: span 2; }
  .scan-input-box { flex-direction: column; }
  .header { flex-direction: column; gap: 12px; }
  .tab-btn { font-size: 12px; padding: 8px 12px; }
}