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

:root {
  --primary: #c9a96e;
  --primary-dark: #a8894e;
  --secondary: #d4af37;
  --bg-dark: #0e0e12;
  --bg-sidebar: #141418;
  --bg-chat: #1a1a1e;
  --bg-input: #242428;
  --bg-hover: #222226;
  --text-primary: #f5f0e8;
  --text-secondary: #9a9590;
  --text-muted: #6b655f;
  --border-color: rgba(201, 169, 110, 0.2);
  --border-gold: rgba(201, 169, 110, 0.25);
  --user-msg-bg: #2a2520;
  --bot-msg-bg: transparent;
}

html, body { height: 100%; }

body {
  font-family: "Cormorant Garamond", "Georgia", serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.7;
  overflow: hidden;
}

.app-container { display: flex; height: 100vh; }

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  text-decoration: none;
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg { stroke: var(--primary); }

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 2px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: "Cinzel", serif;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}

.new-chat-btn:hover { background: var(--bg-hover); border-color: var(--primary); }

.sidebar-content { flex: 1; overflow-y: auto; padding: 12px 8px; }
.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.chat-history { display: flex; flex-direction: column; gap: 8px; }
.history-section { margin-bottom: 8px; }

.history-label {
  display: block;
  padding: 8px 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: "Cinzel", serif;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 2px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.history-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.history-item.active { background: var(--bg-hover); color: var(--text-primary); }
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border-color); }

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 2px;
  margin-bottom: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--bg-dark);
  font-family: "Cinzel", serif;
}

.user-info span { font-size: 0.9rem; }

.sidebar-links { display: flex; flex-direction: column; gap: 4px; }

.sidebar-links a {
  display: block;
  padding: 8px 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: 2px;
  transition: all 0.2s;
}

.sidebar-links a:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Sidebar Toggle (Mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 8px;
  color: var(--primary);
  cursor: pointer;
}

