/* ============================================
   NetLab — Unified Design System
   All pages. One stylesheet.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800;900&family=Geist+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

:root {
  --bg:        #080808;
  --surface:   #0f0f0f;
  --surface2:  #161616;
  --surface3:  #1c1c1c;
  --border:    rgba(255,255,255,0.07);
  --border-hi: rgba(255,255,255,0.13);

  --accent:    #4f8ef7;
  --accent-lo: rgba(79,142,247,0.08);
  --accent-md: rgba(79,142,247,0.16);

  --ok:    #4ade80;
  --warn:  #facc15;
  --err:   #f87171;

  --text:  #ffffff;
  --text2: rgba(255,255,255,0.72);
  --text3: rgba(255,255,255,0.4);

  --font: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', monospace;

  --ease-soft: cubic-bezier(0.23, 1, 0.32, 1);
  --r:  12px;
  --r2: 20px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 99px; }

/* Fixed grain */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px; opacity: 0.025;
}

/* ── Page wrapper ─────────────────────────── */
.page { position: relative; z-index: 2; padding-top: 80px; }

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px; border-radius: 99px;
  font-size: 0.88rem; font-weight: 600; font-family: var(--font);
  border: none; cursor: pointer;
  transition: opacity 150ms, transform 160ms var(--ease-soft);
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; }

.btn-white {
  background: #ffffff; color: #080808;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.btn-white:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent; border: 1px solid var(--border-hi); color: var(--text2);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.04); }

.btn-accent {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 20px rgba(79,142,247,0.25);
}
.btn-accent:hover { opacity: 0.9; }

.btn-sm { padding: 7px 16px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Panel cards ──────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 28px;
  display: flex; flex-direction: column; gap: 16px;
}

.panel-label {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text3);
  display: flex; align-items: center; gap: 8px;
}

.panel-label::before {
  content: ''; width: 3px; height: 12px;
  background: var(--accent); border-radius: 2px;
}

/* ── Terminal textarea ────────────────────── */
.log-input {
  width: 100%; flex: 1; min-height: 320px;
  background: #050505; border: 1px solid var(--border);
  border-radius: var(--r); color: rgba(79,142,247,0.9);
  font-family: var(--mono); font-size: 0.78rem; line-height: 1.85;
  padding: 16px; resize: vertical; outline: none;
  transition: border-color 150ms var(--ease-soft), box-shadow 150ms var(--ease-soft);
}
.log-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-lo); }
.log-input::placeholder { color: rgba(255,255,255,0.08); }
.log-input[readonly] { cursor: default; }

/* ── Lang toggle ──────────────────────────── */
.lang-toggle {
  display: flex; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 99px;
  padding: 3px; gap: 3px; width: fit-content;
}

.lang-btn {
  padding: 4px 14px; border-radius: 99px; font-size: 0.78rem; font-weight: 600;
  border: none; background: transparent; color: var(--text3); cursor: pointer;
  transition: background 150ms, color 150ms; font-family: var(--font);
}
.lang-btn.active { background: var(--accent); color: #fff; }

/* ── Sample tags ──────────────────────────── */
.sample-tag {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 99px; padding: 4px 12px;
  font-size: 0.7rem; font-family: var(--mono); color: var(--text3);
  cursor: pointer; transition: border-color 150ms, color 150ms;
}
.sample-tag:hover { border-color: var(--accent); color: var(--accent); }
.sample-tag:active { transform: scale(0.97); }

/* ── Result states ────────────────────────── */
.result-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; text-align: center;
  color: var(--text3); font-size: 0.85rem; padding: 40px;
}

.loading-state { display: none; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 20px; }
.loading-state.visible { display: flex; }

.loader-ring {
  width: 44px; height: 44px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-text { font-size: 0.82rem; color: var(--text2); font-family: var(--mono); }

.progress-wrap { width: 180px; height: 2px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 99px; width: 0%; transition: width 100ms ease; }

/* ── Result card ──────────────────────────── */
.result-card { display: none; flex-direction: column; gap: 16px; animation: fadeUp 300ms var(--ease-soft); }
.result-card.visible { display: flex; }

.sev-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 99px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  width: fit-content;
}

