﻿/* Kaz Legal Bot — Modern Dark Theme with Enhanced Interactivity
 *
 * Этот файл содержит стили для веб-приложения Kaz Legal Bot. Он использует
 * переменные CSS для лёгкого управления цветовой схемой и размерами элементов.
 * Предусмотрена адаптивная вёрстка для устройств различных размеров,
 * включая планшеты и телефоны. В интерфейсе применяются плавные
 * анимации при наведении, чтобы сделать использование более приятным.
 */

/* === CSS Variables === */
/* Светлая тема — по умолчанию */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-header: #eef2f7;

  /* Цвета текста */
  --text-primary: #0f172a;
  --text-secondary: #475569;

  /* Акцентные цвета */
  --accent-primary: #2563eb; /* Синий для активных элементов */
  --accent-secondary: #16a34a; /* Зелёный для второстепенных действий */
  --danger: #dc2626;         /* Красный для удаления и ошибок */

  /* Отделители и фон пузырей */
  --border-color: #e2e8f0;
  --chat-bubble-user: #e9eef8;
  --chat-bubble-ai: #eef3ff;

  /* Поля ввода */
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
}

/* Тёмная тема — когда body имеет класс .dark-theme */
body.dark-theme {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-header: #1a2232;

  /* Цвета текста */
  --text-primary: #d1d5da;
  --text-secondary: #8b949e;

  /* Акцентные цвета */
  --accent-primary: #58a6ff; /* Голубой для активных элементов */
  --accent-secondary: #3fb950; /* Зелёный для второстепенных действий */
  --danger: #f85149;         /* Красный для удаления и ошибок */

  /* Отделители и фон пузырей */
  --border-color: #30363d;
  --chat-bubble-user: #1f2937;
  --chat-bubble-ai: #24344d;

  /* Поля ввода */
  --input-bg: #1e2531;
  --input-border: #39414c;
}

/* === Global Reset === */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* === Header === */
header {
  background: var(--bg-header);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  position: sticky;
  top: 0;
  z-index: 1000;
}

header h1 {
  color: var(--accent-primary);
  font-size: 1.8rem;
  font-weight: 700;
}

header nav a {
  color: var(--text-secondary);
  text-decoration: none;
  margin-left: 2rem;
  font-size: 1rem;
  transition: color 0.3s ease;
}

header nav a:hover {
  color: var(--accent-primary);
}

/* === Main Layout === */
main {
  flex-grow: 1;
  max-width: 1400px;
  width: 100%;
  margin: 1rem auto;
  padding: 0 1rem;
  display: flex;
  gap: 1rem;
}

.app-container {
  flex-grow: 1;
  display: flex;
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
}

.sidebar h2 {
  font-size: 1.4rem;
  text-align: center;
  margin-bottom: 1rem;
}

#chat-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex-grow: 1;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-primary) var(--bg-secondary);
}

#chat-list::-webkit-scrollbar {
  width: 8px;
}
#chat-list::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
#chat-list::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 10px;
  border: 2px solid var(--bg-secondary);
}

/* РљР°Р¶РґР°СЏ Р·Р°РїРёСЃСЊ вЂ” flex: С‚РµРєСЃС‚ Рё РёРєРѕРЅРєР° РїРѕ РєСЂР°СЏРј */
#chat-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.5rem;
  margin-bottom: 0.4rem;
  border-radius: 6px;
  color: var(--text-secondary);
  background: transparent;
  transition: background 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

#chat-list li.active {
  background: var(--accent-primary);
  color: #fff;
}

#chat-list li:hover {
  background: rgba(88, 166, 255, 0.2);
  transform: translateY(-2px);
}

/* РљРЅРѕРїРєР° СѓРґР°Р»РµРЅРёСЏ РІ СЃРїРёСЃРєРµ С‡Р°С‚РѕРІ */
.delete-chat-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: color 0.3s ease, transform 0.2s ease;
}

.delete-chat-btn:hover {
  color: #ff3333;
  transform: scale(1.1);
}

.delete-chat-btn i {
  pointer-events: none;
}