/* ==================== MAIN CHAT ==================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  position: relative;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-container::-webkit-scrollbar { width: 8px; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* Empty State */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.empty-logo {
  margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.chat-empty h1 {
  font-family: "Cinzel", serif;
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.dev-notice {
  color: var(--text-secondary);
  margin-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.notice-badge {
  display: inline-block;
  padding: 4px 16px;
  background: rgba(212, 175, 55, 0.12);
  color: var(--secondary);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 2px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: "Cinzel", serif;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.suggestion-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 600px;
  width: 100%;
}

.suggestion-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.suggestion-card:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(201, 169, 110, 0.12);
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
}

.card-icon svg { stroke: var(--primary); }

.card-text { display: flex; flex-direction: column; gap: 2px; }
.card-text strong { font-weight: 600; color: var(--text-primary); font-family: "Cinzel", serif; font-size: 0.9rem; }
.card-text span { color: var(--text-secondary); font-size: 0.9rem; }

/* Messages */
.messages-container {
  display: none;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.messages-container.active { display: flex; }

.message-row {
  display: flex;
  gap: 16px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border-color);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row:last-child { border-bottom: none; }

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.message-row.user .message-avatar { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.message-row.bot .message-avatar { background: linear-gradient(135deg, #7ea87e, #5a8a5a); }

.message-content { flex: 1; min-width: 0; }

.message-sender {
  font-family: "Cinzel", serif;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.message-text {
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-text a {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 700;
  transition: color 0.2s ease;
}

.message-text a:hover { color: var(--secondary); text-decoration: underline; }

.message-text pre {
  background: var(--bg-sidebar);
  padding: 16px;
  border-radius: 4px;
  margin: 12px 0;
  overflow-x: auto;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: pre-wrap;
  max-width: 100%;
  font-family: "Fira Code", "Monaco", monospace;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
}

.message-text code {
  background: var(--bg-sidebar);
  padding: 2px 6px;
  border-radius: 2px;
  font-family: "Fira Code", "Monaco", monospace;
  font-size: 0.9rem;
}

/* Typing Indicator */
.typing-row { display: flex; gap: 16px; padding: 24px 0; }

.typing-dots { display: flex; gap: 6px; padding: 12px 0; }

.typing-dots span {
  width: 10px;
  height: 10px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-8px); opacity: 1; }
}

/* ==================== INPUT AREA ==================== */
.input-area { padding: 20px; background: var(--bg-chat); }

.input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within { border-color: var(--primary); }

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: "Cormorant Garamond", serif;
  resize: none;
  max-height: 200px;
  line-height: 1.5;
}

.input-wrapper textarea::placeholder { color: var(--text-muted); }

.send-btn {
  width: 40px;
  height: 40px;
  background: var(--text-muted);
  border: none;
  border-radius: 50%;
  color: var(--bg-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn:hover { background: var(--text-primary); }
.send-btn.active { background: var(--primary); color: var(--bg-dark); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input-disclaimer {
  max-width: 800px;
  margin: 12px auto 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .suggestion-cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .chat-empty h1 { font-size: 1.8rem; }
  .chat-empty p { font-size: 0.95rem; }
}

@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 200; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .chat-main { width: 100%; }
  .suggestion-cards { grid-template-columns: 1fr; gap: 10px; }
  .suggestion-card { padding: 16px; }
  .card-icon { width: 40px; height: 40px; }
  .card-icon svg { width: 20px; height: 20px; }
  .chat-empty h1 { font-size: 1.5rem; }
  .chat-empty p { font-size: 0.9rem; }
  .message-row { padding: 16px 12px; }
  .message-avatar { width: 32px; height: 32px; min-width: 32px; }
  .message-sender { font-size: 0.85rem; }
  .message-text { font-size: 0.95rem; }
  .input-area { padding: 12px; }
  .input-wrapper textarea { font-size: 0.95rem; padding: 12px 50px 12px 16px; }
  .send-btn { width: 40px; height: 40px; right: 8px; }
  .send-btn svg { width: 18px; height: 18px; }
}

@media (max-width: 640px) {
  .sidebar { width: 280px; }
  .sidebar-header { padding: 12px; }
  .sidebar-logo { font-size: 0.9rem; margin-bottom: 12px; }
  .new-chat-btn { padding: 10px 14px; font-size: 0.8rem; }
  .history-label { font-size: 0.65rem; }
  .history-item { padding: 10px 12px; font-size: 0.85rem; }
  .user-info { padding: 10px 12px; font-size: 0.85rem; }
  .user-avatar { width: 32px; height: 32px; font-size: 0.85rem; }
  .sidebar-links { padding: 10px 12px; }
  .sidebar-links a { font-size: 0.8rem; }
  .chat-empty { padding: 20px; }
  .empty-logo svg { width: 48px; height: 48px; }
  .chat-empty h1 { font-size: 1.3rem; margin-bottom: 10px; }
  .dev-notice { font-size: 0.85rem; padding: 8px 12px; }
  .notice-badge { font-size: 0.65rem; padding: 2px 8px; }
  .suggestion-cards { gap: 8px; }
  .suggestion-card { padding: 14px; }
  .card-text strong { font-size: 0.85rem; }
  .card-text span { font-size: 0.8rem; }
  .messages-container { padding: 12px; }
  .message-row { padding: 12px 0; }
  .message-content { max-width: 100%; }
  .message-text { font-size: 0.9rem; line-height: 1.6; }
  .message-text pre { padding: 12px; font-size: 0.8rem; margin: 8px 0; }
  .message-text code { font-size: 0.8rem; padding: 2px 5px; }
  .typing-dots { padding: 12px 16px; }
  .typing-dots span { width: 8px; height: 8px; }
  .input-area { padding: 10px; }
  .input-wrapper { max-width: 100%; }
  .input-wrapper textarea { font-size: 0.9rem; padding: 10px 45px 10px 14px; min-height: 44px; }
  .input-wrapper textarea::placeholder { font-size: 0.9rem; }
  .send-btn { width: 38px; height: 38px; right: 6px; bottom: 6px; }
  .input-disclaimer { font-size: 0.7rem; padding: 8px 0; }
}

@media (max-width: 380px) {
  .sidebar { width: 100%; }
  .chat-empty h1 { font-size: 1.1rem; }
  .chat-empty p { font-size: 0.85rem; }
  .suggestion-card { padding: 12px; }
  .card-icon { width: 36px; height: 36px; }
  .card-text strong { font-size: 0.8rem; }
  .card-text span { font-size: 0.75rem; }
  .message-text { font-size: 0.85rem; }
  .input-wrapper textarea { font-size: 0.85rem; }
}

@media (max-width: 768px) and (orientation: landscape) {
  .chat-container { height: calc(100vh - 60px); }
  .chat-empty { padding: 15px; }
  .chat-empty h1 { font-size: 1.2rem; margin-bottom: 8px; }
  .suggestion-cards { grid-template-columns: repeat(2, 1fr); }
  .input-area { padding: 8px 10px; }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 150;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