.sev-pill.critical { background: rgba(248,113,113,0.1); color: var(--err); border: 1px solid rgba(248,113,113,0.25); }
.sev-pill.warning  { background: rgba(250,204,21,0.1); color: var(--warn); border: 1px solid rgba(250,204,21,0.25); }
.sev-pill.ok       { background: rgba(74,222,128,0.1); color: var(--ok);  border: 1px solid rgba(74,222,128,0.25); }

.result-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }

.result-explanation {
  font-size: 0.85rem; color: var(--text2); line-height: 1.75;
  background: var(--surface2); border-radius: var(--r); padding: 16px;
  border-left: 2px solid var(--accent);
}

.result-steps { list-style: none; display: flex; flex-direction: column; gap: 9px; }

.result-steps li {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 0.83rem; color: var(--text2);
  opacity: 0; animation: stepIn 280ms var(--ease-soft) forwards;
}

.result-steps li:nth-child(1) { animation-delay: 60ms; }
.result-steps li:nth-child(2) { animation-delay: 110ms; }
.result-steps li:nth-child(3) { animation-delay: 160ms; }
.result-steps li:nth-child(4) { animation-delay: 210ms; }
.result-steps li:nth-child(5) { animation-delay: 260ms; }

@keyframes stepIn { from { opacity:0; transform:translateX(-8px); } to { opacity:1; transform:translateX(0); } }

.step-num {
  min-width: 20px; height: 20px; border-radius: 4px;
  background: var(--accent-lo); border: 1px solid rgba(79,142,247,0.2);
  color: var(--accent); font-size: 0.65rem; font-weight: 700;
  font-family: var(--mono); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}

.router-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px;
  font-size: 0.72rem; color: var(--text3); font-family: var(--mono);
}

/* ── Analyzer layout ──────────────────────── */
.analyzer-wrap {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  max-width: 1300px; margin: 0 auto; padding: 32px 40px;
  min-height: calc(100vh - 80px);
}

/* ── Disclaimer inline ────────────────────── */
.disclaimer-inline {
  background: rgba(250,204,21,0.04); border: 1px solid rgba(250,204,21,0.14);
  border-left: 2px solid var(--warn); border-radius: var(--r);
  padding: 10px 14px; font-size: 0.73rem; color: var(--text3); line-height: 1.6;
}
.disclaimer-inline strong { color: var(--warn); }
.disclaimer-inline a { color: var(--accent); }

/* ── Page inner (non-analyzer pages) ─────── */
.page-inner { max-width: 760px; margin: 0 auto; padding: 48px 40px 80px; }

.page-hero { text-align: center; margin-bottom: 48px; }
.page-hero h1 { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 10px; }
.page-hero p  { color: var(--text2); font-size: 0.95rem; line-height: 1.65; }
.page-hero .bm { color: var(--text3); font-size: 0.82rem; margin-top: 4px; }

/* ── Step cards ───────────────────────────── */
.step-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r2); padding: 26px; margin-bottom: 16px;
  transition: border-color 250ms var(--ease-soft);
}
.step-card:focus-within { border-color: var(--border-hi); }

.step-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }

.step-badge {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: var(--accent-lo); border: 1px solid rgba(79,142,247,0.2);
  color: var(--accent); font-weight: 700; font-size: 0.82rem; font-family: var(--mono);
  display: flex; align-items: center; justify-content: center;
}

.step-badge.done { background: rgba(74,222,128,0.1); border-color: rgba(74,222,128,0.25); color: var(--ok); }

.step-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.step-sub   { font-size: 0.78rem; color: var(--text3); margin-top: 3px; }