/* New chat button */
.new-conversation-btn {
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem;
  background: linear-gradient(90deg, var(--accent-secondary) 0%, #2db55f 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.new-conversation-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* === Main content area === */
.main-content-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
}

#initial-sections {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cards for about/help/upload sections */
.input-card, .upload-card, #about-section, #help-section, #contact {
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.input-card .greeting-message {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 1rem;
}

/* Form for first question */
#chat-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

textarea#userQuestion {
  width: 100%;
  min-height: 120px;
  padding: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  resize: vertical;
  transition: border 0.3s ease;
}

textarea#userQuestion:focus {
  border-color: var(--accent-primary);
  outline: none;
}

button.primary-btn {
  background: linear-gradient(90deg, var(--accent-primary) 0%, #2d63e5 100%);
  color: #fff;
  padding: 0.8rem 1.4rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

button.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

button.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Upload Section */
.upload-card h2 {
  font-size: 1.2rem;
  text-align: center;
  margin-bottom: 1rem;
}

.drop-area {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease;
  margin-bottom: 1rem;
}

.drop-area:hover, .drop-area.drag-over {
  background: var(--input-bg);
  border-color: var(--accent-secondary);
}

.drop-area input[type="file"] {
  display: none;
}

.drop-area .drop-label {
  display: block;
  cursor: pointer;
}

.drop-area .drop-label i {
  font-size: 3rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.drop-area .drop-label p {
  margin: 0.5rem 0;
  color: var(--text-secondary);
}

.drop-area .file-types {
  font-size: 0.85rem;
  color: #777;
}

.file-list {
  margin-top: 1rem;
  color: var(--text-primary);
}

.file-list div {
  background: var(--input-bg);
  padding: 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  word-break: break-all;
}

.file-list .remove-file {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.2rem;
}

.file-list .remove-file:hover {
  color: #ff3333;
}

textarea#file-question {
  width: 100%;
  min-height: 80px;
  padding: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  margin-top: 1rem;
  transition: border 0.3s ease;
}

textarea#file-question:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.upload-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}

button.secondary-btn {
  background: var(--accent-secondary);
  color: #fff;
  padding: 0.8rem 1.4rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}

button.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

button.secondary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* About, Help, Contact sections */
#about-section h2, #help-section h2, #contact h2 {
  color: var(--accent-primary);
  font-size: 1.6rem;
  margin-bottom: 1rem;
  text-align: center;
}

#about-section p, #help-section p, #contact p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  text-align: justify;
}

#help-section ul {
  list-style: none;
  padding: 0;
}

#help-section li {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.7rem;
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#help-section li b {
  color: var(--accent-secondary);
}

#contact a {
  color: var(--accent-primary);
  text-decoration: none;
}

#contact a:hover {
  text-decoration: underline;
}

/* === Chat container === */
#current-chat-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

#chat-messages-display {
  flex-grow: 1;
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
  min-height: 400px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-primary) var(--bg-primary);
}

#chat-messages-display::-webkit-scrollbar {
  width: 8px;
}
#chat-messages-display::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
#chat-messages-display::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 10px;
  border: 2px solid var(--bg-primary);
}

/* Chat bubbles */
.chat-bubble {
  padding: 12px 18px;
  border-radius: 16px;
  max-width: 75%;
  font-size: 1rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
  transition: transform 0.1s ease, background 0.3s ease;
}

