/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d1117;
  --bg2:         #161b22;
  --bg3:         #1c2128;
  --bg4:         #21262d;
  --border:      #30363d;
  --border2:     #21262d;
  --accent:      #f97316;
  --accent2:     #fb923c;
  --accent-dim:  #431407;
  --blue:        #38bdf8;
  --blue-dim:    #0c2a3f;
  --green:       #4ade80;
  --green-dim:   #052e16;
  --red:         #f87171;
  --red-dim:     #2a0a0a;
  --yellow:      #fbbf24;
  --yellow-dim:  #1f1500;
  --text:        #e6edf3;
  --text2:       #8b949e;
  --text3:       #484f58;
  --sidebar-w:   260px;
  --topbar-h:    52px;
  --input-h:     80px;
  --radius:      10px;
  --font-ui:     'DM Sans', sans-serif;
  --font-head:   'Syne', sans-serif;
  --font-code:   'JetBrains Mono', monospace;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  display: flex;
}

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform .3s ease;
  z-index: 100;
}

.sidebar-top { padding: 20px 16px; flex: 1; overflow-y: auto; }

.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 18px; height: 18px; fill: white; }
.logo-name { font-family: var(--font-head); font-size: 14px; font-weight: 700; color: var(--text); }
.logo-sub  { font-size: 11px; color: var(--text2); }

.progress-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); margin-bottom: 8px; }
.progress-bar-track { background: var(--bg4); border-radius: 4px; height: 5px; margin-bottom: 4px; overflow: hidden; }
#progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width .5s ease; }
.progress-text { font-size: 11px; color: var(--text2); margin-bottom: 20px; }
#progress-pct { color: var(--accent); font-weight: 600; }

.nav-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); margin-bottom: 8px; }
.sections-nav { margin-top: 4px; }
.nav-item {
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text2);
  margin-bottom: 2px;
  display: flex; align-items: center; gap: 8px;
  cursor: default;
  transition: all .15s;
}
.nav-item.active   { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-item.done     { color: var(--green); }
.nav-item.done::before { content: '✓'; font-size: 11px; }
.nav-item.pending::before { content: '○'; font-size: 10px; color: var(--text3); }
.nav-item.active::before  { content: '▶'; font-size: 10px; }

.sidebar-bottom { padding: 16px; border-top: 1px solid var(--border2); display: flex; flex-direction: column; gap: 8px; }
.sidebar-bottom button {
  width: 100%;
  padding: 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-family: var(--font-ui);
  font-size: 12.5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s;
}
.sidebar-bottom button:hover { border-color: var(--accent); color: var(--accent); }
#report-btn { border-color: var(--blue); color: var(--blue); }
#report-btn:hover { background: var(--blue-dim); }

/* ── Main ───────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border2);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
#menu-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text2); display: none; padding: 4px;
}
#topbar-section {
  flex: 1;
  font-family: var(--font-head);
  font-size: 14px; font-weight: 700;
  color: var(--text);
}
#findings-badge {
  font-size: 12px;
  background: var(--yellow-dim);
  color: var(--yellow);
  border: 1px solid #7c3c00;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

/* ── Chat window ────────────────────────────────────────── */
#chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  scroll-behavior: smooth;
}
#chat-window::-webkit-scrollbar { width: 4px; }
#chat-window::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#messages { max-width: 780px; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; gap: 0; }

/* ── Message bubbles ────────────────────────────────────── */
.msg { display: flex; gap: 12px; margin-bottom: 20px; animation: fadeUp .25s ease; }
@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; margin-top: 2px;
}
.msg.bot  .msg-avatar { background: var(--accent); color: white; font-family: var(--font-head); }
.msg.user .msg-avatar { background: var(--bg4); color: var(--text2); border: 1px solid var(--border); }

.msg-body { flex: 1; min-width: 0; }
.msg-name { font-size: 11.5px; font-weight: 600; letter-spacing: .03em; margin-bottom: 5px; }
.msg.bot  .msg-name { color: var(--accent); }
.msg.user .msg-name { color: var(--text2); }

.msg-content {
  font-size: 14px; line-height: 1.75;
  color: var(--text);
}
.msg.user .msg-content {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  padding: 10px 14px;
  display: inline-block;
  max-width: 100%;
}

