/* ============================================================
   KYT Chat — index.css  (dark/light aware)
   ============================================================ */

body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.layout { display: flex; flex: 1; overflow: hidden; }

/* ── Header extras ───────────────────────────────────────────── */
.header-right { display: flex; align-items: center; gap: 10px; }

.live-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.9);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #a5d6a7; box-shadow: 0 0 0 2px rgba(165,214,167,0.3);
  animation: blink 2s ease-in-out infinite;
}
.source-count {
  font-family: var(--mono); font-size: 11px;
  color: rgba(255,255,255,0.75); background: rgba(255,255,255,0.1);
  padding: 3px 10px; border-radius: 12px;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-section { padding: 16px 12px 8px; flex-shrink: 0; }
.sidebar-label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-sec); margin-bottom: 6px;
}
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 8px 12px; }

.faq-btn {
  display: block; width: 100%; background: transparent; border: none;
  color: var(--text-sec); font-family: var(--sans); font-size: 13px;
  padding: 8px 10px; border-radius: var(--radius); cursor: pointer;
  text-align: left; transition: background 0.15s, color 0.15s;
  line-height: 1.4; margin-bottom: 2px;
}
.faq-btn:hover { background: var(--primary-lt); color: var(--primary); }

.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; flex-shrink: 0; }

.source-tag {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-sec);
  padding: 6px 8px; border-radius: var(--radius); margin-bottom: 2px;
}
.source-pip { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Chat area ───────────────────────────────────────────────── */
.chat-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--bg); }

.messages {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ── Welcome ─────────────────────────────────────────────────── */
.welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 16px; padding: 40px 20px;
  animation: fadeUp 0.4s ease;
}
.welcome-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--appbar); /* uses the appbar colour which is always blue */
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  box-shadow: 0 4px 20px rgba(21,101,192,0.4);
}
.welcome h2 { font-size: 24px; font-weight: 400; }
.welcome h2 em { font-style: normal; font-weight: 500; color: var(--primary); }
.welcome p  { font-size: 14px; color: var(--text-sec); max-width: 380px; line-height: 1.7; }

/* ── Messages ────────────────────────────────────────────────── */
.msg { display: flex; gap: 10px; animation: fadeUp 0.2s ease; }
.msg.user      { flex-direction: row-reverse; align-self: flex-end; max-width: 70%; }
.msg.assistant { align-self: flex-start; max-width: 76%; flex-direction: column; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500; align-self: flex-end;
  background: var(--surface2); color: var(--text-sec); border: 1px solid var(--border);
}

.msg-body { display: flex; gap: 10px; }
.msg.assistant .msg-body { flex-direction: row; align-items: flex-start; }

.msg-assistant-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--appbar);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; margin-top: 2px;
}

.bubble { padding: 10px 14px; font-size: 13px; line-height: 1.65; border-radius: var(--radius-xl); }

.msg.user .bubble {
  background: var(--appbar); color: #fff;
  border-bottom-right-radius: var(--radius);
}
.msg.assistant .bubble {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-bottom-left-radius: var(--radius);
  box-shadow: var(--shadow-1); flex: 1;
}
.msg.assistant .bubble strong { color: var(--primary); font-weight: 500; }

/* Confidence chip */
.confidence-badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: 10px; margin-left: 8px; vertical-align: middle;
}
.conf-high   { background: rgba(165,214,167,0.15); color: var(--success); }
.conf-medium { background: rgba(255,204,128,0.15); color: var(--warning); }
.conf-low    { background: rgba(239,154,154,0.15); color: var(--error); }

