/* ===== AURACHAT - MULTI-THEME STYLES ===== */

/* === BASE THEME: LIGHT === */
:root {
  --primary: #FF9933;
  --primary-dark: #E65100;
  --primary-light: #FFE0B2;
  --primary-glow: rgba(255, 153, 51, 0.15);
  --bg: #FFF8F0;
  --surface: #FFFFFF;
  --surface-hover: #FFF3E0;
  --text: #2D2D2D;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #FFCC80;
  --border-light: #FFE8CC;
  --shadow: rgba(255, 153, 51, 0.08);
  --shadow-strong: rgba(255, 153, 51, 0.15);
  --code-bg: #F5F5F5;
  --user-bubble: linear-gradient(135deg, #FF9933, #FF8A65);
  --ai-bubble: #FFFFFF;
  --success: #4CAF50;
  --error: #E53935;
  --font-size: 14px;
}

/* === DARK THEME === */
[data-theme="dark"] {
  --primary: #FFB74D;
  --primary-dark: #FF9800;
  --primary-light: #5D4037;
  --primary-glow: rgba(255, 183, 77, 0.12);
  --bg: #0D0D0D;
  --surface: #1A1A1A;
  --surface-hover: #262626;
  --text: #F0F0F0;
  --text-secondary: #B0B0B0;
  --text-muted: #707070;
  --border: #3D3D3D;
  --border-light: #2A2A2A;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-strong: rgba(0, 0, 0, 0.6);
  --code-bg: #1E1E1E;
  --user-bubble: linear-gradient(135deg, #FF9800, #F57C00);
  --ai-bubble: #1E1E1E;
}

/* === SAFFRON THEME === */
[data-theme="saffron"] {
  --primary: #FF6F00;
  --primary-dark: #E65100;
  --primary-light: #FFE0B2;
  --primary-glow: rgba(255, 111, 0, 0.15);
  --bg: #FFF3E0;
  --surface: #FFFFFF;
  --surface-hover: #FFECB3;
  --text: #3E2723;
  --text-secondary: #5D4037;
  --text-muted: #8D6E63;
  --border: #FFCC80;
  --border-light: #FFE0B2;
  --shadow: rgba(255, 111, 0, 0.1);
  --shadow-strong: rgba(255, 111, 0, 0.2);
  --code-bg: #FFF8E1;
  --user-bubble: linear-gradient(135deg, #FF6F00, #FF8F00);
  --ai-bubble: #FFFFFF;
}

/* === MIDNIGHT THEME === */
[data-theme="midnight"] {
  --primary: #64B5F6;
  --primary-dark: #42A5F5;
  --primary-light: #1E3A5F;
  --primary-glow: rgba(100, 181, 246, 0.12);
  --bg: #0a0e1a;
  --surface: #121a2e;
  --surface-hover: #1a2540;
  --text: #E3F2FD;
  --text-secondary: #90CAF9;
  --text-muted: #5C7A9E;
  --border: #1E3A5F;
  --border-light: #162544;
  --shadow: rgba(0, 0, 0, 0.5);
  --shadow-strong: rgba(0, 0, 0, 0.7);
  --code-bg: #0d1321;
  --user-bubble: linear-gradient(135deg, #42A5F5, #1E88E5);
  --ai-bubble: #121a2e;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: var(--font-size);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

/* ===== APP CONTAINER ===== */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
  height: 100%;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.logo-icon {
  font-size: 1.8em;
}

.logo-text {
  font-size: 1.4em;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.new-chat-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px var(--shadow-strong);
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--shadow-strong);
}

.new-chat-btn:active {
  transform: translateY(0);
}

/* Chat History */
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 0.9em;
}

.history-item {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  font-size: 0.9em;
}

.history-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.history-item.active {
  background: var(--primary-glow);
  color: var(--primary-dark);
  border-left: 3px solid var(--primary);
}

.history-item .chat-icon {
  font-size: 1.1em;
}

.history-item .chat-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .chat-time {
  font-size: 0.75em;
  color: var(--text-muted);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-light);
}

.model-selector select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85em;
  cursor: pointer;
  margin-bottom: 10px;
}

.footer-actions {
  display: flex;
  gap: 8px;
}

.footer-actions button {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1em;
  transition: all 0.2s ease;
}

.footer-actions button:hover {
  background: var(--primary-glow);
  color: var(--primary-dark);
  border-color: var(--primary);
}

/* ===== MAIN CHAT AREA ===== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  gap: 12px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3em;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}

.chat-title {
  flex: 1;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.export-btn {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
}

.export-btn:hover {
  background: var(--surface-hover);
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 40px;
}

.welcome-icon {
  font-size: 4em;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

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

.welcome-screen h1 {
  font-size: 2em;
  margin-bottom: 10px;
  color: var(--text);
}

.welcome-screen p {
  color: var(--text-secondary);
  max-width: 500px;
  margin-bottom: 30px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 600px;
}

.chip {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

/* Messages */
.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.message {
  display: flex;
  gap: 12px;
  animation: messageSlide 0.3s ease;
}

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

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

.message.user .message-avatar {
  background: var(--user-bubble);
  color: white;
}

.message.ai .message-avatar {
  background: var(--surface);
  border: 2px solid var(--primary);
}

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

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-author {
  font-weight: 600;
  font-size: 0.9em;
}

.message-time {
  font-size: 0.75em;
  color: var(--text-muted);
}

.message-bubble {
  padding: 14px 18px;
  border-radius: 14px;
  line-height: 1.7;
  font-size: 0.95em;
}

.message.user .message-bubble {
  background: var(--user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.ai .message-bubble {
  background: var(--ai-bubble);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
}

.message.ai .message-bubble pre {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
}

.message.ai .message-bubble code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
}

.message.ai .message-bubble p code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.message.ai .message-bubble ul,
.message.ai .message-bubble ol {
  margin: 10px 0;
  padding-left: 24px;
}

.message.ai .message-bubble li {
  margin: 4px 0;
}

.message.ai .message-bubble blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 14px;
  margin: 10px 0;
  color: var(--text-secondary);
}

.message.ai .message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.message.ai .message-bubble th,
.message.ai .message-bubble td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.message.ai .message-bubble th {
  background: var(--surface-hover);
}

/* Typing Indicator */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.typing-indicator.visible {
  display: flex;
}

.typing-indicator .message-avatar {
  background: var(--surface);
  border: 2px solid var(--primary);
}

.typing-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 14px 18px;
  background: var(--ai-bubble);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ===== INPUT AREA ===== */
.input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-wrapper textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1em;
  resize: none;
  max-height: 200px;
  min-height: 24px;
  outline: none;
  padding: 6px 0;
  font-family: inherit;
}

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

