/* ── Chat Assistant ───────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.chat-message {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: var(--shadow);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-message.ai {
  align-self: flex-start;
  background: var(--bg4);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: #000;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

.chat-input-area {
  padding: 16px;
  background: var(--bg3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chat-suggestions::-webkit-scrollbar {
  height: 0;
}

.suggest-chip {
  background: var(--bg4);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: all .2s;
}

.suggest-chip:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212, 175, 55, 0.05);
}

.input-row {
  display: flex;
  gap: 12px;
}

#chatInput {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border .2s;
  font-family: var(--font);
}

#chatInput:focus {
  border-color: var(--gold);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #000;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 24px;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
}

.btn-primary:hover {
  opacity: .9;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* ── Analytical Response Styles ────────────────────────────────── */

/* Override pre-wrap for AI messages that render HTML */
.chat-message.ai {
  white-space: normal;
}

.chat-analytical {
  line-height: 1.65;
  font-size: 13.5px;
}

.chat-analytical p {
  margin: 0 0 10px;
}

.chat-section-head {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(212,175,55,0.2);
}

.chat-section-head:first-child {
  margin-top: 0;
}

.chat-section-subhead {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin: 12px 0 6px;
}

.chat-bullets {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chat-bullets li {
  padding-left: 16px;
  position: relative;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.chat-bullets li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--gold);
  font-size: 11px;
  top: 2px;
}

/* Flags used badge */
.chat-flags-used {
  margin-top: 12px;
  padding: 6px 12px;
  background: rgba(212,175,55,0.06);
  border: 1px solid rgba(212,175,55,0.15);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chat-flags-used code {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10.5px;
  color: var(--gold);
  font-family: monospace;
}

/* Data tables below AI response */
.chat-data-table {
  max-width: 100%;
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.chat-data-label {
  background: var(--bg3);
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

/* Error */
.chat-error {
  color: #ff6b6b;
  font-size: 13px;
}

/* Inline Charts */
.chat-chart-container {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.chat-chart-container canvas {
  max-width: 100% !important;
  height: auto !important;
}