html.light .conf-high   { background: #e8f5e9; color: #2e7d32; }
html.light .conf-medium { background: #fff8e1; color: #e65100; }
html.light .conf-low    { background: #fce4ec; color: #c62828; }

/* ── Source cards in chat ────────────────────────────────────── */
.sources-row    { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; margin-left: 42px; }
.sources-header { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-sec); }
.source-cards   { display: flex; flex-direction: column; gap: 8px; }

/* Constrain card width in chat so they don't stretch edge to edge */
.source-cards .source-card { max-width: 400px; font-size: 12px; }

/* Actions row at bottom of each card */
.card-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px;
}

/* Go to source button */
.source-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  color: var(--primary); background: var(--primary-lt);
  border: 1px solid rgba(144,202,249,0.25);
  border-radius: 6px; padding: 4px 10px;
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.source-btn:hover { background: rgba(144,202,249,0.2); border-color: var(--primary); }
.source-btn svg   { flex-shrink: 0; }
html.light .source-btn {
  color: var(--primary); background: #e3f2fd;
  border-color: rgba(25,118,210,0.2);
}
html.light .source-btn:hover { background: #bbdefb; border-color: var(--primary); }

/* Image wrapper in cards */
.card-img-wrap {
  margin-bottom: 8px; border-radius: var(--radius);
  overflow: hidden; max-height: 160px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
}
.card-img-wrap img {
  max-width: 100%; max-height: 160px; object-fit: contain; display: block;
}

.pdf-page-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; color: var(--error);
  background: rgba(239,154,154,0.15); padding: 2px 8px; border-radius: 10px; margin-right: 8px;
}
html.light .pdf-page-badge { background: #fce4ec; color: #c62828; }

.video-embed-wrapper {
  width: 100%;
  border-radius: var(--radius); overflow: hidden; margin-bottom: 8px;
}
/* iframe (Drive) — aspect-ratio box */
.video-embed-wrapper iframe {
  display: block; width: 100%; aspect-ratio: 16/9; border: none;
}
/* native <video> — no black gap, compact height */
.video-embed-wrapper video {
  display: block; width: 100%; max-height: 180px;
  object-fit: cover; border-radius: var(--radius);
}

.video-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.timestamp-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; color: var(--success);
  background: rgba(165,214,167,0.15); padding: 2px 8px; border-radius: 10px;
}
html.light .timestamp-chip { background: #e8f5e9; color: #2e7d32; }

.transcript-snippet {
  font-family: var(--mono); font-size: 11px; color: var(--text-sec);
  line-height: 1.6; margin-top: 10px; padding: 8px 12px;
  background: var(--surface2); border-left: 3px solid var(--border2);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.extra-toggle {
  background: transparent; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 12px;
  font-size: 12px; font-weight: 500; padding: 4px 12px; cursor: pointer;
  transition: background 0.15s;
}
.extra-toggle:hover { background: var(--primary-lt); }

/* ── Typing indicator ────────────────────────────────────────── */
.typing {
  display: flex; gap: 5px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); border-bottom-left-radius: var(--radius);
  width: fit-content; box-shadow: var(--shadow-1);
}
.t-dot { width: 6px; height: 6px; background: var(--text-dis); border-radius: 50%; animation: bounce 1.1s infinite; }
.t-dot:nth-child(2) { animation-delay: 0.18s; }
.t-dot:nth-child(3) { animation-delay: 0.36s; }

/* ── Input bar ───────────────────────────────────────────────── */
.input-bar {
  border-top: 1px solid var(--border); padding: 12px 20px 14px;
  background: var(--surface); flex-shrink: 0;
}
.input-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 24px; padding: 4px 4px 4px 18px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(144,202,249,0.15);
}
html.light .input-row:focus-within { box-shadow: 0 0 0 2px rgba(25,118,210,0.12); }

.input-row input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--sans); font-size: 14px; padding: 8px 0;
}
.input-row input::placeholder { color: var(--text-dis); }

.send-btn {
  background: var(--appbar); border: none; border-radius: 50%;
  width: 38px; height: 38px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s; box-shadow: var(--shadow-1);
}
.send-btn:hover:not(:disabled) { background: #1976d2; }
.send-btn:disabled { background: var(--border2); box-shadow: none; cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; fill: white; }

.input-hint { font-size: 10px; color: var(--text-dis); text-align: center; margin-top: 6px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .sidebar { display: none; }
  .messages { padding: 16px 12px; }
  .msg.user, .msg.assistant { max-width: 95%; }
}