/* ── Bot message components ─────────────────────────────── */
.msg-content p { margin-bottom: 8px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { font-weight: 500; color: var(--text); }
.msg-content code {
  font-family: var(--font-code);
  font-size: 12.5px;
  background: var(--bg4);
  border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 4px;
  color: var(--blue);
}
.msg-content pre {
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px; margin: 10px 0;
  overflow-x: auto;
}
.msg-content pre code {
  background: none; border: none; padding: 0;
  color: var(--text); font-size: 12.5px; line-height: 1.6;
}

.callout {
  border-radius: 8px; padding: 10px 14px; margin: 8px 0;
  font-size: 13.5px; border: 1px solid;
}
.callout-good    { background: var(--green-dim);  border-color: #166534;  color: #86efac; }
.callout-bad     { background: var(--red-dim);    border-color: #7f1d1d;  color: #fca5a5; }
.callout-warn    { background: var(--yellow-dim); border-color: #7c3c00;  color: #fde68a; }
.callout-info    { background: var(--blue-dim);   border-color: #1e4a6a;  color: #7dd3fc; }
.callout-finding { background: #16213e; border-color: #375a8c; color: #c9d1d9; }

.sql-block {
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px; margin: 8px 0;
  font-family: var(--font-code);
  font-size: 12px; color: var(--text);
  white-space: pre-wrap; line-height: 1.6;
}
.sql-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text3); margin-bottom: 6px;
}

.resolution-box {
  background: var(--green-dim);
  border: 1px solid #166534;
  border-radius: 8px; padding: 12px 16px; margin: 8px 0;
}
.resolution-title { color: var(--green); font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.resolution-list { list-style: decimal; padding-left: 18px; }
.resolution-list li { color: #86efac; font-size: 13px; margin-bottom: 4px; line-height: 1.5; }

.section-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid #7c2d12; padding: 2px 8px;
  border-radius: 4px; margin-bottom: 8px;
}

/* ── Typing indicator ───────────────────────────────────── */
.typing { display: flex; align-items: center; gap: 5px; padding: 8px 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite; opacity: .3;
}
.typing span:nth-child(2){animation-delay:.2s}
.typing span:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,80%,100%{opacity:.3}40%{opacity:1}}

/* ── Input area ─────────────────────────────────────────── */
#input-area {
  padding: 14px 20px 16px;
  border-top: 1px solid var(--border2);
  background: var(--bg2);
  flex-shrink: 0;
}
#input-wrap {
  max-width: 780px; margin: 0 auto;
  display: flex; gap: 8px; align-items: center;
  position: relative;
}
#user-input {
  flex: 1; background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 11px 16px;
  outline: none;
  transition: border-color .15s;
}
#user-input:focus { border-color: var(--accent); }
#user-input::placeholder { color: var(--text3); }
#user-input:disabled { opacity: .5; cursor: not-allowed; }

#send-btn {
  width: 40px; height: 40px;
  background: var(--accent); border: none;
  border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .15s, transform .1s;
}
#send-btn:hover:not(:disabled) { opacity: .85; }
#send-btn:active:not(:disabled) { transform: scale(.95); }
#send-btn:disabled { opacity: .35; cursor: not-allowed; }

#quick-choices {
  max-width: 780px; margin: 10px auto 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.choice-btn {
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer; transition: all .15s;
  font-family: var(--font-ui);
}
.choice-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── Report modal ───────────────────────────────────────── */
#report-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 20px;
}
#report-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%; max-width: 740px;
  max-height: 88vh;
  display: flex; flex-direction: column;
}
#report-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: space-between;
}
#report-title { font-family: var(--font-head); font-size: 17px; font-weight: 700; color: var(--text); }
#close-report {
  background: none; border: none; color: var(--text2);
  font-size: 18px; cursor: pointer; padding: 4px;
  transition: color .15s;
}
#close-report:hover { color: var(--text); }
#report-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
#report-body::-webkit-scrollbar { width: 4px; }
#report-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#report-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border2);
  display: flex; justify-content: flex-end; gap: 10px;
}
#report-footer button {
  padding: 8px 18px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-family: var(--font-ui);
  font-size: 13px; cursor: pointer;
  transition: all .15s;
}
#report-footer button:first-child { border-color: var(--accent); color: var(--accent); }
#report-footer button:first-child:hover { background: var(--accent-dim); }
#report-footer button:last-child:hover { border-color: var(--text2); color: var(--text); }

/* ── Report cards ───────────────────────────────────────── */
.report-summary { display: flex; gap: 10px; margin-bottom: 20px; }
.report-count-card {
  flex: 1; border-radius: 8px; padding: 12px; text-align: center;
  border: 1px solid;
}
.report-count-card .num { font-size: 28px; font-weight: 800; font-family: var(--font-head); }
.report-count-card .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; margin-top: 2px; }
.sev-CRITICAL { background: var(--red-dim);    border-color: #7f1d1d; color: var(--red); }
.sev-HIGH     { background: var(--yellow-dim); border-color: #7c3c00; color: var(--yellow); }
.sev-MEDIUM   { background: var(--blue-dim);   border-color: #1e4a6a; color: var(--blue); }
.sev-OK       { background: var(--green-dim);  border-color: #166534; color: var(--green); }

.report-finding {
  border-radius: 8px; padding: 14px 16px; margin-bottom: 12px;
  border: 1px solid;
}
.report-finding-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sev-badge {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; padding: 2px 7px; border-radius: 3px; color: #000;
  flex-shrink: 0;
}
.finding-title { font-size: 13px; font-weight: 600; color: var(--text); }
.finding-section { font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.finding-steps { list-style: decimal; padding-left: 18px; }
.finding-steps li { font-size: 12.5px; color: var(--text2); margin-bottom: 3px; line-height: 1.5; }
.finding-sql {
  margin-top: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px;
  font-family: var(--font-code); font-size: 11.5px;
  color: var(--text); white-space: pre-wrap;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
  }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.5); }
  #menu-toggle { display: block; }
  #messages { padding: 0 14px; }
  #input-area { padding: 10px 14px 12px; }
  .report-summary { flex-wrap: wrap; }
  .report-count-card { min-width: calc(50% - 5px); }
}