/* ── IP input ─────────────────────────────── */
.ip-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text); font-family: var(--mono);
  font-size: 0.95rem; padding: 10px 14px; outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.ip-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-lo); }

.ip-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.ip-preset {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 99px; padding: 3px 11px;
  font-size: 0.72rem; font-family: var(--mono); color: var(--text3);
  cursor: pointer; transition: border-color 150ms, color 150ms;
}
.ip-preset:hover { border-color: var(--accent); color: var(--accent); }

/* ── Progress log ─────────────────────────── */
.progress-log {
  background: #050505; border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px; font-family: var(--mono); font-size: 0.72rem;
  line-height: 1.9; max-height: 190px; overflow-y: auto; color: var(--text3);
}
.log-ok   { color: var(--ok); display: block; }
.log-fail { color: var(--err); display: block; }
.log-info { color: var(--accent); display: block; }

/* ── Upload zone ──────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--r2);
  padding: 56px 24px; text-align: center; cursor: pointer; position: relative;
  transition: border-color 200ms, background 200ms; background: var(--surface);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-lo); }
.upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* ── QR step indicator ────────────────────── */
.qr-steps { display: flex; gap: 0; position: relative; margin-bottom: 36px; }
.qr-steps::before {
  content: ''; position: absolute; top: 16px; left: 10%; right: 10%;
  height: 1px; background: var(--border);
}
.qr-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; z-index: 1; }

.qr-dot {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem; font-family: var(--mono); color: var(--text3);
  transition: background 200ms, border-color 200ms, color 200ms, box-shadow 200ms;
}
.qr-step.active .qr-dot {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 0 16px rgba(79,142,247,0.35);
}
.qr-step-lbl { font-size: 0.68rem; color: var(--text3); text-align: center; }

/* ══════════════════════════════════════
   CHAT PAGE — Clean, simple, refreshing
══════════════════════════════════════ */
.chat-page { display: flex; flex-direction: column; height: calc(100vh - 80px); }

.chat-topbar {
  padding: 16px 40px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); flex-shrink: 0;
}

.chat-topbar-left { display: flex; align-items: center; gap: 12px; }

.chat-ai-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent-lo); border: 1px solid rgba(79,142,247,0.25);
  display: flex; align-items: center; justify-content: center;
}
.chat-ai-avatar svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 1.5; }

.chat-ai-name  { font-weight: 700; font-size: 0.92rem; }
.chat-ai-model { font-size: 0.72rem; color: var(--text3); font-family: var(--mono); }

.status-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 99px; padding: 5px 14px; font-size: 0.72rem; font-family: var(--mono); color: var(--text3);
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text3); }
.status-dot.on  { background: var(--ok); box-shadow: 0 0 6px var(--ok); animation: dotPulse 2s ease-in-out infinite; }
.status-dot.off { background: var(--err); }

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

/* Messages area */
.messages {
  flex: 1; overflow-y: auto; padding: 40px;
  display: flex; flex-direction: column; gap: 24px;
  max-width: 860px; width: 100%; margin: 0 auto; align-self: center;
}

/* Welcome */
.chat-welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 32px; text-align: center;
  flex: 1; padding: 40px;
  animation: fadeUp 400ms var(--ease-soft);
}

.welcome-avatar {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.welcome-avatar svg { width: 28px; height: 28px; stroke: var(--accent); fill: none; stroke-width: 1.5; }

.welcome-heading { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; }
.welcome-sub     { font-size: 0.92rem; color: var(--text2); max-width: 400px; line-height: 1.7; }
.welcome-bm      { font-size: 0.8rem; color: var(--text3); margin-top: 2px; }

/* Quick prompts */
.quick-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  max-width: 540px; width: 100%;
}

