/* ===========================================================
   Hesiodex — Chat Interface Styles
   Centered chat area with welcome state, messages, input bar
   =========================================================== */

/* ── Chat container ── */
.chat-container {
  display: flex; flex-direction: column;
  height: 100%;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

/* ── Messages area ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Welcome state ── */
.chat-welcome {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  flex: 1;
  padding: 60px 20px;
}
.welcome-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
  font-size: 1.6rem; font-weight: 700; color: #fff;
}
.chat-welcome h2 {
  font-size: 1.5rem; font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.chat-welcome p {
  color: var(--text-dim); font-size: 0.92rem;
  max-width: 440px; margin-bottom: 28px;
}
.welcome-chips {
  display: flex; flex-wrap: wrap;
  justify-content: center; gap: 8px;
  max-width: 560px;
}
.welcome-chips button {
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim); font-size: 0.84rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.welcome-chips button:hover {
  background: var(--surface2);
  border-color: var(--border-h);
  color: var(--text);
}

/* ── Message wrapper ── */
.chat-msg-wrapper {
  display: flex; flex-direction: column;
  padding: 4px 0;
}
.chat-msg-wrapper.user { align-items: flex-end; }
.chat-msg-wrapper.assistant { align-items: flex-start; }

/* ── Individual message ── */
.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
}
.chat-msg.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.chat-msg.assistant {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

/* ── Markdown in assistant messages ── */
.chat-msg.assistant strong { color: var(--accent-h); }
.chat-msg.assistant ul, .chat-msg.assistant ol {
  margin: 6px 0 6px 18px; padding: 0;
}
.chat-msg.assistant li { margin-bottom: 3px; }
.chat-msg.assistant p { margin: 0 0 8px 0; }
.chat-msg.assistant p:last-child { margin-bottom: 0; }

/* ── SOP citation chips ── */
.chat-msg .sop-cite {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem; font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  cursor: pointer; text-decoration: none;
  margin: 0 2px;
  transition: opacity 0.12s;
}
.chat-msg .sop-cite:hover { opacity: 0.8; }

/* ── Typing indicator ── */
.chat-typing {
  display: flex; gap: 5px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 6px;
}
.chat-typing .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: chatDot 1.2s ease-in-out infinite;
}
.chat-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ── */
.chat-input-area {
  padding: 0 24px 20px;
  flex-shrink: 0;
}
.chat-input-wrap {
  display: flex; align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 4px 4px 16px;
  transition: border-color 0.15s;
}
.chat-input-wrap:focus-within {
  border-color: var(--accent);
}
.chat-input-wrap textarea {
  flex: 1;
  background: none; border: none;
  color: var(--text);
  font-size: 0.92rem;
  font-family: var(--font);
  line-height: 1.5;
  padding: 10px 0;
  resize: none;
  max-height: 160px;
  overflow-y: auto;
}
.chat-input-wrap textarea:focus { outline: none; }
.chat-input-wrap textarea::placeholder { color: var(--text-faint); }
.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--accent); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}
.chat-send-btn:hover { background: var(--accent-h); }
.chat-send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.chat-send-btn svg { width: 18px; height: 18px; }

.chat-hint {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.72rem;
  margin-top: 8px;
}

/* ── Flag an Issue ── */
.chat-flag-btn {
  background: none; border: none;
  color: var(--text-faint); font-size: 0.72rem;
  cursor: pointer; padding: 4px 2px 0;
  opacity: 0; transition: opacity 0.15s;
}
.chat-msg-wrapper:hover .chat-flag-btn { opacity: 1; }
.chat-flag-btn:hover { color: var(--accent); }

.chat-flag-form {
  margin-top: 8px; padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.chat-flag-input {
  width: 100%; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-size: 0.84rem; font-family: var(--font);
  resize: vertical; box-sizing: border-box;
}
.chat-flag-input:focus { outline: none; border-color: var(--accent); }
.chat-flag-input::placeholder { color: var(--text-faint); }
.chat-flag-actions { display: flex; gap: 8px; margin-top: 8px; }
.chat-flag-submit, .chat-flag-cancel {
  padding: 6px 14px; border-radius: 8px;
  border: none; font-size: 0.78rem;
  cursor: pointer; font-family: var(--font);
}
.chat-flag-submit { background: var(--accent); color: #fff; }
.chat-flag-submit:hover { background: var(--accent-h); }
.chat-flag-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-flag-cancel { background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }
.chat-flag-cancel:hover { color: var(--text); }
.chat-flag-thanks { color: var(--success); font-size: 0.82rem; padding: 4px 0; }
