/* public/css/app.css */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Syne:wght@400;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg-primary:    #050c1a;
  --bg-secondary:  #0a1628;
  --bg-card:       #0d1d35;
  --bg-hover:      #112040;
  --border:        #1a3050;
  --border-light:  #1e3860;
  --text-primary:  #e2eaf5;
  --text-secondary:#7a9bc4;
  --text-muted:    #3d6090;
  --accent:        #0ea5e9;
  --accent-dim:    rgba(14,165,233,.15);
  --green:         #10b981;
  --green-dim:     rgba(16,185,129,.12);
  --yellow:        #f59e0b;
  --yellow-dim:    rgba(245,158,11,.12);
  --red:           #ef4444;
  --red-dim:       rgba(239,68,68,.12);
  --orange:        #f97316;
  --sidebar-w:     256px;
  --radius:        8px;
  --font-ui:       'Inter', sans-serif;
  --font-head:     'Syne', sans-serif;
  --font-mono:     'IBM Plex Mono', monospace;
}

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

html { font-size: 14px; }

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

/* ── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.logo-text { font-family: var(--font-head); font-weight: 800; font-size: 16px; color: var(--text-primary); }
.logo-version { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

.sidebar-section { padding: 16px 12px 4px; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  text-decoration: none;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(14,165,233,.2);
}
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.plan-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.plan-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--yellow);
  text-transform: uppercase;
}
.plan-scans { font-size: 11px; color: var(--text-muted); }

/* ── Main Content ────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-family: var(--font-head); font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page { padding: 28px; display: none; }
.page.active { display: block; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  font-family: var(--font-ui);
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0284c7; }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-icon      { padding: 7px; border-radius: 6px; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-family: var(--font-head); font-size: 15px; font-weight: 700; }

/* ── Stats Grid ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat-card.green::before { background: var(--green); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-card.red::before { background: var(--red); }
.stat-card.blue::before { background: var(--accent); }

.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-family: var(--font-head); font-size: 32px; font-weight: 800; line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Score Circle ────────────────────────────────────────────────────── */
.score-ring {
  width: 100px; height: 100px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.score-ring svg { position: absolute; top: 0; left: 0; transform: rotate(-90deg); }
.score-ring .score-val {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 800;
  z-index: 1;
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(26,48,80,.5);
  font-size: 13px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }

/* ── Severity Badges ─────────────────────────────────────────────────── */
.sev {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sev-critical { background: var(--red-dim);    color: var(--red); }
.sev-high     { background: rgba(249,115,22,.12); color: var(--orange); }
.sev-medium   { background: var(--yellow-dim); color: var(--yellow); }
.sev-low      { background: rgba(59,130,246,.12); color: #60a5fa; }
.sev-info     { background: rgba(107,114,128,.12); color: #9ca3af; }

/* ── Status Pills ────────────────────────────────────────────────────── */
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-green  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.status-red    { background: var(--red); box-shadow: 0 0 6px var(--red); }

.traffic-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.pill-green  { background: var(--green-dim);  color: var(--green); }
.pill-yellow { background: var(--yellow-dim); color: var(--yellow); }
.pill-red    { background: var(--red-dim);    color: var(--red); }
.pill-blue   { background: var(--accent-dim); color: var(--accent); }

/* ── Module Status Grid ──────────────────────────────────────────────── */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.module-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.module-icon { font-size: 24px; margin-bottom: 6px; }
.module-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.module-score { font-family: var(--font-mono); font-size: 20px; font-weight: 500; margin: 4px 0; }

/* ── Findings List ───────────────────────────────────────────────────── */
.finding-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .15s;
}
.finding-item:hover { border-color: var(--border-light) !important; background: var(--bg-hover); }
.finding-item.critical { border-left-color: var(--red); }
.finding-item.high     { border-left-color: var(--orange); }
.finding-item.medium   { border-left-color: var(--yellow); }
.finding-item.low      { border-left-color: #60a5fa; }
.finding-item.info     { border-left-color: #6b7280; }

.finding-header { display: flex; align-items: center; justify-content: space-between; }
.finding-title  { font-size: 13px; font-weight: 600; }
.finding-meta   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.finding-body   { display: none; margin-top: 12px; }
.finding-body.open { display: block; }

.fix-box {
  background: var(--green-dim);
  border: 1px solid rgba(16,185,129,.2);
  border-radius: 6px;
  padding: 12px;
  margin-top: 10px;
}
.fix-box h4 { color: var(--green); font-size: 12px; margin-bottom: 6px; }
.fix-steps  { list-style: none; }
.fix-steps li {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
  padding-left: 18px;
  position: relative;
}
.fix-steps li::before {
  content: counter(step-counter);
  counter-increment: step-counter;
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
  font-family: var(--font-mono);
}
.fix-steps { counter-reset: step-counter; }

/* ── Forms ───────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.form-input, .form-select {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-ui);
  transition: border-color .15s;
  outline: none;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Permission Warning ──────────────────────────────────────────────── */
.perm-warning {
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.perm-warning-icon { font-size: 20px; }
.perm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  cursor: pointer;
}
.perm-check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ── Module Checkboxes ───────────────────────────────────────────────── */
.module-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.module-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  font-size: 13px;
}
.module-check input { accent-color: var(--accent); }
.module-check:has(input:checked) {
  border-color: rgba(14,165,233,.4);
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── Compliance ──────────────────────────────────────────────────────── */
.owasp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.owasp-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.owasp-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 4px;
}
.owasp-name { font-size: 12px; font-weight: 600; }
.owasp-count {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
}

/* ── Progress Bar ────────────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .5s ease;
}

/* ── Pulse animation for running scans ───────────────────────────────── */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.pulse { animation: pulse 2s infinite; }

/* ── Fade in ─────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity:0; transform:translateY(12px); }
  to   { opacity:1; transform:translateY(0); }
}
.fade-up { animation: fadeUp .3s ease forwards; }

/* ── Login Page ──────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(14,165,233,.06) 0%, transparent 70%);
  top: -200px; right: -100px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  position: relative;
  z-index: 1;
}

/* ── Scan status colors ──────────────────────────────────────────────── */
.status-queued   { color: var(--text-muted); }
.status-running  { color: var(--accent); }
.status-completed { color: var(--green); }
.status-failed   { color: var(--red); }

/* ── Alert boxes ─────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,.3); }
.alert-info { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(14,165,233,.3); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