.chat-bubble.user-message {
  background: var(--chat-bubble-user);
  color: var(--text-primary);
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.chat-bubble.ai-response {
  background: var(--chat-bubble-ai);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

.chat-bubble:hover {
  transform: translateY(-2px);
  background: rgba(88, 166, 255, 0.1);
}

.chat-bubble p {
  margin: 0;
}

/* AI response markdown */
.ai-response p {
  margin-bottom: 0.5em;
}
.ai-response ul, .ai-response ol {
  margin-left: 1.5em;
  margin-bottom: 0.5em;
}
.ai-response li {
  margin-bottom: 0.2em;
}
.ai-response h1, .ai-response h2, .ai-response h3,
.ai-response h4, .ai-response h5, .ai-response h6 {
  color: var(--accent-primary);
  margin-top: 1em;
  margin-bottom: 0.5em;
}
.ai-response a {
  color: var(--accent-secondary);
  text-decoration: none;
}
.ai-response a:hover {
  text-decoration: underline;
}
.ai-response code {
  background: #333;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 0.9em;
}
.ai-response pre {
  background: #222;
  padding: 1em;
  border-radius: 5px;
  overflow-x: auto;
}
.ai-response pre code {
  background: transparent;
  padding: 0;
  font-size: 1em;
}
.ai-response blockquote {
  border-left: 4px solid var(--accent-primary);
  padding-left: 1em;
  margin-left: 0;
  color: var(--text-secondary);
  font-style: italic;
}
.ai-response table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
}
.ai-response th, .ai-response td {
  border: 1px solid var(--border-color);
  padding: 8px;
}
.ai-response th {
  background: var(--input-bg);
  color: var(--text-primary);
}
.ai-response hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1em 0;
}

/* Chat input area */
.chat-input-area {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  width: 100%;
}

.chat-input {
  flex-grow: 1;
  padding: 0.8rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border 0.3s ease;
}

.chat-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.send-button {
  background: linear-gradient(90deg, var(--accent-primary) 0%, #2d63e5 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.8rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Spinners */
#spinner, #fileSpinner {
  display: none; /* Hidden by default; shown via JavaScript */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  margin: 20px auto;
  max-width: 500px;
  width: fit-content;
  font-size: 1rem;
}

#spinner p, #fileSpinner p {
  margin-top: 0;
  font-size: 1.1rem;
}

.loader {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin-top: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error message */
.error-message {
  color: var(--danger);
  font-weight: bold;
}

/* Footer */
footer {
  background: var(--bg-header);
  color: var(--text-secondary);
  text-align: center;
  padding: 1rem;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.2);
  margin-top: auto;
}

