/* ═══════════════════════════════════════════════
   IPeritus V5 — chat.css
   Shared styles for all Centurion One chat pages
   ═══════════════════════════════════════════════ */

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

:root {
  --blue:      #1e5c7f;
  --blue-dk:   #124460;
  --blue-lt:   #2e7aaa;
  --blue-pale: #eef4f8;
  --red:       #e82020;
  --ink:       #0c0c0a;
  --ink-mid:   #3a3830;
  --ink-dim:   #7a7670;
  --ink-faint: #c2bdb5;
  --paper:     #fafaf8;
  --cream:     #f2efe9;
  --rule:      rgba(12,12,10,.09);
  --rule-b:    rgba(30,92,127,.16);
  --green:     #287a4f;
  --amber:     #b86a00;
  --fs:        "Libre Baskerville", serif;
  --fss:       "Libre Franklin", sans-serif;
  --fm:        "DM Mono", monospace;

  /* Chat-specific */
  --chat-bg:      #0d1117;
  --chat-surface: #161b22;
  --chat-border:  rgba(48,54,61,0.8);
  --chat-text:    #e6edf3;
  --chat-dim:     #8b949e;
  --chat-blue:    #58a6ff;
  --chat-accent:  #1e5c7f;
}

html { height: 100%; }
body {
  height: 100%; background: var(--chat-bg);
  color: var(--chat-text); font-family: var(--fss);
  font-weight: 400; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────── */
.chat-layout { display: flex; flex-direction: column; height: 100vh; }

/* ── Chat Header ─────────────────────────────── */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--chat-surface);
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0; z-index: 100;
}
.chat-header-left { display: flex; align-items: center; gap: 16px; }
.chat-logo { height: 28px; filter: brightness(0) invert(1); opacity: .85; }
.chat-divider { width: 1px; height: 20px; background: var(--chat-border); }
.chat-product-name { font-family: var(--fm); font-size: 10px; font-weight: 300; letter-spacing: .28em; text-transform: uppercase; color: var(--chat-blue); }
.chat-product-tag  { font-family: var(--fm); font-size: 9px; font-weight: 300; letter-spacing: .2em; text-transform: uppercase; color: var(--chat-dim); margin-top: 2px; }

.chat-header-right { display: flex; align-items: center; gap: 12px; }
.chat-status { display: flex; align-items: center; gap: 6px; font-family: var(--fm); font-size: 9px; font-weight: 300; letter-spacing: .2em; text-transform: uppercase; color: var(--green); }
.chat-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse-g 2.5s ease infinite; }
@keyframes pulse-g { 0%,100%{opacity:1} 50%{opacity:.35} }

.back-link {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase;
  color: var(--chat-dim); text-decoration: none; padding: 7px 14px;
  border: 1px solid var(--chat-border);
  transition: color .25s, border-color .25s;
}
.back-link:hover { color: var(--chat-text); border-color: rgba(88,166,255,.4); }
.back-link svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Body: sidebar + main ────────────────────── */
.chat-body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────── */
.chat-sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--chat-surface);
  border-right: 1px solid var(--chat-border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar-section { padding: 20px 18px 0; }
.sidebar-section:last-child { padding-bottom: 20px; }

.sidebar-label {
  font-family: var(--fm); font-size: 8.5px; font-weight: 400;
  letter-spacing: .24em; text-transform: uppercase; color: var(--chat-dim);
  margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.sidebar-label::after { content: ""; flex: 1; height: 1px; background: var(--chat-border); }
.sidebar-rule { height: 1px; background: var(--chat-border); margin: 16px 18px; }

.prompt-chip {
  display: block; width: 100%;
  padding: 9px 12px; margin-bottom: 5px;
  background: transparent; border: 1px solid var(--chat-border);
  color: var(--chat-dim); font-size: 11.5px; font-weight: 400;
  font-family: var(--fss); cursor: pointer; text-align: left;
  transition: background .2s, border-color .2s, color .2s;
  line-height: 1.45;
}
.prompt-chip:last-child { margin-bottom: 0; }
.prompt-chip:hover { background: rgba(30,92,127,.2); border-color: var(--chat-blue); color: var(--chat-text); }

.sidebar-products { padding: 0 18px 20px; }
.sidebar-prod-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; margin-bottom: 5px;
  border: 1px solid var(--chat-border); text-decoration: none;
  color: var(--chat-dim); font-size: 10.5px; font-weight: 400;
  transition: background .2s, border-color .2s, color .2s;
}
.sidebar-prod-link:hover { background: rgba(30,92,127,.2); border-color: rgba(88,166,255,.4); color: var(--chat-text); }
.sidebar-prod-link.current { border-color: var(--chat-blue); color: var(--chat-blue); background: rgba(88,166,255,.08); }
.spl-name { font-weight: 500; }
.spl-status { font-family: var(--fm); font-size: 8px; letter-spacing: .15em; text-transform: uppercase; }
.spl-status.live { color: var(--green); }
.spl-status.soon { color: var(--amber); }

/* ── Chat Main Area ──────────────────────────── */
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 28px 40px;
  display: flex; flex-direction: column; gap: 24px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 2px; }

