/* ================================================
   Main Content & Chat
   ================================================ */

/* Main Content Wrapper */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* ── Header ── */
.app-header {
  height: var(--header-h);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--gold-border);
  flex-shrink: 0;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.header-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, rgba(201,168,76,0.1), rgba(201,168,76,0.05));
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.header-icon svg { width: 26px; height: 26px; stroke: var(--gold); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.header-text h1 {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.06em;
  line-height: 1.2;
}
.header-text p {
  font-size: 12px;
  color: var(--text-gold);
  font-weight: 400;
  letter-spacing: 0.02em;
}
.header-actions { display: flex; align-items: center; gap: 10px; }

/* ── Content Area ── */
.content-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Chat Panel ── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: row; /* Horizontal splitting: history list + chat area */
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--gold-border);
  background: var(--bg-primary);
  position: relative;
}

/* Chat History Drawer */
.chat-history-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--gold-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  transition: var(--transition);
}
.chat-history-header {
  padding: 16px 20px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-size: 13px;
  border: 1px solid transparent;
  gap: 6px;
}
.chat-history-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: rgba(201,168,76,0.1);
}
.chat-history-item.active {
  background: var(--gold-glow);
  color: var(--gold);
  border-color: var(--gold-border);
  font-weight: 600;
}
.chat-history-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-history-del {
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--text-muted);
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.chat-history-item:hover .chat-history-del { opacity: 1; }
.chat-history-del:hover { background: rgba(220,60,60,0.15); color: #e07070; }

/* Main Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Message Bubble ── */
.message {
  display: flex;
  gap: 12px;
  animation: fadeInUp 0.3s ease forwards;
  max-width: 88%;
}
.message.bot { align-self: flex-start; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.message.bot .message-avatar {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: #0e0e0e;
  box-shadow: 0 2px 10px rgba(201,168,76,0.3);
}
.message.user .message-avatar {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  color: var(--text-secondary);
}

.message-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.message-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.message.user .message-name { text-align: right; color: var(--text-secondary); }

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}
.message.bot .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  color: var(--text-primary);
  border-top-left-radius: 4px;
}
.message.user .message-bubble {
  background: linear-gradient(135deg, #1d1a10, #252010);
  border: 1px solid var(--gold-border-hv);
  color: var(--text-primary);
  border-top-right-radius: 4px;
}

/* Markdown in bot messages */
.message-bubble strong { color: var(--gold-light); font-weight: 600; }
.message-bubble code {
  background: rgba(201,168,76,0.1);
  border: 1px solid var(--gold-border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--gold-light);
}
.message-bubble pre {
  background: var(--bg-secondary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12px;
}
.message-bubble ul, .message-bubble ol { padding-left: 20px; margin: 4px 0; }
.message-bubble li { margin: 3px 0; }
.message-bubble p { margin: 4px 0; }
.message-bubble h1, .message-bubble h2, .message-bubble h3 { color: var(--gold-light); margin: 8px 0 4px; }
.message-bubble hr { border-color: var(--gold-border); margin: 10px 0; }

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.message.user .message-meta { flex-direction: row-reverse; }
.msg-check { color: var(--gold-dim); font-size: 12px; }
.export-pdf-btn {
  background: none;
  border: none;
  color: var(--gold-dim);
  cursor: pointer;
  font-size: 10.5px;
  font-family: inherit;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.export-pdf-btn:hover {
  color: var(--gold);
  background: var(--gold-glow);
  border-color: var(--gold-border);
}
.export-pdf-btn:active {
  transform: scale(0.95);
}

/* Attached file tag in message */
.message-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(201,168,76,0.08);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 6px;
}

/* ── Typing Indicator ── */
.typing-indicator {
  display: flex;
  gap: 12px;
  align-self: flex-start;
  animation: fadeIn 0.3s ease;
}
.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  border-top-left-radius: 4px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--gold);
  border-radius: 50%;
  animation: typing-dot 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ── New Conversation Button ── */
.btn-new-conversation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 24px 12px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-lg);
  transition: var(--transition);
  font-family: inherit;
}
.btn-new-conversation:hover {
  background: var(--gold-glow);
  border-color: var(--gold-border-hv);
  transform: translateY(-1px);
}

/* ── Input Area ── */
.input-area {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--gold-border);
  align-items: flex-end;
}

/* Upload Zone */
.upload-zone {
  width: 140px;
  min-width: 140px;
  min-height: 90px;
  border: 1.5px dashed var(--gold-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-input);
  padding: 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--gold);
  background: var(--gold-glow);
}
.upload-zone svg { width: 26px; height: 26px; stroke: var(--gold); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.upload-zone .upload-label { font-size: 11.5px; font-weight: 600; color: var(--gold); }
.upload-zone .upload-hint { font-size: 9.5px; color: var(--text-muted); line-height: 1.3; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-zone.has-file { border-color: var(--gold); background: rgba(201,168,76,0.06); }
.upload-file-name { font-size: 9px; color: var(--gold-light); margin-top: 2px; word-break: break-all; max-width: 120px; }

/* Text Input Wrapper */
.input-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.input-field-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#messageInput {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  padding: 12px 16px;
  resize: none;
  min-height: 48px;
  max-height: 140px;
  outline: none;
  transition: var(--transition);
  line-height: 1.5;
}
#messageInput:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
#messageInput::placeholder { color: var(--text-muted); }

.input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Send Button */
.btn-send {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #0e0e0e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(201,168,76,0.3);
}
.btn-send:hover {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 6px 20px rgba(201,168,76,0.4);
}
.btn-send:active { transform: scale(0.97); }
.btn-send svg { width: 18px; height: 18px; stroke: #0e0e0e; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn-send.loading { animation: goldPulse 1.2s infinite; cursor: wait; }

/* Disclaimer */
.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 20px 10px;
  background: var(--bg-secondary);
}

/* Voice Recording State */
.btn-icon.recording {
  color: #e05050;
  border-color: rgba(224,80,80,0.5);
  background: rgba(224,80,80,0.1);
  animation: goldPulse 1s infinite;
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  text-align: center;
}
.empty-state svg { width: 56px; height: 56px; stroke: var(--gold-dim); fill: none; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.empty-state p { font-size: 13px; color: var(--text-muted); max-width: 320px; line-height: 1.6; }

/* Suggestion chips */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.chip {
  padding: 7px 14px;
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--gold);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.chip:hover { background: var(--gold-glow); border-color: var(--gold-border-hv); transform: translateY(-1px); }