/* === Loading Skeleton Components === */
.skeleton {
  background: linear-gradient(90deg, var(--input-bg) 25%, var(--border-color) 50%, var(--input-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-chat-message {
  max-width: 75%;
  margin-bottom: 1rem;
  padding: 12px 18px;
  border-radius: 16px;
  height: 60px;
}

.skeleton-chat-message.user {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.skeleton-chat-message.ai {
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

.skeleton-sidebar-item {
  height: 40px;
  margin-bottom: 0.4rem;
  border-radius: 6px;
}

.skeleton-text-line {
  height: 16px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-text-line.short {
  width: 60%;
}

.skeleton-text-line.medium {
  width: 80%;
}

.skeleton-text-line.long {
  width: 100%;
}

.skeleton-container {
  padding: 1rem;
  background: var(--bg-primary);
  border-radius: 8px;
  margin-bottom: 1rem;
}

/* === Smooth Transitions === */
.app-container {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#initial-sections {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

#initial-sections.fade-out {
  opacity: 0;
  transform: translateY(-20px);
}

#current-chat-container {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

#current-chat-container.fade-in {
  opacity: 1;
  transform: translateY(0);
}

#current-chat-container[style*="flex"] {
  opacity: 1;
  transform: translateY(0);
}

.chat-bubble {
  opacity: 0;
  transform: translateY(10px);
  animation: slideInMessage 0.3s ease-out forwards;
}

@keyframes slideInMessage {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sidebar li {
  transition: all 0.2s ease;
}

.input-card, .upload-card, #about-section, #help-section, #contact {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.input-card:hover, .upload-card:hover, #about-section:hover, #help-section:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

/* === Enhanced Error Display Components === */
.error-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  border-left: 4px solid;
  transition: all 0.3s ease;
  animation: slideInError 0.3s ease-out;
}

@keyframes slideInError {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.error-container.connection-error {
  background: rgba(248, 81, 73, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.error-container.upload-error {
  background: rgba(255, 165, 0, 0.1);
  border-color: #ffa500;
  color: #ffa500;
}

.error-container.api-error {
  background: rgba(248, 81, 73, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.error-container.validation-error {
  background: rgba(255, 193, 7, 0.1);
  border-color: #ffc107;
  color: #ffc107;
}

.error-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.error-content {
  flex-grow: 1;
}

.error-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.error-description {
  font-size: 0.9rem;
  opacity: 0.9;
  line-height: 1.4;
}

.error-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.error-action-btn {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.error-action-btn:hover {
  background: currentColor;
  color: var(--bg-primary);
}

.error-action-btn.primary {
  background: currentColor;
  color: var(--bg-primary);
}

.error-action-btn.primary:hover {
  opacity: 0.8;
}

.error-dismiss {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  padding: 0.2rem;
  border-radius: 50%;
}

.error-dismiss:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* Connection status indicator */
.connection-status {
  position: fixed;
  top: 70px;
  right: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  z-index: 1001;
  transition: all 0.3s ease;
  transform: translateY(-100px);
}

.connection-status.show {
  transform: translateY(0);
}

.connection-status.online {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

.connection-status.offline {
  border-color: var(--danger);
  color: var(--danger);
}

.connection-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Loading overlay for chat transitions */
.chat-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 100;
}

.chat-overlay.show {
  opacity: 1;
  visibility: visible;
}

.chat-overlay .loader {
  margin-bottom: 1rem;
}

.chat-overlay-text {
  color: var(--text-secondary);
  text-align: center;
  font-size: 1.1rem;
}

/* === Responsive Breakpoints === */
/* Medium screens (tablets) */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
  }
  #chat-list {
    max-height: 150px;
  }
  header {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
  }
  header nav a {
    margin: 0 0.5rem;
  }
  .chat-bubble {
    font-size: 0.9rem;
    padding: 10px 15px;
    max-width: 90%;
  }
  textarea#userQuestion {
    min-height: 80px;
    font-size: 0.95rem;
    padding: 0.8rem;
  }
  button#send-initial-message {
    font-size: 0.95rem;
    padding: 10px 15px;
  }
  .upload-card {
    padding: 1.5rem;
  }
  .upload-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
  }
  #spinner, #fileSpinner {
    font-size: 0.9rem;
    padding: 18px 4px;
    max-width: 90vw;
  }
  .loader {
    width: 28px;
    height: 28px;
  }
  .file-question-input {
    font-size: 0.95rem;
    padding: 0.8rem;
    min-height: 60px;
  }
  .new-conversation-btn {
    font-size: 0.95rem;
    padding: 0.7rem;
  }
}

/* Small screens (phones) */
@media (max-width: 480px) {
  .sidebar {
    padding: 1rem 0.5rem;
  }
  #chat-list {
    max-height: 120px;
  }
  .chat-input-area {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.8rem 0;
  }
  .attach-button {
    align-self: flex-start;
    padding: 0.5rem;
  }
  .chat-input {
    width: 100%;
    font-size: 0.95rem;
    padding: 0.6rem;
  }
  .send-button {
    width: 100%;
    padding: 0.7rem;
    font-size: 0.95rem;
  }
  #spinner, #fileSpinner {
    font-size: 0.85rem;
    padding: 14px 4px;
    max-width: 95vw;
  }
  .loader {
    width: 24px;
    height: 24px;
  }
  .chat-bubble {
    font-size: 0.85rem;
    padding: 8px 14px;
    max-width: 85%;
  }
  .upload-card h2, .input-card .greeting-message {
    font-size: 1.1rem;
  }
  #about-section h2, #help-section h2, #contact h2 {
    font-size: 1.3rem;
  }
  button.primary-btn {
    font-size: 0.95rem;
    padding: 0.7rem 1.2rem;
  }
  .new-conversation-btn {
    font-size: 0.9rem;
    padding: 0.6rem;
  }
}

/* AI Response Formatter Styles */
.content-warning {
  background: rgba(248, 81, 73, 0.15);
  border-left: 4px solid var(--danger);
  padding: 0.8rem 1rem;
  margin: 0.5rem 0;
  border-radius: 0 6px 6px 0;
  color: #ff6b6b;
  font-weight: 600;
}

.content-positive {
  background: rgba(63, 185, 80, 0.15);
  border-left: 4px solid var(--accent-secondary);
  padding: 0.8rem 1rem;
  margin: 0.5rem 0;
  border-radius: 0 6px 6px 0;
  color: #4ade80;
  font-weight: 600;
}

