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

:root {
  --navy: #042C53; --navy-deep: #021B35; --navy-mid: #0A3A6B;
  --blue: #378ADD; --blue-light: #5AA3E8;
  --teal: #1D9E75; --teal-light: #25C692;
  --amber: #E8A317; --red: #D94052;
  --surface: #081E36; --surface-raised: #0C2A4A; --surface-card: #102F52;
  --border: rgba(255,255,255,0.08); --border-light: rgba(255,255,255,0.05);
  --text: #E8EDF3; --text-sec: #8BA3BE; --text-muted: #5A7A98;
  --font: 'DM Sans', -apple-system, sans-serif; --font-mono: 'JetBrains Mono', monospace;
  --sidebar-w: 240px; --r: 10px; --rs: 6px; --rl: 14px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--navy-deep); color: var(--text); height: 100vh; overflow: hidden; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: var(--text); }
input { font-family: inherit; border: none; outline: none; background: none; color: var(--text); }
.app { display: flex; height: 100vh; }

/* ── Sidebar ── */
.sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--navy); display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.sb-brand { padding: 20px 20px 16px; }
.sb-brand h1 { font-size: 16px; font-weight: 700; color: #fff; }
.sb-brand .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.sb-nav { padding: 8px 10px; flex: 1; overflow-y: auto; }
.sb-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); padding: 14px 10px 6px; font-weight: 600; }
.sb-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--rs); font-size: 13.5px; font-weight: 450; color: var(--text-sec); transition: all 0.15s; width: 100%; text-align: left; margin-bottom: 1px; }
.sb-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sb-item.active { background: var(--blue); color: #fff; }
.sb-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sb-src { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12.5px; color: var(--text-muted); }
.sb-dot { width: 7px; height: 7px; border-radius: 50%; }
.sb-dot.on { background: var(--teal-light); } .sb-dot.wait { background: var(--amber); } .sb-dot.off { background: var(--text-muted); opacity: 0.35; }
.sb-user { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sb-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
.sb-uname { font-size: 13px; font-weight: 500; } .sb-urole { font-size: 11px; color: var(--text-muted); }

/* ── Main ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 50px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0; }
.topbar-title { font-size: 14px; font-weight: 600; }
.topbar-stats { font-size: 12.5px; color: var(--text-muted); }
.topbar-stats b { color: var(--text); font-weight: 600; }
.topbar-user { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-mid); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--blue-light); }

/* ── Chat ── */
.chat-area { flex: 1; overflow-y: auto; padding: 24px 24px 16px; display: flex; flex-direction: column; }
.chat-messages { flex: 1; max-width: 820px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.welcome { text-align: center; padding: 60px 20px 30px; animation: fadeUp 0.4s ease; }
.welcome h2 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.welcome p { font-size: 14px; color: var(--text-sec); max-width: 500px; margin: 0 auto 20px; line-height: 1.6; }
.welcome-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wchip { padding: 8px 16px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 20px; font-size: 13px; color: var(--blue-light); transition: all 0.15s; }
.wchip:hover { border-color: var(--blue); background: rgba(55,138,221,0.08); }

/* Messages */
.msg { display: flex; gap: 12px; animation: fadeUp 0.3s ease; }
.msg.user { justify-content: flex-end; }
.msg.user .msg-content { background: var(--blue); color: #fff; border-radius: var(--rl) var(--rl) 4px var(--rl); padding: 12px 18px; max-width: 600px; font-size: 14px; line-height: 1.6; }
.msg.ai { align-items: flex-start; }
.msg-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.msg.ai .msg-avatar { background: var(--teal); color: #fff; }
.msg.ai .msg-body { max-width: 720px; flex: 1; }
.msg-text { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 4px var(--rl) var(--rl) var(--rl); padding: 14px 18px; font-size: 14px; line-height: 1.7; }
.msg-text strong { color: #fff; }

/* Alert */
.chat-alert { background: rgba(232,163,23,0.08); border: 1px solid rgba(232,163,23,0.25); border-radius: var(--rs); padding: 10px 14px; margin-top: 10px; font-size: 13px; color: var(--amber); display: flex; align-items: center; gap: 8px; }
.chat-alert-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex-shrink: 0; }

/* ── Startup Cards ── */
.chat-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.scard { background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; transition: border-color 0.15s; cursor: pointer; }
.scard:hover { border-color: rgba(55,138,221,0.3); }
.scard-main { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; }
.scard-avatar { width: 42px; height: 42px; border-radius: var(--rs); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0; }
.scard-body { flex: 1; min-width: 0; }
.scard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.scard-name { font-size: 14px; font-weight: 600; }
.scard-expand { color: var(--text-muted); font-size: 11px; display: flex; align-items: center; gap: 4px; transition: color 0.15s; }
.scard:hover .scard-expand { color: var(--blue-light); }
.scard-expand svg { width: 14px; height: 14px; transition: transform 0.2s; }
.scard.open .scard-expand svg { transform: rotate(180deg); }
.scard-tags { display: flex; gap: 5px; flex-shrink: 0; }
.scard-tag { padding: 2px 8px; border-radius: 3px; font-size: 10.5px; font-weight: 600; border: 1px solid; }
.scard-tag.teal { background: rgba(29,158,117,0.1); color: var(--teal-light); border-color: rgba(29,158,117,0.25); }
.scard-tag.blue { background: rgba(55,138,221,0.1); color: var(--blue-light); border-color: rgba(55,138,221,0.2); }
.scard-tag.purple { background: rgba(139,92,246,0.1); color: #A78BFA; border-color: rgba(139,92,246,0.2); }
.scard-tag.gray { background: rgba(255,255,255,0.04); color: var(--text-sec); border-color: var(--border); }
.scard-tagline { font-size: 12.5px; color: var(--text-sec); line-height: 1.5; margin-bottom: 6px; }
.scard-meta { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.scard-meta span { display: flex; align-items: center; gap: 4px; }
.scard-highlight { margin-top: 8px; padding: 8px 12px; background: rgba(55,138,221,0.05); border-left: 2px solid var(--blue); border-radius: 0 var(--rs) var(--rs) 0; font-size: 12.5px; color: var(--text-sec); line-height: 1.5; }

/* ── Detail Panel ── */
.scard-detail { display: none; border-top: 1px solid var(--border); padding: 0; max-height: 0; overflow: hidden; transition: max-height 0.3s ease, padding 0.3s ease; }
.scard.open .scard-detail { display: block; max-height: 2000px; padding: 16px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.detail-section { margin-bottom: 0; }
.detail-section.full { grid-column: 1 / -1; }
.detail-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.detail-value { font-size: 13px; line-height: 1.6; color: var(--text-sec); }
.detail-value a { color: var(--blue-light); text-decoration: none; word-break: break-all; }
.detail-value a:hover { text-decoration: underline; }

.detail-divider { grid-column: 1 / -1; height: 1px; background: var(--border); margin: 4px 0; }

.detail-text-block { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--rs); padding: 10px 12px; font-size: 12.5px; line-height: 1.65; color: var(--text-sec); max-height: 120px; overflow-y: auto; }
.detail-text-block::-webkit-scrollbar { width: 4px; }
.detail-text-block::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.detail-contact { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--rs); padding: 10px 14px; }
.detail-contact-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--navy-mid); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--blue-light); flex-shrink: 0; }
.detail-contact-info { font-size: 13px; }
.detail-contact-info .dc-name { font-weight: 600; color: var(--text); }
.detail-contact-info .dc-title { font-size: 12px; color: var(--text-muted); }
.detail-contact-info .dc-email { font-size: 12px; color: var(--blue-light); }

.detail-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.detail-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--rs); font-size: 12px; color: var(--blue-light);
  text-decoration: none; transition: all 0.15s;
}
.detail-link:hover { border-color: var(--blue); background: rgba(55,138,221,0.06); }
.detail-link svg { width: 13px; height: 13px; }

/* Follow-up */
.follow-up { margin-top: 10px; }
.follow-btn { padding: 7px 14px; background: var(--surface-card); border: 1px solid var(--border); border-radius: 20px; font-size: 12.5px; color: var(--blue-light); transition: all 0.15s; }
.follow-btn:hover { border-color: var(--blue); background: rgba(55,138,221,0.08); }

/* Typing */
.typing { display: flex; gap: 12px; align-items: flex-start; animation: fadeUp 0.3s ease; }
.typing .msg-avatar { background: var(--teal); color: #fff; }
.typing-dots { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 4px var(--rl) var(--rl) var(--rl); padding: 14px 20px; display: flex; gap: 5px; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: bounce 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* Input bar */
.input-bar { padding: 12px 24px 16px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.input-box { max-width: 820px; margin: 0 auto; display: flex; align-items: center; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--rl); overflow: hidden; transition: border-color 0.2s; }
.input-box:focus-within { border-color: var(--blue); }
.input-box input { flex: 1; padding: 13px 18px; font-size: 14.5px; }
.input-box input::placeholder { color: var(--text-muted); }
.send-btn { background: var(--blue); color: #fff; margin: 5px; padding: 9px 18px; border-radius: var(--r); font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; transition: background 0.15s; }
.send-btn:hover { background: var(--blue-light); }
.send-btn:disabled { opacity: 0.35; pointer-events: none; }
.send-btn svg { width: 16px; height: 16px; }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* Scrollbar */
.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .chat-area { padding: 16px; }
  .input-bar { padding: 10px 12px 14px; }
  .scard-tags { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
}