.quick-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px;
  font-size: 0.82rem; color: var(--text2); cursor: pointer; text-align: left;
  transition: border-color 150ms, background 150ms, transform 160ms var(--ease-soft);
  border: none; font-family: var(--font); width: 100%;
  border: 1px solid var(--border);
}
.quick-card:hover { border-color: rgba(79,142,247,0.3); background: var(--surface2); color: var(--text); }
.quick-card:active { transform: scale(0.97); }
.quick-title { font-weight: 700; font-size: 0.85rem; color: var(--text); margin-bottom: 3px; }
.quick-sub   { font-size: 0.75rem; color: var(--text3); }

/* Messages */
.message { display: flex; gap: 12px; animation: fadeUp 250ms var(--ease-soft); max-width: 100%; }
.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; align-self: flex-end;
}
.msg-avatar svg { width: 14px; height: 14px; stroke: var(--text3); fill: none; stroke-width: 1.5; }
.message.user .msg-avatar { background: var(--accent-lo); border-color: rgba(79,142,247,0.2); }
.message.user .msg-avatar svg { stroke: var(--accent); }

.msg-bubble {
  padding: 12px 16px; border-radius: 16px;
  font-size: 0.875rem; line-height: 1.7; word-break: break-word;
  max-width: calc(100% - 50px);
}

.message.ai   .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.message.user .msg-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; font-weight: 500; }

.thinking {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; border-bottom-left-radius: 4px; width: fit-content;
  font-size: 0.75rem; color: var(--text3);
}

.thinking-dots { display: flex; gap: 4px; }
.thinking-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--text3);
  animation: dotBounce 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes dotBounce { 0%,60%,100%{transform:translateY(0);opacity:0.35} 30%{transform:translateY(-5px);opacity:1} }

.cursor-blink {
  display: inline-block; width: 2px; height: 1em;
  background: var(--accent); margin-left: 2px; vertical-align: middle;
  animation: blink 0.8s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Chat input */
.chat-input-area {
  padding: 16px 40px 24px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  max-width: 860px; width: 100%; margin: 0 auto; align-self: center; flex-shrink: 0;
}

.offline-note {
  background: rgba(248,113,113,0.06); border: 1px solid rgba(248,113,113,0.15);
  border-radius: var(--r); padding: 10px 14px; font-size: 0.75rem; color: var(--text3);
  display: none;
}

.attach-toggle {
  display: flex; align-items: center; gap: 7px; font-size: 0.73rem; color: var(--text3);
  cursor: pointer; width: fit-content; border: none; background: none; font-family: var(--font);
  transition: color 150ms;
}
.attach-toggle:hover { color: var(--accent); }

.attach-box { display: none; }
.attach-box.open { display: block; }

.attach-input {
  width: 100%; background: #050505; border: 1px solid var(--border);
  border-radius: var(--r); color: rgba(79,142,247,0.8); font-family: var(--mono);
  font-size: 0.73rem; padding: 12px; resize: vertical; min-height: 80px; max-height: 140px; outline: none;
  transition: border-color 150ms;
}
.attach-input:focus { border-color: var(--accent); }

.input-row { display: flex; gap: 10px; align-items: flex-end; }

.chat-input {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; color: var(--text); font-family: var(--font);
  font-size: 0.88rem; padding: 12px 16px; resize: none;
  min-height: 48px; max-height: 120px; outline: none; line-height: 1.5;
  overflow-y: hidden; transition: border-color 150ms, box-shadow 150ms;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-lo); }

.send-btn {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--accent); border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 150ms, transform 160ms var(--ease-soft);
  box-shadow: 0 4px 16px rgba(79,142,247,0.25);
}
.send-btn:hover { opacity: 0.9; }
.send-btn:active { transform: scale(0.97); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.send-btn svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; }

.input-hint { font-size: 0.68rem; color: var(--text3); text-align: center; }

/* ── Utilities ────────────────────────────── */
.hidden { display: none !important; }
.font-mono { font-family: var(--mono); }
.text-accent { color: var(--accent); }
.text-muted  { color: var(--text3); }

/* ── Keyframes ────────────────────────────── */
@keyframes fadeUp { from{opacity:0;transform:translateY(14px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