/* Welcome state */
.chat-welcome { max-width: 640px; margin: auto; text-align: center; padding: 40px 0; }
.welcome-eyebrow { font-family: var(--fm); font-size: 9.5px; font-weight: 300; letter-spacing: .3em; text-transform: uppercase; color: var(--chat-blue); margin-bottom: 16px; display: block; }
.welcome-title   { font-family: var(--fs); font-size: clamp(26px, 3vw, 40px); font-weight: 700; line-height: 1.1; letter-spacing: -.02em; color: var(--chat-text); margin-bottom: 14px; }
.welcome-title em { font-style: italic; color: var(--chat-blue); }
.welcome-body { font-size: 14.5px; font-weight: 300; line-height: 1.75; color: var(--chat-dim); max-width: 480px; margin: 0 auto 32px; }
.welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.wchip {
  padding: 9px 16px; background: transparent;
  border: 1px solid var(--chat-border); color: var(--chat-dim);
  font-size: 12px; font-weight: 400; font-family: var(--fss);
  cursor: pointer; transition: background .2s, border-color .2s, color .2s;
}
.wchip:hover { background: rgba(30,92,127,.25); border-color: var(--chat-blue); color: var(--chat-text); }

/* Message bubbles */
.message { display: flex; gap: 14px; max-width: 720px; }
.message.user { flex-direction: row-reverse; align-self: flex-end; }
.message.assistant { align-self: flex-start; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fm); font-size: 10px; font-weight: 400;
  letter-spacing: .1em;
}
.message.user      .msg-avatar { background: var(--blue-dk); color: rgba(238,244,248,.8); }
.message.assistant .msg-avatar { background: rgba(30,92,127,.3); color: var(--chat-blue); border: 1px solid var(--chat-border); }

.msg-bubble {
  padding: 13px 16px; max-width: 540px;
  font-size: 13.5px; font-weight: 300; line-height: 1.72;
}
.message.user      .msg-bubble { background: rgba(30,92,127,.25); color: var(--chat-text); border: 1px solid rgba(30,92,127,.4); }
.message.assistant .msg-bubble { background: var(--chat-surface); color: var(--chat-text); border: 1px solid var(--chat-border); }
.msg-bubble strong { font-weight: 600; color: var(--chat-text); }
.msg-bubble em     { font-style: italic; color: var(--chat-blue); }

.msg-meta { font-family: var(--fm); font-size: 8.5px; font-weight: 300; letter-spacing: .12em; color: var(--chat-dim); margin-top: 5px; }
.message.user      .msg-meta { text-align: right; }
.message.assistant .msg-meta { text-align: left; }

/* Typing indicator */
.typing-indicator { display: flex; gap: 5px; align-items: center; padding: 13px 16px; background: var(--chat-surface); border: 1px solid var(--chat-border); width: fit-content; }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--chat-dim); animation: typing-bounce 1.4s ease infinite; }
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

/* Deep-link card inside response */
.response-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; margin-top: 12px;
  border: 1px solid var(--chat-border); text-decoration: none;
  background: rgba(30,92,127,.1);
  transition: background .2s, border-color .2s;
}
.response-card:hover { background: rgba(30,92,127,.25); border-color: rgba(88,166,255,.4); }
.rc-label { font-family: var(--fm); font-size: 8px; font-weight: 300; letter-spacing: .2em; text-transform: uppercase; color: var(--chat-blue); margin-bottom: 3px; }
.rc-title { font-size: 12.5px; font-weight: 500; color: var(--chat-text); }
.rc-arrow { width: 26px; height: 26px; border: 1px solid var(--chat-border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rc-arrow svg { width: 10px; height: 10px; stroke: var(--chat-blue); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Input Area ──────────────────────────────── */
.chat-input-area {
  padding: 16px 40px 22px;
  background: var(--chat-bg);
  border-top: 1px solid var(--chat-border);
  flex-shrink: 0;
}
.chat-input-wrap {
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--chat-surface); border: 1px solid var(--chat-border);
  padding: 10px 14px; transition: border-color .25s;
}
.chat-input-wrap:focus-within { border-color: var(--chat-blue); }
.chat-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--chat-text); font-size: 13.5px; font-weight: 300;
  font-family: var(--fss); resize: none; min-height: 22px; max-height: 120px;
  line-height: 1.55;
}
.chat-input::placeholder { color: var(--chat-dim); }
.chat-send-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--blue); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; transition: background .25s;
}
.chat-send-btn:hover { background: var(--blue-lt); }
.chat-send-btn:disabled { background: var(--chat-border); cursor: default; }
.chat-send-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-input-note { font-family: var(--fm); font-size: 8.5px; font-weight: 300; letter-spacing: .15em; color: var(--chat-dim); margin-top: 8px; text-align: center; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .chat-sidebar    { display: none; }
  .chat-messages   { padding: 20px; }
  .chat-input-area { padding: 12px 20px 18px; }
  .chat-header     { padding: 12px 20px; }
}