.input-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.char-count {
  font-size: 0.75em;
  color: var(--text-muted);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 2px 10px var(--shadow-strong);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 0 8px;
}

.ai-model {
  font-size: 0.8em;
  color: var(--primary);
  font-weight: 500;
}

.disclaimer {
  font-size: 0.75em;
  color: var(--text-muted);
}

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.visible {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--shadow-strong);
  animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 1.2em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3em;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
}

.setting-item {
  margin-bottom: 24px;
}

.setting-item label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.theme-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-option {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s ease;
}

.theme-option:hover {
  border-color: var(--primary);
}

.theme-option.active {
  border-color: var(--primary);
  background: var(--primary-glow);
  color: var(--primary-dark);
}

.danger-btn {
  padding: 10px 20px;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: transparent;
  color: var(--error);
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s;
}

.danger-btn:hover {
  background: var(--error);
  color: white;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    transform: translateX(-100%);
    height: 100%;
    box-shadow: 4px 0 20px var(--shadow-strong);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: block;
  }

  .messages-container {
    padding: 12px;
  }

  .welcome-screen h1 {
    font-size: 1.5em;
  }

  .suggestion-chips {
    flex-direction: column;
    align-items: stretch;
  }

  .chip {
    text-align: center;
  }
}

/* ===== CODE HIGHLIGHTING OVERRIDE ===== */
.hljs {
  background: var(--code-bg) !important;
  border-radius: 8px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* Per-message action buttons (Copy / Edit / Regenerate) */
.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message:hover .message-actions {
  opacity: 1;
}

.msg-action {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85em;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.msg-action:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Inline edit box */
.edit-textarea {
  width: 100%;
  min-height: 60px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95em;
  resize: vertical;
}

.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.edit-actions button {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85em;
}

.edit-save {
  background: var(--primary);
  color: white;
}

.edit-cancel {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-light) !important;
}

/* Delete button on each sidebar conversation */
.history-item {
  position: relative;
}

.history-delete {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.9em;
  opacity: 0;
  padding: 2px 4px;
  border-radius: 4px;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.history-item:hover .history-delete {
  opacity: 0.7;
}

.history-delete:hover {
  opacity: 1 !important;
  background: rgba(220, 38, 38, 0.15);
}