.content-reference {
  background: rgba(88, 166, 255, 0.15);
  border-left: 4px solid var(--accent-primary);
  padding: 0.8rem 1rem;
  margin: 0.5rem 0;
  border-radius: 0 6px 6px 0;
  color: #7dd3fc;
  font-style: italic;
}

.bold-text {
  color: var(--text-primary);
  font-weight: 700;
}

.italic-text {
  color: var(--text-secondary);
  font-style: italic;
}

.code-block {
  background: #1a1f2e;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.8rem 0;
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 0.9em;
  line-height: 1.4;
}

.code-block code {
  background: transparent;
  padding: 0;
  border: none;
  color: #e6db74;
}

.inline-code {
  background: rgba(88, 166, 255, 0.2);
  color: var(--accent-primary);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 0.9em;
  border: 1px solid rgba(88, 166, 255, 0.3);
}

.header-1, .header-2, .header-3 {
  color: var(--accent-primary);
  margin: 1rem 0 0.5rem 0;
  font-weight: 700;
}

.header-1 {
  font-size: 1.4em;
  border-bottom: 2px solid var(--accent-primary);
  padding-bottom: 0.3rem;
}

.header-2 {
  font-size: 1.2em;
}

.header-3 {
  font-size: 1.1em;
}

.formatted-list, .numbered-list {
  margin: 0.8rem 0;
  padding-left: 1.5rem;
}

.formatted-list {
  list-style-type: disc;
}

.numbered-list {
  list-style-type: decimal;
}

.list-item, .numbered-item {
  margin-bottom: 0.3rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.list-item::marker, .numbered-item::marker {
  color: var(--accent-secondary);
  font-weight: bold;
}

 
 / *   H e a d e r   r i g h t   s e c t i o n   f o r   t h e m e   t o g g l e   * / 
 
 . h e a d e r - r i g h t   { 
 
     d i s p l a y :   f l e x ; 
 
     a l i g n - i t e m s :   c e n t e r ; 
 
     j u s t i f y - c o n t e n t :   f l e x - e n d ; 
 
     g a p :   1 r e m ; 
 
 } 
 
 
 
 / *   T h e m e   t o g g l e   b u t t o n   * / 
 
 . t h e m e - t o g g l e   { 
 
     w i d t h :   4 0 p x ; 
 
     h e i g h t :   4 0 p x ; 
 
     b a c k g r o u n d :   v a r ( - - i n p u t - b g ) ; 
 
     b o r d e r :   1 p x   s o l i d   v a r ( - - b o r d e r - c o l o r ) ; 
 
     b o r d e r - r a d i u s :   5 0 % ; 
 
     c o l o r :   v a r ( - - t e x t - s e c o n d a r y ) ; 
 
     c u r s o r :   p o i n t e r ; 
 
     d i s p l a y :   f l e x ; 
 
     a l i g n - i t e m s :   c e n t e r ; 
 
     j u s t i f y - c o n t e n t :   c e n t e r ; 
 
     f o n t - s i z e :   1 . 2 r e m ; 
 
     t r a n s i t i o n :   a l l   0 . 3 s   e a s e ; 
 
     m a r g i n - l e f t :   1 r e m ; 
 
 } 
 
 
 
 . t h e m e - t o g g l e : h o v e r   { 
 
     b a c k g r o u n d :   v a r ( - - a c c e n t - p r i m a r y ) ; 
 
     c o l o r :   # f f f ; 
 
     b o r d e r - c o l o r :   v a r ( - - a c c e n t - p r i m a r y ) ; 
 
     t r a n s f o r m :   t r a n s l a t e Y ( - 2 p x ) ; 
 
     b o x - s h a d o w :   0   4 p x   8 p x   r g b a ( 0 ,   0 ,   0 ,   0 . 3 ) ; 
 
 } 
 
 
 
 . t h e m e - t o g g l e : a c t i v e   { 
 
     t r a n s f o r m :   t r a n s l a t e Y ( 0 ) ; 
 
     b o x - s h a d o w :   0   2 p x   4 p x   r g b a ( 0 ,   0 ,   0 ,   0 . 2 ) ; 
 
 } 
 
 