/* TechCorp Industries — Financial AI Assistant */

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

:root {
  --bg:           #0a0f14;
  --surface:      #111820;
  --surface2:     #1a2330;
  --surface3:     #202c3b;
  --border:       #263040;
  --accent:       #2ea44f;
  --accent-dim:   #1f7a3a;
  --accent-glow:  rgba(46,164,79,.15);
  --accent-text:  #4ade80;
  --text:         #e2eaf4;
  --text-muted:   #7a8fa6;
  --text-dim:     #4a5e72;
  --user-bg:      #1a3a6b;
  --user-border:  #2563b0;
  --red:          #f85149;
  --red-dim:      rgba(248,81,73,.12);
  --radius:       12px;
  --radius-lg:    18px;
  --sidebar-w:    260px;
  --transition:   .18s ease;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.65; overflow: hidden; }

/* ── Layout ─────────────────────────────────────────────── */
body { display: flex; height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 6px;
  flex-shrink: 0;
  transition: transform var(--transition);
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.logo-icon svg { width: 36px; height: 36px; flex-shrink: 0; }

.sidebar-title { font-weight: 700; font-size: 15px; color: var(--text); }
.sidebar-sub   { font-size: 11px; color: var(--text-muted); }

.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 6px;
}
.btn-new-chat svg { width: 16px; height: 16px; }
.btn-new-chat:hover { background: var(--accent-dim); }

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
  padding: 10px 6px 4px;
}

.sidebar-chips { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }

.side-chip {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-chip:hover { background: var(--surface2); color: var(--text); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  padding: 4px 6px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.connected    { background: var(--accent); animation: pulse 2s infinite; }
.status-dot.disconnected { background: var(--red); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.server-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.btn-settings {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-settings svg { width: 15px; height: 15px; }
.btn-settings:hover { border-color: var(--accent); color: var(--text); }

/* ── Main ────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Topbar (mobile) ─────────────────────────────────────── */
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-title { flex: 1; font-weight: 600; font-size: 15px; }
.btn-icon-sm {
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer; line-height: 1;
}
.conn-dot-mini {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim); flex-shrink: 0;
}
.conn-dot-mini.connected    { background: var(--accent); }
.conn-dot-mini.disconnected { background: var(--red); }

/* ── Chat area ───────────────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scroll-behavior: smooth;
}
.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Welcome ─────────────────────────────────────────────── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  gap: 16px;
  max-width: 640px;
  margin: auto;
  animation: fadeUp .4s ease;
}
.welcome-icon svg { width: 56px; height: 56px; }
.welcome-title { font-size: 24px; font-weight: 700; color: var(--text); }
.welcome-sub { font-size: 14px; color: var(--text-muted); max-width: 480px; }

.welcome-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin-top: 12px;
}

.wcard {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}
.wcard:hover { border-color: var(--accent); background: var(--surface2); transform: translateY(-1px); }
.wcard-icon { font-size: 18px; flex-shrink: 0; }
.wcard-label { font-size: 13px; color: var(--text); line-height: 1.4; }

@keyframes fadeUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }

/* ── Messages ────────────────────────────────────────────── */
.msg-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  animation: fadeUp .2s ease;
}
.msg-row.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
  margin-top: 3px;
}
.msg-row.user .msg-avatar {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  color: #93c5fd;
}
.msg-row.assistant .msg-avatar {
  background: var(--surface2);
  border: 1px solid var(--border);
}
.msg-row.assistant .msg-avatar svg { width: 24px; height: 24px; }

.msg-bubble {
  padding: 13px 17px;
  border-radius: var(--radius-lg);
  max-width: 78%;
  font-size: 14.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.user .msg-bubble {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-top-right-radius: 4px;
  color: #dbeafe;
}
.msg-row.assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text);
}
.msg-bubble .err { color: var(--red); }

.blink { display: inline-block; animation: blink .6s steps(1) infinite; color: var(--accent); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Input bar ───────────────────────────────────────────── */
.input-bar {
  padding: 12px 20px 18px;
  flex-shrink: 0;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.input-box {
  display: flex;
  align-items: flex-end;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px 10px 16px;
  gap: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea#user-input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.65;
  resize: none;
  min-height: 40px;
  max-height: 180px;
  overflow-y: auto;
  padding: 2px 0;
}
textarea#user-input::placeholder { color: var(--text-dim); }

.input-actions { display: flex; align-items: flex-end; gap: 8px; }

.char-count { font-size: 11px; color: var(--text-dim); padding-bottom: 4px; }

.btn-send {
  width: 38px; height: 38px;
  background: var(--accent);
  border: none; border-radius: 10px;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.btn-send svg { width: 18px; height: 18px; }
.btn-send:hover:not(:disabled) { background: var(--accent-dim); }
.btn-send:disabled { opacity: .35; cursor: not-allowed; }
.btn-send.loading { animation: spin 1s linear infinite; background: var(--accent-dim); }
@keyframes spin { to{transform:rotate(360deg)} }

.input-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 6px 4px 0;
  display: flex;
  gap: 6px;
}
.link-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: inherit; cursor: pointer; text-decoration: underline;
  padding: 0;
}
.link-btn:hover { color: var(--text-muted); }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 20px; border-radius: 100px;
  font-size: 13px; opacity: 0;
  transition: all .3s; z-index: 200; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 460px; max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: fadeUp .2s ease;
  overflow: hidden;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { background: var(--surface3); }

.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.field input, .field select {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 12px;
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color var(--transition);
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field small { font-size: 11px; color: var(--text-dim); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px 20px; border-top: 1px solid var(--border);
}

.btn-primary {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 9px 20px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: background var(--transition);
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 8px; padding: 9px 16px;
  font-size: 13px; cursor: pointer; transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

.test-result {
  margin: 0 24px 16px; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
}
.test-result.hidden { display: none; }
.test-result.ok  { background: var(--accent-glow); color: var(--accent-text); border: 1px solid #2ea44f40; }
.test-result.nok { background: var(--red-dim); color: var(--red); border: 1px solid #f8514940; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 720px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; }
  .chat-area { padding: 16px 12px; }
  .input-bar { padding: 8px 12px 14px; }
  .msg-bubble { max-width: 90%; }
  .welcome-cards { grid-template-columns: 1fr; }
}
