/* ==========================================
   AXILIA RAG - MODERN UI DESIGN v4.0
   Matching Flutter App Theme
   Dark & Light Mode Support
   ========================================== */

/* ==================== CSS VARIABLES - LIGHT THEME (Default) ==================== */
:root {
  /* Background Colors - Light */
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #f0f2f5;
  --bg-surface: #ffffff;
  --bg-middle: #e8ebef;
  --bg-hover: rgba(99, 102, 241, 0.08);
  --bg-active: rgba(99, 102, 241, 0.12);
  --bg-contrasto: #e4e7eb;
  --bg-bubble: #f0f2f5;

  /* Text Colors - Light */
  --text-primary: #24292f;
  --text-secondary: #57606a;
  --text-tertiary: #8b949e;

  /* Border Colors - Light */
  --border-color: #d0d7de;
  --border-light: #e6e8eb;

  /* Accent Colors - Indigo/Violet Premium */
  --accent-color: #6366F1;
  --accent-hover: #4F46E5;
  --accent-light: rgba(99, 102, 241, 0.12);

  /* Gradient Colors - Indigo to Violet to Pink */
  --gradient-start: #818CF8;
  --gradient-middle: #7C3AED;
  --gradient-end: #EC4899;

  /* Status Colors */
  --success-color: #3FB950;
  --warning-color: #D29922;
  --danger-color: #F85149;
  --info-color: #6366F1;

  /* Input */
  --input-bg: #ffffff;
  --input-border: #d0d7de;
  --input-focus: #6366F1;

  /* Messages */
  --message-user: linear-gradient(135deg, #6366F1 0%, #7C3AED 100%);
  --message-assistant: #f6f8fa;

  /* Layout */
  --sidebar-width: 300px;
  --header-height: 56px;
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --border-radius-xl: 24px;

  /* Shadows - Light */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* ==================== CSS VARIABLES - DARK THEME ==================== */
[data-theme="dark"] {
  /* Background Colors - Dark (Flutter Style) */
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-tertiary: #21262D;
  --bg-surface: #161B22;
  --bg-middle: #1c2128;
  --bg-hover: rgba(129, 140, 248, 0.1);
  --bg-active: rgba(129, 140, 248, 0.15);
  --bg-contrasto: #282e36;
  --bg-bubble: #21262D;

  /* Text Colors - Dark */
  --text-primary: #F0F6FC;
  --text-secondary: #8B949E;
  --text-tertiary: #6E7681;

  /* Border Colors - Dark */
  --border-color: #30363D;
  --border-light: #21262D;

  /* Accent Colors - Brighter Indigo for Dark Mode */
  --accent-color: #818CF8;
  --accent-hover: #6366F1;
  --accent-light: rgba(129, 140, 248, 0.15);

  /* Input - Dark */
  --input-bg: #161B22;
  --input-border: #30363D;

  /* Messages - Dark */
  --message-assistant: #161B22;

  /* Shadows - Dark */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(129, 140, 248, 0.35);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.5;
}

/* ==================== FONT FAMILIES - Website Matching ==================== */

/* Base font - Sora for general text */
body {
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
}

/* Headlines - Space Grotesk for modern tech feel */
h1, h2, h3, h4, h5, h6,
.section-title,
.modal-title {
  font-family: 'Space Grotesk', 'Sora', sans-serif;
  font-weight: 600;
}

/* Special headlines - Playfair for elegant titles (welcome) */
.welcome-message h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
}

/* Message content - Sora for readability */
.message-bubble.assistant,
.message-content,
.streaming-content {
  font-family: 'Sora', -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.7;
}

/* UI Elements - Poppins for buttons and controls */
button, input, select, textarea,
.sidebar, .nav-item, .conversation-item,
.btn, .action-button {
  font-family: 'Poppins', 'Sora', sans-serif;
}

/* Code - Fira Code for monospace */
code, pre, .code-block,
.cot-icon {
  font-family: 'Fira Code', 'Consolas', monospace;
}

/* Small text and labels */
.text-muted, .text-secondary,
.char-counter, .timestamp,
.welcome-feature, .suggestion-text {
  font-family: 'Sora', sans-serif;
  font-weight: 400;
}

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

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

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

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

/* ==================== MAIN LAYOUT ==================== */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease;
  position: relative;
  z-index: 100;
}

[data-theme="dark"] .sidebar {
  background: #010409;
}

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

.new-chat-btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--accent-color);
  border: none;
  border-radius: var(--border-radius);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
  font-family: 'Playfair Display', serif;
  letter-spacing: 0.3px;
}

.new-chat-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

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

/* Conversations List */
.conversations-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  padding: 12px 14px;
  margin-bottom: 4px;
  border-radius: var(--border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
}

.conversation-item.active {
  background: var(--bg-active);
  border-color: var(--accent-color);
}

/* v3.1: Container for title + project tag */
.conversation-title-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  cursor: pointer;
}

.conversation-title {
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
  font-family: 'Playfair Display', serif;
  font-weight: 500;
}

.conversation-item:hover .conversation-title {
  color: var(--accent-color);
}

/* v3.1: Project tag in conversation list */
.conversation-project-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  max-width: fit-content;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-actions {
  display: none;
  gap: 4px;
  align-items: center;
}

.conversation-item:hover .conversation-actions {
  display: flex;
}

.action-btn {
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-color);
}

/* ==================== CONVERSATION SEARCH ==================== */
.conversation-search-container {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.conversation-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
  overflow: hidden;
}

.conversation-search-wrapper:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.conversation-search-wrapper:focus-within .search-icon {
  color: var(--accent-color);
}

.conversation-search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
  font-family: 'Sora', sans-serif;
}

.conversation-search-input::placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}

.clear-search-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.clear-search-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-color);
}

.search-results-count {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: var(--accent-light);
  border-radius: 6px;
  text-align: center;
  font-family: 'Sora', sans-serif;
  font-style: italic;
}

.conversation-item.filtered-out {
  display: none !important;
}

.conversation-item.search-match {
  background: var(--accent-light);
  border-left: 3px solid var(--accent-color);
}

.no-results-message {
  padding: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
  font-family: 'Sora', sans-serif;
  font-style: italic;
}

/* ==================== SIDEBAR TOOLS & ACTIONS ==================== */
.sidebar-tools {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.quick-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.action-button {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.action-button:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-2px);
}

.action-button:active {
  transform: translateY(0) scale(0.95);
}

.action-button.active {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.action-button.admin-only {
  background: var(--bg-tertiary);
  color: var(--accent-color);
  border-color: var(--accent-color);
  display: none;
}

.action-button.admin-only:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
}

/* ==================== SIDEBAR FOOTER ==================== */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 12px;
}

.user-menu-wrapper {
  position: relative;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-menu:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-info {
  flex: 1;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'Playfair Display', serif;
}

.user-email,
.user-role {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: 'Sora', sans-serif;
}

/* Dropdown Menu */
.dropdown-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 8px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: none;
}

.dropdown-menu.show {
  display: block;
  animation: slideUp 0.2s ease;
}

.dropdown-item {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--accent-color);
}

/* ==================== MAIN CONTENT AREA ==================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* ==================== HEADER ==================== */
.main-header {
  height: var(--header-height);
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  backdrop-filter: blur(10px);
}

[data-theme="dark"] .main-header {
  background: rgba(22, 27, 34, 0.9);
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* Sidebar collapsed state */
.app-container.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

.app-container.sidebar-collapsed .main-content {
  flex: 1;
}

.app-container.sidebar-collapsed .sidebar-toggle .toggle-open {
  display: none;
}

.app-container.sidebar-collapsed .sidebar-toggle .toggle-close {
  display: block !important;
  transform: rotate(180deg);
}

/* Main content footer space */
.main-content-footer {
  height: 20px;
  flex-shrink: 0;
  background: var(--bg-primary);
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.model-selector:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ==================== KNOWLEDGE GRAPH BUTTON - v3.3 ==================== */
.header-btn.kg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-btn.kg-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.header-btn.kg-btn svg {
  flex-shrink: 0;
}

.header-btn.kg-btn.has-data {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: rgba(var(--accent-color-rgb), 0.1);
}

.header-btn.kg-btn.has-data::after {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  margin-left: 4px;
}

/* ==================== THEME TOGGLE BUTTON ==================== */
.theme-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.theme-toggle-btn .sun-icon,
.theme-toggle-btn .moon-icon {
  width: 20px;
  height: 20px;
}

/* ==================== CHAT AREA ==================== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==================== WELCOME MESSAGE ==================== */
.welcome-message {
  max-width: 800px;
  margin: 60px auto;
  text-align: center;
  padding: 0 24px;
  animation: welcomeFadeIn 0.8s ease-out;
  position: relative;
}

@keyframes welcomeFadeIn {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Brain Container with Particles */
.welcome-brain-container {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Brain Icon - Clean, no borders */
.welcome-brain-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: brainFloat 4s ease-in-out infinite;
  z-index: 1;
}

.welcome-brain-icon svg {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 4px 20px rgba(129, 140, 248, 0.4));
}

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

/* Particle effects around brain */
.welcome-brain-container .welcome-particles {
  position: absolute;
  width: 160px;
  height: 160px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.welcome-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: particleFloat 3s ease-in-out infinite;
}

.welcome-particle:nth-child(1) {
  background: var(--gradient-start);
  top: 10%;
  left: 20%;
  animation-delay: 0s;
}

.welcome-particle:nth-child(2) {
  background: var(--gradient-middle);
  top: 15%;
  right: 15%;
  animation-delay: 0.5s;
}

.welcome-particle:nth-child(3) {
  background: var(--gradient-end);
  bottom: 20%;
  left: 15%;
  animation-delay: 1s;
}

.welcome-particle:nth-child(4) {
  background: var(--gradient-start);
  bottom: 15%;
  right: 20%;
  animation-delay: 1.5s;
}

.welcome-particle:nth-child(5) {
  background: var(--gradient-middle);
  top: 50%;
  left: 5%;
  animation-delay: 0.7s;
}

.welcome-particle:nth-child(6) {
  background: var(--gradient-end);
  top: 50%;
  right: 5%;
  animation-delay: 1.2s;
}

@keyframes particleFloat {
  0%, 100% {
    opacity: 0.4;
    transform: translateY(0) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateY(-15px) scale(1.2);
  }
}

/* Features Carousel Container */
.features-carousel-container {
  width: 100%;
  overflow: hidden;
  margin-bottom: 12px;
  mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
}

.features-carousel {
  width: 100%;
  overflow: hidden;
}

.features-track {
  display: flex;
  gap: 12px;
  width: max-content;
}

/* Row 1: Left to Right animation */
.features-row-1 .features-track {
  animation: scrollLeft 30s linear infinite;
}

/* Row 2: Right to Left animation */
.features-row-2 .features-track {
  animation: scrollRight 30s linear infinite;
}

@keyframes scrollLeft {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes scrollRight {
  0% { transform: translateX(-50%); }
  100% { transform: translateX(0); }
}

/* Pause on hover */
.features-carousel-container:hover .features-track {
  animation-play-state: paused;
}

/* Legacy animated logo (keep for backward compatibility) */
.welcome-logo {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 32px;
  display: none; /* Hidden - replaced by brain icon */
  align-items: center;
  justify-content: center;
}

@keyframes logoPulse {
  0%, 100% {
    box-shadow: 0 8px 32px rgba(129, 140, 248, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 12px 48px rgba(124, 58, 237, 0.5);
    transform: scale(1.05);
  }
}

/* No fallback needed - using welcome-brain-container */
.welcome-message::before {
  display: none !important;
}

.welcome-message h1 {
  font-family: 'Playfair Display', serif;
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-middle) 50%, var(--gradient-end) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  animation: gradientShift 4s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.welcome-message h1 .brand-highlight {
  position: relative;
}

.welcome-message p {
  font-family: 'Sora', sans-serif;
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 40px;
  line-height: 1.7;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

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

/* Welcome subtitle */
.welcome-subtitle {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 32px;
  text-align: center;
}

/* Feature badges - Now in carousel */
.welcome-features {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
  flex-wrap: wrap;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

.welcome-feature {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.welcome-feature:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(129, 140, 248, 0.15);
}

.welcome-feature svg {
  width: 16px;
  height: 16px;
  color: inherit;
  opacity: 0.7;
  flex-shrink: 0;
}

.welcome-feature:hover svg {
  opacity: 1;
}

[data-theme="dark"] .welcome-feature:hover {
  box-shadow: 0 4px 16px rgba(129, 140, 248, 0.2);
}

/* Carousel features don't animate on hover to keep smooth scrolling */
.features-carousel .welcome-feature:hover {
  transform: none;
}

.welcome-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 32px;
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

.suggestion-card {
  padding: 20px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  position: relative;
  overflow: hidden;
}

/* Animated gradient border on hover */
.suggestion-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: var(--border-radius-lg);
  padding: 2px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-middle), var(--gradient-end));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.suggestion-card:hover::before {
  opacity: 1;
}

/* Glow effect */
.suggestion-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.05) 0%, rgba(124, 58, 237, 0.05) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: var(--border-radius-lg);
}

.suggestion-card:hover::after {
  opacity: 1;
}

.suggestion-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .suggestion-card:hover {
  box-shadow: 0 12px 40px rgba(129, 140, 248, 0.15);
}

.suggestion-icon {
  display: block;
  margin-bottom: 12px;
  width: 28px;
  height: 28px;
  color: var(--text-tertiary);
  transition: color 0.3s ease;
}

.suggestion-icon svg {
  width: 100%;
  height: 100%;
}

.suggestion-card:hover .suggestion-icon {
  color: var(--accent-color);
}

.suggestion-text {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

.suggestion-card:hover .suggestion-text {
  color: var(--accent-color);
}

.popularity-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--accent-color);
  color: white;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 12px;
  position: relative;
  z-index: 1;
}

/* ==================== MESSAGE BUBBLES ==================== */
.message-wrapper {
  display: flex;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  animation: messageSlideIn 0.3s ease-out;
}

/* Nascondi i messaggi di sistema che contengono solo contesto link (commenti HTML) */
.message-wrapper.system {
  display: none !important;
}

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

.message-wrapper.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

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

.assistant-avatar {
  background: var(--bg-tertiary);
  color: var(--accent-color);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .assistant-avatar {
  background: var(--bg-surface);
}

.admin-badge {
  color: var(--gradient-middle);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.message-container {
  flex: 1;
  max-width: 800px;
}

.message-bubble {
  padding: 16px 20px;
  border-radius: var(--border-radius-lg);
  line-height: 1.7;
}

.message-bubble.user {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 4px var(--border-radius-lg);
}

[data-theme="dark"] .message-bubble.user {
  background: #21262D;
  color: #F0F6FC;
}

.message-bubble.assistant {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) var(--border-radius-lg) 4px;
}

[data-theme="dark"] .message-bubble.assistant {
  background: var(--bg-surface);
}

/* Message Content Styling */
.message-bubble.assistant p {
  margin: 14px 0;
}

.message-bubble.assistant p:first-child {
  margin-top: 0;
}

.message-bubble.assistant p:last-child {
  margin-bottom: 0;
}

.message-bubble.assistant ul,
.message-bubble.assistant ol {
  margin: 16px 0;
  padding-left: 28px;
}

.message-bubble.assistant li {
  margin: 10px 0;
  line-height: 1.6;
}

.message-bubble.assistant h1,
.message-bubble.assistant h2,
.message-bubble.assistant h3,
.message-bubble.assistant h4 {
  color: var(--accent-color);
  margin-top: 20px;
  margin-bottom: 12px;
}

.message-bubble.assistant h1:first-child,
.message-bubble.assistant h2:first-child {
  margin-top: 0;
}

/* Code blocks */
.message-bubble.assistant pre {
  margin: 16px 0;
  padding: 16px;
  background: #0D1117;
  border-radius: var(--border-radius);
  overflow-x: auto;
  border: 1px solid var(--border-color);
  position: relative;
}

.message-bubble.assistant code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  color: #F0F6FC;
}

.message-bubble.assistant pre code {
  background: none;
  padding: 0;
}

.message-bubble.assistant :not(pre) > code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-color);
  font-size: 0.9em;
}

[data-theme="dark"] .message-bubble.assistant :not(pre) > code {
  background: rgba(129, 140, 248, 0.1);
}

/* Code copy button */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 6px;
  color: #8B949E;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.lang-badge,
.code-language-badge {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 11px;
  color: #818CF8;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  background: rgba(129, 140, 248, 0.15);
  border-radius: 4px;
  border: 1px solid rgba(129, 140, 248, 0.3);
}

/* Links */
.message-bubble.assistant a {
  color: var(--accent-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.message-bubble.assistant a:hover {
  border-bottom-color: var(--accent-color);
}

/* Blockquotes */
.message-bubble.assistant blockquote {
  margin: 16px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--accent-color);
  background: var(--accent-light);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  color: var(--text-primary);
}

/* Horizontal rules */
.message-bubble.assistant hr {
  margin: 24px 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

em {
  font-style: italic;
}

/* Math formulas */
.katex-display {
  margin: 20px 0;
  overflow-x: auto;
}

.katex {
  font-size: 1.1em;
}

/* ==================== TABLES ==================== */
.streaming-content table,
.message-content table,
.message-bubble table,
.formatted-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  font-size: 14px;
}

[data-theme="dark"] .streaming-content table,
[data-theme="dark"] .message-content table,
[data-theme="dark"] .message-bubble table,
[data-theme="dark"] .formatted-table {
  background: #0D1117;
  border-color: #30363D;
}

.streaming-content thead,
.message-content thead,
.message-bubble thead,
.formatted-table thead {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .streaming-content thead,
[data-theme="dark"] .message-content thead,
[data-theme="dark"] .message-bubble thead,
[data-theme="dark"] .formatted-table thead {
  background: #161B22;
}

.streaming-content th,
.message-content th,
.message-bubble th,
.formatted-table th {
  color: var(--text-primary);
  font-weight: 600;
  padding: 14px 18px;
  text-align: left;
  border-bottom: 2px solid var(--accent-color);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.streaming-content td,
.message-content td,
.message-bubble td,
.formatted-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  line-height: 1.5;
}

.streaming-content tbody tr:last-child td,
.message-content tbody tr:last-child td,
.message-bubble tbody tr:last-child td,
.formatted-table tbody tr:last-child td {
  border-bottom: none;
}

.streaming-content tbody tr:nth-child(even) td,
.message-content tbody tr:nth-child(even) td,
.message-bubble tbody tr:nth-child(even) td,
.formatted-table tbody tr:nth-child(even) td {
  background: var(--bg-tertiary);
}

.streaming-content tbody tr:hover td,
.message-content tbody tr:hover td,
.message-bubble tbody tr:hover td,
.formatted-table tbody tr:hover td {
  background: var(--bg-hover);
}

/* ==================== MESSAGE FEEDBACK ==================== */
.message-feedback {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-tertiary);
}

.feedback-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.feedback-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.feedback-btn.clicked {
  animation: feedbackPulse 0.3s ease;
}

@keyframes feedbackPulse {
  50% { transform: scale(1.2); }
}

.feedback-btn.active-positive {
  background: rgba(63, 185, 80, 0.15);
  border-color: var(--success-color);
  color: var(--success-color);
}

.feedback-btn.active-negative {
  background: rgba(248, 81, 73, 0.15);
  border-color: var(--danger-color);
  color: var(--danger-color);
}

/* ========================================
   TRAIN KB - Admin Knowledge Base Training
   ======================================== */

/* Train KB Button in feedback row */
.feedback-btn.train-kb-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  color: white;
}

.feedback-btn.train-kb-btn:hover {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
  border-color: #5a67d8;
  color: white;
  transform: scale(1.05);
}

.feedback-btn.train-kb-btn svg {
  stroke: white;
}

/* Train KB Modal */
.train-kb-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.train-kb-modal.active {
  opacity: 1;
  visibility: visible;
}

.train-kb-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.train-kb-content {
  position: relative;
  background: var(--bg-secondary);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  width: 90%;
  max-width: 550px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.train-kb-modal.active .train-kb-content {
  transform: scale(1) translateY(0);
}

.train-kb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.train-kb-header h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.train-kb-header h3 svg {
  color: #667eea;
}

.train-kb-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s ease;
}

.train-kb-close:hover {
  color: var(--danger-color);
}

.train-kb-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.train-kb-preview {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.train-kb-section {
  margin-bottom: 16px;
}

.train-kb-section:last-child {
  margin-bottom: 0;
}

.train-kb-section label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.train-kb-text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  max-height: 100px;
  overflow-y: auto;
}

.train-kb-options {
  margin-bottom: 20px;
}

.train-kb-options label {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.train-kb-options select {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.train-kb-options select:focus {
  outline: none;
  border-color: #667eea;
}

.train-kb-options small {
  display: block;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.train-kb-info {
  background: rgba(102, 126, 234, 0.08);
  border-radius: 10px;
  padding: 16px;
  border-left: 3px solid #667eea;
}

.train-kb-info p {
  margin: 0 0 8px 0;
  color: var(--text-primary);
}

.train-kb-info ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
}

.train-kb-info li {
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.train-kb-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.train-kb-btn-cancel {
  flex: 1;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.train-kb-btn-cancel:hover {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
}

.train-kb-btn-confirm {
  flex: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.train-kb-btn-confirm:hover:not(:disabled) {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.train-kb-btn-confirm:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.train-kb-btn-confirm .btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.train-kb-btn-confirm .spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 600px) {
  .train-kb-content {
    width: 95%;
    max-height: 90vh;
    border-radius: 12px;
  }

  .train-kb-header {
    padding: 16px 20px;
  }

  .train-kb-body {
    padding: 20px;
  }

  .train-kb-footer {
    flex-direction: column;
    padding: 16px 20px;
  }

  .train-kb-btn-cancel,
  .train-kb-btn-confirm {
    flex: none;
    width: 100%;
  }
}

/* Summary Download Button */
.summary-download-container {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.summary-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent-color), #5a67d8);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.summary-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.summary-download-btn:active {
  transform: translateY(0);
}

.summary-download-btn svg {
  width: 16px;
  height: 16px;
}

.summary-download-btn.loading {
  background: linear-gradient(135deg, #6b7280, #9ca3af);
  cursor: wait;
  pointer-events: none;
}

.summary-download-btn.loading svg {
  animation: spin 1s linear infinite;
}

.summary-download-btn.success {
  background: linear-gradient(135deg, #10b981, #059669);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.copy-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
  animation: fadeIn 0.3s ease;
}

.typing-dots {
  display: flex;
  gap: 6px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  width: fit-content;
}

.typing-dot {
  width: 10px;
  height: 10px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDots {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ==================== MULTI-AGENT INDICATOR v3.4 ==================== */
.multi-agent-indicator {
  animation: fadeIn 0.3s ease;
}

.multi-agent-indicator .message-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 16px 20px;
  min-width: 280px;
}

.multi-agent-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.multi-agent-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.multi-agent-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.multi-agent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.multi-agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-md);
  transition: all 0.3s ease;
}

.multi-agent-item.completed {
  background: rgba(var(--success-rgb, 52, 199, 89), 0.1);
}

.multi-agent-item.error {
  background: rgba(var(--error-rgb, 255, 69, 58), 0.1);
}

.agent-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.agent-label {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
}

.agent-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: agentSpin 0.8s linear infinite;
}

.multi-agent-item.completed .agent-spinner,
.multi-agent-item.error .agent-spinner {
  border: none;
  animation: none;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes agentSpin {
  to { transform: rotate(360deg); }
}

/* Streaming Content */
.streaming-message {
  position: relative;
}

.streaming-content {
  display: inline;
  line-height: 1.7;
}

.cursor-blink {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-color);
  margin-left: 2px;
  animation: blink 1s infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ==================== STREAMING SKELETON ==================== */
.streaming-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.08) 0%,
    rgba(0, 0, 0, 0.12) 50%,
    rgba(0, 0, 0, 0.08) 100%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.skeleton-line-1 { width: 90%; }
.skeleton-line-2 { width: 75%; }
.skeleton-line-3 { width: 60%; }

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Dark mode skeleton */
[data-theme="dark"] .skeleton-line {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.06) 100%
  );
  background-size: 200% 100%;
}

/* ==================== SKELETON WITH THINKING MESSAGE ==================== */
.skeleton-thinking-message {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 0;
}

.skeleton-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: skeletonSpin 0.8s linear infinite;
}

@keyframes skeletonSpin {
  to { transform: rotate(360deg); }
}

.skeleton-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: opacity 0.2s ease;
}

[data-theme="dark"] .skeleton-text {
  color: var(--text-secondary);
}

.skeleton-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==================== INTELLIGENT SEARCH LOADER (Premium Design) ==================== */
.intelligent-search-loader {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px;
  background: linear-gradient(135deg,
    rgba(102, 126, 234, 0.08) 0%,
    rgba(118, 75, 162, 0.08) 50%,
    rgba(236, 72, 153, 0.05) 100%);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 16px;
  margin: 4px 0;
  animation: loaderAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.intelligent-search-loader::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%);
  animation: shimmerEffect 2s ease-in-out infinite;
}

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

@keyframes shimmerEffect {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Header row with icon and title */
.intelligent-search-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.intelligent-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
  border: 1px solid rgba(102, 126, 234, 0.25);
  color: #667eea;
  flex-shrink: 0;
  animation: iconPulse 2s ease-in-out infinite;
  transition: all 0.3s ease;
}

@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.3);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 8px rgba(102, 126, 234, 0);
  }
}

.intelligent-search-icon svg {
  width: 22px;
  height: 22px;
  stroke: #667eea;
  stroke-width: 1.5;
  fill: none;
  animation: searchScan 2.5s ease-in-out infinite;
}

@keyframes searchScan {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

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

.intelligent-search-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.intelligent-search-subtitle {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
  opacity: 0;
  animation: fadeSlideIn 0.4s ease forwards 0.2s;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Progress section */
.intelligent-search-progress-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.intelligent-search-progress {
  height: 6px;
  background: rgba(102, 126, 234, 0.15);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-bar-animated {
  height: 100%;
  background: linear-gradient(90deg,
    #667eea 0%,
    #764ba2 25%,
    #ec4899 50%,
    #764ba2 75%,
    #667eea 100%);
  background-size: 300% 100%;
  border-radius: 3px;
  animation: progressFlow 2s linear infinite, progressGrow 8s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.4);
}

@keyframes progressFlow {
  0% { background-position: 100% 0; }
  100% { background-position: 0% 0; }
}

@keyframes progressGrow {
  0%, 100% { width: 20%; margin-left: 0; }
  25% { width: 40%; margin-left: 10%; }
  50% { width: 30%; margin-left: 35%; }
  75% { width: 45%; margin-left: 25%; }
}

/* Phases animation */
.intelligent-search-phases {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-phase {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(102, 126, 234, 0.08);
  border: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  opacity: 0.6;
  transition: all 0.3s ease;
}

.search-phase svg {
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.search-phase.active {
  opacity: 1;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
  border-color: rgba(102, 126, 234, 0.3);
  color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.search-phase.completed {
  opacity: 1;
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.search-phase.completed .search-phase-icon svg {
  display: none;
}

.search-phase.completed .search-phase-icon::after {
  content: '✓';
  font-size: 11px;
  font-weight: 600;
}

.search-phase-icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-phase.active .search-phase-icon {
  animation: iconSpin 1.2s linear infinite;
}

@keyframes iconSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Floating particles effect */
.intelligent-search-loader .particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 50%;
  opacity: 0.5;
  animation: particleFloat 3s ease-in-out infinite;
}

.intelligent-search-loader .particle:nth-child(1) {
  top: 20%;
  right: 15%;
  animation-delay: 0s;
}

.intelligent-search-loader .particle:nth-child(2) {
  top: 60%;
  right: 8%;
  animation-delay: 0.5s;
}

.intelligent-search-loader .particle:nth-child(3) {
  top: 80%;
  right: 20%;
  animation-delay: 1s;
}

@keyframes particleFloat {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-15px) scale(1.3);
    opacity: 0.2;
  }
}

/* Dark theme adjustments */
[data-theme="dark"] .intelligent-search-loader {
  background: linear-gradient(135deg,
    rgba(102, 126, 234, 0.12) 0%,
    rgba(118, 75, 162, 0.12) 50%,
    rgba(236, 72, 153, 0.08) 100%);
  border-color: rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .intelligent-search-title {
  background: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="dark"] .intelligent-search-icon {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
  border-color: rgba(102, 126, 234, 0.35);
}

[data-theme="dark"] .intelligent-search-icon svg {
  stroke: #818cf8;
}

[data-theme="dark"] .search-phase.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
  color: #818cf8;
}

/* ==================== THINKING LOADER (Modern Style) ==================== */
.thinking-loader {
  display: flex;
  justify-content: flex-start;
  padding: 16px 20px;
  animation: fadeIn 0.3s ease;
}

.thinking-loader-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Dark mode adjustments */
[data-theme="dark"] .thinking-loader-content {
  background: var(--bg-tertiary, #2d2d2d);
  border-color: var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.thinking-spinner {
  color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinking-spinner svg {
  width: 20px;
  height: 20px;
}

.thinking-text {
  font-size: 14px;
  color: var(--text-secondary);
  transition: opacity 0.2s ease;
  font-weight: 400;
}

/* Legacy support - hide old dots if present */
.thinking-dots {
  display: none;
}

/* Inline Thinking Loader - for fallback processing phases */
.inline-thinking-loader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 12px 0;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary, var(--bg-secondary)) 100%);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-color);
  border-radius: var(--border-radius);
  animation: fadeIn 0.3s ease, pulseGlow 2s infinite;
}

.inline-thinking-loader .thinking-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.inline-thinking-loader .thinking-message {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb, 74, 144, 226), 0.2);
  }
  50% {
    box-shadow: 0 0 8px 2px rgba(var(--accent-rgb, 74, 144, 226), 0.3);
  }
}

/* ==================== INPUT AREA ==================== */
.input-container {
  padding: 16px 24px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

.input-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.textarea-wrapper {
  width: 100%;
  position: relative;
}

.message-input {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  font-family: inherit;
  min-height: 100px;
  max-height: 300px;
  overflow-y: auto;
  transition: all 0.3s ease;
}

.message-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}

[data-theme="dark"] .message-input {
  background: var(--bg-surface);
}

.message-input::placeholder {
  color: var(--text-tertiary);
}

.input-buttons-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.input-buttons-left {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Uniform style for all action buttons in input area */
.input-buttons-left .action-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.input-buttons-left .action-button svg {
  width: 18px;
  height: 18px;
}

.input-buttons-left .action-button:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-1px);
}

.input-buttons-left .action-button:active {
  transform: translateY(0) scale(0.95);
}

.input-buttons-left .action-button.active {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

[data-theme="dark"] .input-buttons-left .action-button {
  background: #161B22;
  border-color: #30363D;
  color: #8B949E;
}

[data-theme="dark"] .input-buttons-left .action-button:hover {
  background: #21262D;
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.input-buttons-right {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-left: auto;
}

.char-counter {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 0 8px;
}

.char-counter.warning {
  color: var(--warning-color);
}

.char-counter.danger {
  color: var(--danger-color);
}

/* Attach Button */
.attach-button {
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  width: 36px;
  flex-shrink: 0;
}

.attach-button.admin-only {
  display: flex !important;
}

.attach-button:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-color);
}

/* Send Button */
.send-button {
  width: 44px;
  height: 44px;
  background: var(--accent-color);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.1);
  box-shadow: var(--shadow-glow);
}

.send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg-tertiary);
  box-shadow: none;
}

.send-button:active:not(:disabled) {
  transform: scale(0.95);
}

.send-button .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Voice Button */
.voice-button {
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.voice-button:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.voice-button.recording {
  background: rgba(248, 81, 73, 0.15);
  border-color: var(--danger-color);
  color: var(--danger-color);
  animation: pulse 1s infinite;
}

.voice-timer {
  font-size: 12px;
  color: var(--danger-color);
  font-weight: 600;
  font-family: 'Fira Code', monospace;
}

.input-info {
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ==================== COT COMPACT BUTTON ==================== */
.cot-button-wrapper {
  position: relative;
}

.cot-button {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  font-weight: 600;
  min-width: 36px;
  transition: all 0.3s ease;
}

.cot-button .cot-icon {
  color: var(--text-tertiary);
  transition: all 0.3s ease;
}

.cot-button.active {
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-middle) 100%);
  border-color: transparent;
  box-shadow: 0 0 12px rgba(129, 140, 248, 0.4);
}

.cot-button.active .cot-icon {
  color: white;
}

.cot-button:hover:not(.active) {
  border-color: var(--accent-color);
}

.cot-button:hover:not(.active) .cot-icon {
  color: var(--accent-color);
}

/* COT Dropdown Menu */
.cot-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 8px;
  z-index: 100;
  animation: dropdownFadeIn 0.2s ease;
}

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

.cot-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.cot-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.cot-dropdown-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.cot-info-link {
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
  padding-top: 12px;
}

.cot-info-link svg {
  color: var(--text-tertiary);
}

.cot-info-link:hover svg {
  color: var(--accent-color);
}

/* Legacy COT styles - hidden */
.cot-controls-wrapper {
  display: none;
}

.cot-toggle-container {
  display: none;
}

.cot-toggle-label {
  display: none;
}

.cot-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cot-toggle-slider {
  display: none;
}

.cot-label-text {
  display: none;
}

/* ==================== KB DIRECT BUTTON (v2.3) ==================== */
/* Direct Knowledge Base query - bypasses router for ~80% faster responses */
.kb-direct-button-wrapper {
  position: relative;
}

.kb-direct-button {
  min-width: 36px;
  transition: all 0.3s ease;
}

.kb-direct-button svg {
  color: var(--text-tertiary);
  transition: all 0.3s ease;
}

.kb-direct-button.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: transparent;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.kb-direct-button.active svg {
  color: white;
}

.kb-direct-button:hover:not(.active) {
  border-color: #10b981;
}

.kb-direct-button:hover:not(.active) svg {
  color: #10b981;
}

/* KB Direct indicator in chat */
.kb-direct-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px;
  font-size: 11px;
  color: #10b981;
  margin-left: 8px;
}

.kb-direct-indicator svg {
  width: 12px;
  height: 12px;
}

[data-theme="dark"] .kb-direct-button:hover:not(.active) {
  border-color: #34d399;
}

[data-theme="dark"] .kb-direct-button:hover:not(.active) svg {
  color: #34d399;
}

/* v3.4.10: Force Multi-Agent Button */
.force-ma-button-wrapper {
  position: relative;
}

.force-ma-button {
  min-width: 36px;
  transition: all 0.3s ease;
}

.force-ma-button svg {
  color: var(--text-tertiary);
  transition: all 0.3s ease;
}

.force-ma-button.active {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  border-color: transparent;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

.force-ma-button.active svg {
  color: white;
}

.force-ma-button:hover:not(.active) {
  border-color: #8b5cf6;
}

.force-ma-button:hover:not(.active) svg {
  color: #8b5cf6;
}

[data-theme="dark"] .force-ma-button:hover:not(.active) {
  border-color: #a78bfa;
}

[data-theme="dark"] .force-ma-button:hover:not(.active) svg {
  color: #a78bfa;
}

.cot-info-button {
  padding: 6px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
}

.cot-info-button:hover {
  background: var(--bg-hover);
  color: var(--accent-color);
}

.cot-reasoning-container {
  display: none;
}

.cot-sub-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}

.cot-sub-option input[type="checkbox"] {
  cursor: pointer;
}

.cot-status {
  margin-left: auto;
  padding: 6px 14px;
  background: var(--accent-light);
  border-radius: 8px;
  font-size: 13px;
  color: var(--accent-color);
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

/* COT Display */
.cot-reasoning-section {
  margin: 20px 0;
  padding: 16px;
  background: var(--accent-light);
  border-left: 4px solid var(--accent-color);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  animation: slideInEffect 0.5s ease;
}

.cot-reasoning-section h3 {
  color: var(--accent-color);
  margin: 0 0 12px 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cot-final-answer {
  margin: 20px 0;
  padding: 16px;
  background: rgba(210, 153, 34, 0.1);
  border-left: 4px solid var(--warning-color);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  animation: slideInEffect 0.5s ease;
}

.cot-final-answer h3 {
  color: var(--warning-color);
  margin: 0 0 12px 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cot-info-content {
  padding: 8px;
}

.cot-info-content h4 {
  color: var(--text-primary);
  margin: 20px 0 12px 0;
  font-size: 16px;
}

.cot-info-content h4:first-child {
  margin-top: 0;
}

.cot-info-content p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 12px 0;
}

.cot-info-content ul,
.cot-info-content ol {
  margin: 12px 0;
  padding-left: 24px;
}

.cot-info-content li {
  color: var(--text-secondary);
  margin: 8px 0;
  line-height: 1.6;
}

.cot-info-tip {
  margin-top: 20px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border-left: 3px solid var(--accent-color);
  font-size: 14px;
  color: var(--success-color);
}

.cot-reasoning-display {
  background: var(--accent-light);
  border-left: 4px solid var(--accent-color);
  padding: 16px;
  margin: 12px 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.cot-step {
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border-left: 3px solid var(--accent-color);
}

.cot-step .step-number {
  color: var(--accent-color);
  font-weight: 600;
  margin-right: 8px;
}

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.8);
}

.modal-overlay.active,
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xl);
  padding: 28px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .modal {
  background: var(--bg-secondary);
}

.modal-overlay.active .modal,
.modal-overlay.show .modal {
  transform: scale(1) translateY(0);
}

.modal-large {
  max-width: 800px;
  display: flex;
  flex-direction: column;
}

/* Fix scroll for modal-large: only body scrolls, header/footer stay fixed */
.modal-large .modal-body {
  flex: 1;
  overflow-y: auto;
  max-height: calc(85vh - 160px); /* Account for header and footer */
}

.modal-large .modal-footer {
  flex-shrink: 0;
}

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

.modal-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-middle) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-close {
  padding: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bg-hover);
  border-color: var(--danger-color);
  color: var(--danger-color);
}

.modal-body {
  margin-bottom: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--border-radius);
}

.tab-button {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-button.active {
  background: var(--bg-surface);
  color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ==================== MODEL INFO MODAL ==================== */
.model-info-content {
  color: var(--text-primary);
  line-height: 1.7;
}

.model-info-content h3 {
  color: var(--accent-color);
  font-size: 18px;
  margin: 28px 0 14px 0;
  font-weight: 600;
}

.model-info-content h3:first-child {
  margin-top: 0;
}

.model-info-content p {
  margin: 14px 0;
  color: var(--text-secondary);
}

.model-info-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.model-features-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.model-features-list li {
  padding: 10px 0 10px 32px;
  position: relative;
  color: var(--text-secondary);
}

.model-features-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success-color);
  font-weight: bold;
  font-size: 16px;
}

.model-specs {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 18px;
  margin: 16px 0;
}

[data-theme="dark"] .model-specs {
  background: var(--bg-contrasto);
}

.model-specs-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

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

.model-specs-label {
  color: var(--text-tertiary);
  font-size: 14px;
}

.model-specs-value {
  color: var(--accent-color);
  font-weight: 600;
  font-size: 14px;
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: 20px;
}

.form-group label,
.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input,
.search-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.3s ease;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .search-input {
  background: var(--input-bg);
}

.form-input:focus,
.search-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

.form-error {
  font-size: 12px;
  color: var(--danger-color);
  margin-top: 6px;
  display: none;
}

.form-error.show {
  display: block;
}

.form-input.error {
  border-color: var(--danger-color);
}

/* ==================== BUTTONS ==================== */
.btn {
  padding: 12px 24px;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .btn-secondary {
  background: var(--bg-tertiary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent-color);
}

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

.btn-danger:hover:not(:disabled) {
  background: #d63031;
  transform: translateY(-2px);
}

.btn-warning {
  background: var(--bg-tertiary);
  color: var(--accent-color);
  border: 1px solid var(--accent-color);
}

.btn-warning:hover:not(:disabled) {
  background: var(--accent-light);
  transform: translateY(-2px);
}

.btn-export {
  background: var(--bg-tertiary);
  color: #22c55e;
  border: 1px solid #22c55e;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-export:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.1);
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Modal Action Buttons */
.btn-cancel,
.btn-analyze {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-cancel:hover {
  background: var(--bg-hover);
}

.btn-analyze {
  background: var(--accent-color);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-analyze:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-analyze:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== VIDEO UPLOAD MODAL ==================== */
.video-modal {
  max-width: 700px;
}

.video-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.video-tab {
  padding: 12px 24px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.video-tab:hover {
  color: var(--text-primary);
}

.video-tab.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
}

.video-tab-content {
  display: none;
}

.video-tab-content.active {
  display: block;
}

.video-upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-tertiary);
  margin-bottom: 24px;
}

.video-upload-zone:hover,
.video-upload-zone.drag-over {
  border-color: var(--accent-color);
  background: var(--accent-light);
  transform: scale(1.02);
}

.video-upload-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.video-upload-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.video-upload-subtext {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.video-upload-formats {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.video-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.video-options label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.video-options select {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.video-options select:focus {
  outline: none;
  border-color: var(--accent-color);
}

[data-theme="dark"] .video-options select {
  background: var(--input-bg);
}

.video-url-section {
  margin-bottom: 24px;
}

.video-url-section label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.video-url-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.video-url-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

[data-theme="dark"] .video-url-input {
  background: var(--input-bg);
}

.video-url-examples {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

.video-submit-btn {
  width: 100%;
  padding: 12px 24px;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 16px;
}

.video-submit-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.video-submit-btn:active {
  transform: translateY(0);
}

/* Video Progress */
#video-progress-section {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-contrasto);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.video-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.video-progress-header strong {
  color: var(--text-primary);
  font-size: 14px;
}

.video-status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-uploading,
.status-downloading,
.status-processing,
.status-transcribing {
  background: var(--info-color);
  color: white;
}

.status-indexing {
  background: var(--gradient-middle);
  color: white;
}

.status-completed {
  background: var(--success-color);
  color: white;
}

.status-failed {
  background: var(--danger-color);
  color: white;
}

.video-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.video-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gradient-start), var(--gradient-middle));
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.video-progress-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.video-result-success {
  margin-top: 16px;
  padding: 16px;
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid var(--success-color);
  border-radius: 8px;
  color: var(--success-color);
  font-size: 14px;
  font-weight: 500;
}

[data-theme="dark"] .video-result-success {
  background: rgba(63, 185, 80, 0.15);
}

.video-result-stats {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.video-result-stats ul {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
}

.video-result-stats li {
  padding: 4px 0;
}

/* ==================== STATS & CARDS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--accent-color);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==================== SEARCH RESULTS ==================== */
.search-section {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.search-help-text {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  font-style: italic;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--bg-hover);
  background: var(--bg-tertiary);
}

.search-result-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  transform: translateX(4px);
}

[data-theme="dark"] .search-result-item {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

[data-theme="dark"] .search-result-item:hover {
  background: var(--bg-hover);
}

.search-result-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.search-result-snippet {
  font-size: 13px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.search-enhanced-badge {
  display: inline-block;
  background: var(--accent-color);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: 8px;
}

/* ==================== DEEP SEARCH ==================== */
.deep-search-btn {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 50%;
  cursor: pointer;
  margin-right: 10px;
  font-size: 18px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.deep-search-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
  box-shadow: var(--shadow-glow);
}

.deep-search-btn:active {
  transform: scale(0.95);
}

.deep-search-result {
  background: var(--bg-secondary);
  border-left: 4px solid var(--gradient-middle);
  margin: 15px 0;
  padding: 15px;
  border-radius: 8px;
}

.result {
  padding: 12px;
  margin: 10px 0;
  background: var(--bg-surface);
  border-radius: 6px;
  border-left: 4px solid var(--border-color);
  transition: all 0.3s ease;
}

.result:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(5px);
}

.local-result {
  border-left-color: var(--success-color);
  background: rgba(63, 185, 80, 0.05);
}

.web-result {
  border-left-color: var(--info-color);
  background: rgba(88, 166, 255, 0.05);
}

.result strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 5px;
}

.result small {
  color: var(--text-tertiary);
  font-style: italic;
}

.result a {
  color: var(--info-color);
  text-decoration: none;
  font-weight: 500;
}

.result a:hover {
  text-decoration: underline;
}

/* ==================== MULTI-DOCUMENT ANALYSIS ==================== */
/* #multi-doc-button uses .action-button base styles */

.multi-doc-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.multi-doc-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.multi-doc-modal-content {
  background: var(--bg-surface);
  border-radius: var(--border-radius-xl);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

[data-theme="dark"] .multi-doc-modal-content {
  background: var(--bg-secondary);
}

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

.multi-doc-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.multi-doc-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.multi-doc-close:hover {
  background: var(--bg-middle);
  color: var(--text-primary);
}

.multi-doc-body {
  padding: 24px;
}

.multi-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 40px 20px;
  text-align: center;
  margin-bottom: 20px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.multi-upload-area:hover {
  border-color: var(--accent-color);
  background: var(--accent-light);
}

[data-theme="dark"] .multi-upload-area:hover {
  background: rgba(129, 140, 248, 0.1);
}

.multi-upload-area.dragover {
  border-color: var(--accent-color);
  background: var(--accent-light);
  transform: scale(1.02);
}

.multi-upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-secondary);
}

.multi-upload-text {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
}

.multi-upload-subtext {
  color: var(--text-secondary);
  font-size: 14px;
}

.multi-upload-input {
  display: none;
}

.multi-file-list {
  max-height: 250px;
  overflow-y: auto;
  margin: 20px 0;
  padding: 4px;
}

.multi-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin: 8px 0;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
  background: var(--bg-tertiary);
}

.multi-file-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
}

[data-theme="dark"] .multi-file-item {
  background: var(--bg-tertiary);
}

.multi-file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.multi-file-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: 6px;
  color: var(--accent-color);
}

.multi-file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multi-file-size {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 8px;
  background: var(--bg-surface);
  border-radius: 4px;
}

.multi-file-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.multi-file-remove:hover {
  background: rgba(248, 81, 73, 0.1);
  color: var(--danger-color);
}

.multi-analysis-options {
  margin: 24px 0;
  padding: 20px;
  border-radius: 8px;
  background: var(--bg-tertiary);
}

.multi-analysis-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.analysis-type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.analysis-type-option {
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-surface);
}

.analysis-type-option:hover {
  border-color: var(--accent-color);
  background: var(--accent-light);
}

.analysis-type-option.selected {
  border-color: var(--accent-color);
  background: var(--accent-light);
}

.analysis-type-option input[type="radio"] {
  display: none;
}

.analysis-type-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.analysis-type-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-color);
  flex-shrink: 0;
  margin-top: 2px;
}

.analysis-type-content {
  flex: 1;
}

.analysis-type-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.analysis-type-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  border-radius: 0 0 var(--border-radius-xl) var(--border-radius-xl);
}
/* ==================== ANALYSIS RESULT ==================== */
.analysis-result {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  margin: 10px 0;
}

[data-theme="dark"] .analysis-result {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.15) 0%, rgba(124, 58, 237, 0.15) 100%);
  border-color: rgba(129, 140, 248, 0.3);
}

.analysis-result h3 {
  color: var(--text-primary);
  margin: 0 0 15px 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.analysis-info {
  background: var(--bg-surface);
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
}

[data-theme="dark"] .analysis-info {
  background: rgba(0, 0, 0, 0.3);
}

.analysis-info p {
  margin: 8px 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.analysis-info strong {
  color: var(--text-primary);
  font-weight: 600;
}

.download-btn-chat {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.download-btn-chat:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

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

.download-btn-chat svg {
  width: 16px;
  height: 16px;
}

.result-actions {
  margin: 20px 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.message[data-analysis-message="true"] {
  background: var(--bg-surface);
  border-left: 3px solid var(--accent-color);
  animation: slideInLeft 0.3s ease;
}

.analysis-description {
  margin-top: 16px;
  padding: 12px;
  background: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.analysis-description strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ==================== PROGRESS & STATUS ==================== */
.bulk-progress {
  padding: 15px;
  background: rgba(88, 166, 255, 0.1);
  border-radius: 8px;
  margin: 10px 0;
}

[data-theme="dark"] .bulk-progress {
  background: rgba(88, 166, 255, 0.15);
}

.progress-header {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.progress-bar-container {
  width: 100%;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  overflow: hidden;
  margin: 10px 0;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gradient-start), var(--gradient-middle));
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 500;
  font-size: 12px;
}

.progress-container {
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
  display: none;
  background: var(--bg-secondary);
}

.progress-container.active {
  display: block;
}

.progress-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.progress-percentage {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-color);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gradient-start), var(--gradient-middle), var(--gradient-end));
  border-radius: 4px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.status-message {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.status-message.success {
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
  color: var(--success-color);
}

.status-message.error {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--danger-color);
}

.status-message.info {
  background: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--info-color);
}

.status-phases {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  opacity: 0.5;
  transition: all 0.3s ease;
}

.phase.active {
  opacity: 1;
  border-color: var(--accent-color);
  background: var(--accent-light);
}

.phase-icon {
  font-size: 24px;
}

.phase-text {
  font-size: 11px;
  text-align: center;
  color: var(--text-secondary);
}

/* ==================== LINK DETECTION ==================== */
.link-detected {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: var(--accent-light);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.link-detected:hover {
  background: rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .link-detected {
  background: rgba(129, 140, 248, 0.15);
}

[data-theme="dark"] .link-detected:hover {
  background: rgba(129, 140, 248, 0.25);
}

.detected-link {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.detected-link:hover {
  text-decoration: underline;
}

.link-indicator {
  display: inline-block;
  font-size: 14px;
  opacity: 0.8;
  animation: pulseLink 2s infinite;
}

@keyframes pulseLink {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.message-bubble.contains-links {
  position: relative;
}

.message-bubble.contains-links::before {
  content: "🔗";
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 12px;
  opacity: 0.6;
}

.link-analysis-status {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  animation: slideInEffect 0.3s ease;
}

.link-status-analyzing {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(210, 153, 34, 0.1);
  color: var(--warning-color);
  padding: 6px 10px;
  border-radius: 4px;
}

[data-theme="dark"] .link-status-analyzing {
  background: rgba(210, 153, 34, 0.2);
}

.link-status-completed {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(63, 185, 80, 0.1);
  color: var(--success-color);
  padding: 6px 10px;
  border-radius: 4px;
}

[data-theme="dark"] .link-status-completed {
  background: rgba(63, 185, 80, 0.2);
}

.link-status-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(248, 81, 73, 0.1);
  color: var(--danger-color);
  padding: 6px 10px;
  border-radius: 4px;
}

[data-theme="dark"] .link-status-error {
  background: rgba(248, 81, 73, 0.2);
}

.status-icon {
  font-size: 16px;
  animation: rotateIcon 1s linear infinite;
}

.link-status-completed .status-icon {
  animation: none;
}

.status-text {
  font-size: 13px;
  font-weight: 500;
}

.link-analyzing-loader {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(63, 185, 80, 0.3);
  border-top-color: var(--success-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 8px;
}

.temp-content-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--gradient-middle) 0%, var(--gradient-end) 100%);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 8px;
}

.message-from-link {
  animation: highlightNew 2s ease;
}

/* ==================== NOTIFICATIONS ==================== */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 20px;
  border-radius: 8px;
  border-left: 4px solid;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
  transform: translateX(400px);
  transition: transform 0.3s ease;
  z-index: 2000;
}

.notification.show {
  transform: translateX(0);
}

.notification.success {
  border-color: var(--success-color);
  background: rgba(63, 185, 80, 0.1);
}

.notification.warning {
  border-color: var(--warning-color);
  background: rgba(210, 153, 34, 0.1);
}

.notification.danger {
  border-color: var(--danger-color);
  background: rgba(248, 81, 73, 0.1);
}

/* ==================== NOTIFICATION TOAST ==================== */
.notification-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10000;
  animation: slideInRight 0.3s ease;
  font-size: 14px;
  font-weight: 500;
  color: white;
}

.notification-toast.notification-success {
  background: linear-gradient(135deg, var(--success-color) 0%, #2ea043 100%);
}

.notification-toast.notification-error,
.notification-toast.notification-danger {
  background: linear-gradient(135deg, var(--danger-color) 0%, #d63031 100%);
}

.notification-toast.notification-warning {
  background: linear-gradient(135deg, var(--warning-color) 0%, #e17f00 100%);
}

.notification-toast.notification-info {
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-middle) 100%);
}

.notification-icon {
  font-size: 18px;
}

.notification-message {
  flex: 1;
}

/* ==================== ALERTS ==================== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
  animation: slideDown 0.3s ease;
}

.alert.show {
  display: block;
}

.alert-danger,
.alert.alert-danger {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.2);
  color: var(--danger-color);
}

.alert-success,
.alert.alert-success {
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.2);
  color: var(--success-color);
}

.alert-warning,
.alert.alert-warning {
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.2);
  color: var(--warning-color);
}

.alert-info,
.alert.alert-info {
  background: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--info-color);
}

/* ==================== SECURITY & ACCESSIBILITY ==================== */
.user-menu,
.action-btn,
.btn {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* ==================== USER MANAGEMENT MODAL ==================== */
#user-management-modal {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#user-management-modal.active {
  display: flex;
  opacity: 1;
}

#user-management-modal .modal {
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

#user-management-modal.active .modal {
  transform: scale(1);
}

/* ==================== SMART DOCUMENT TEMPLATE ==================== */
.smart-info-box {
  background: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
}

[data-theme="dark"] .smart-info-box {
  background: rgba(129, 140, 248, 0.1);
  border-color: rgba(129, 140, 248, 0.3);
}

.info-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.info-content {
  flex: 1;
}

.info-content strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.info-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.info-content li {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
  line-height: 1.5;
}

.smart-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.smart-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.smart-section .step-number,
.section-title .step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent-color);
  color: white;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.template-upload-zone,
.support-upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-tertiary);
}

.template-upload-zone:hover,
.support-upload-zone:hover {
  border-color: var(--accent-color);
  background: var(--accent-light);
}

.template-upload-zone.drag-over,
.support-upload-zone.drag-over {
  border-color: var(--accent-color);
  background: var(--accent-light);
  transform: scale(1.01);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-tertiary);
}

.upload-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

.template-preview {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.preview-icon {
  font-size: 24px;
}

.preview-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-remove {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  line-height: 1;
}

.preview-remove:hover {
  background: var(--danger-color);
  color: white;
}

.analyze-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.analyze-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.template-analysis {
  margin-top: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
}

.template-analysis h5 {
  color: var(--accent-color);
  margin-bottom: 8px;
}

/* Example Templates Section */
.example-templates-section {
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
}

.example-templates-section .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.example-templates-section .step-icon {
  font-size: 20px;
}

.example-templates-section .section-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.template-category {
  margin-bottom: 16px;
}

.template-category:last-child {
  margin-bottom: 0;
}

.category-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.example-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.example-template-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 90px;
}

.example-template-btn:hover {
  border-color: var(--accent-color);
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.example-template-btn:active {
  transform: translateY(0);
}

.example-template-btn .template-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.example-template-btn .template-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.example-template-btn .template-desc {
  font-size: 10px;
  color: var(--text-tertiary);
  line-height: 1.3;
}

/* Dark theme adjustments */
[data-theme="dark"] .example-templates-section {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
}

[data-theme="dark"] .example-template-btn {
  background: var(--bg-secondary);
}

[data-theme="dark"] .example-template-btn:hover {
  background: rgba(16, 163, 127, 0.15);
}

/* Smart Prompt Input */
.smart-prompt-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
  transition: all 0.2s ease;
}

.smart-prompt-input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.smart-prompt-input::placeholder {
  color: var(--text-tertiary);
}

/* ==================== SIDEBAR OVERLAY (Mobile) ==================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

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

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

@keyframes slideInEffect {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

@keyframes slideOut {
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

@keyframes rotateIcon {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes loading {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes loadingShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes highlightMessage {
  0% { background-color: transparent; }
  20% { background-color: var(--accent-light); transform: scale(1.01); }
  40% { background-color: rgba(129, 140, 248, 0.2); transform: scale(1.02); }
  60% { background-color: rgba(129, 140, 248, 0.15); transform: scale(1.01); }
  80% { background-color: var(--accent-light); transform: scale(1); }
  100% { background-color: transparent; transform: scale(1); }
}

@keyframes highlightNew {
  0% {
    background: var(--accent-light);
    border-left-color: var(--accent-color);
    border-left-width: 5px;
  }
  100% {
    background: transparent;
    border-left-color: var(--success-color);
    border-left-width: 3px;
  }
}

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

@keyframes pulseText {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
  }

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

  .sidebar-toggle {
    display: flex;
  }

  .welcome-message {
    margin: 20px auto;
    padding: 0 16px;
  }

  .welcome-message h1 {
    font-size: 32px;
  }

  .welcome-logo {
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
  }

  .welcome-logo::before {
    width: 100px;
    height: 100px;
  }

  .welcome-logo::after {
    width: 80px;
    height: 80px;
  }

  .welcome-logo-core {
    width: 56px;
    height: 56px;
    font-size: 26px;
    border-radius: 14px;
  }

  .welcome-particles {
    width: 160px;
    height: 160px;
  }

  .welcome-message p {
    font-size: 15px;
    margin-bottom: 24px;
  }

  .welcome-features {
    gap: 8px;
    margin-bottom: 24px;
  }

  .welcome-feature {
    padding: 6px 12px;
    font-size: 12px;
  }

  .welcome-subtitle {
    font-size: 13px;
    margin-bottom: 20px;
  }

  .welcome-suggestions {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .suggestion-card {
    padding: 16px 18px;
  }

  .suggestion-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 8px;
  }

  .chat-messages {
    padding: 16px;
    gap: 16px;
  }

  .message-wrapper {
    gap: 10px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .message-bubble {
    padding: 12px 14px;
  }

  .input-container {
    padding: 12px 16px;
  }

  .message-input {
    min-height: 80px;
    padding: 12px 14px;
  }

  .input-buttons-row {
    flex-wrap: wrap;
  }

  .modal {
    width: 95%;
    padding: 20px;
    border-radius: var(--border-radius-lg);
  }

  .modal-tabs {
    flex-direction: column;
  }

  .tab-button {
    text-align: center;
  }

  .status-phases {
    grid-template-columns: repeat(2, 1fr);
  }

  .notification-toast {
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .video-modal {
    max-width: 95%;
    padding: 16px;
  }

  .video-upload-zone {
    padding: 32px 16px;
  }

  .video-upload-icon {
    font-size: 48px;
  }

  .video-options {
    grid-template-columns: 1fr;
  }

  .analysis-type-grid {
    grid-template-columns: 1fr;
  }

  /* Tables scroll on mobile */
  .streaming-content table,
  .message-content table,
  .message-bubble table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .welcome-message h1 {
    font-size: 24px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: 20px;
  }

  .input-buttons-left {
    width: 100%;
    justify-content: flex-start;
  }

  .action-button {
    width: 38px;
    height: 38px;
  }

  .status-phases {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .phase {
    padding: 8px;
  }

  .phase-icon {
    font-size: 20px;
  }

  .phase-text {
    font-size: 10px;
  }
}

/* ==================== PRINT STYLES ==================== */
@media print {
  .sidebar,
  .input-container,
  .main-header,
  .message-feedback,
  .action-button {
    display: none !important;
  }

  .main-content {
    width: 100%;
  }

  .chat-messages {
    overflow: visible;
    padding: 20px;
  }

  .message-bubble {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ==================== ACCESSIBILITY ==================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==================== HIGH CONTRAST MODE ==================== */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000;
  }

  [data-theme="dark"] {
    --border-color: #fff;
  }

  .btn-primary,
  .send-button {
    border: 2px solid currentColor;
  }
}

/* ==================== BADGE COUNT ==================== */
.badge-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  background: var(--danger-color);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ==================== SPINNER ==================== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==================== FILES SUMMARY ==================== */
.files-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.summary-card:hover {
  border-color: var(--accent-color);
  transform: translateY(-2px);
}

.summary-icon {
  font-size: 28px;
}

.summary-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-color);
}

.summary-label {
  font-size: 12px;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .files-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .files-summary {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .summary-card {
    padding: 12px;
    flex-direction: column;
    text-align: center;
  }

  .summary-value {
    font-size: 20px;
  }
}

/* ==================== ADMIN STATS GRID ==================== */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 24px 30px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .admin-stats-grid {
  background: #0D1117;
  border-bottom-color: #30363D;
}

.admin-stat-card {
  text-align: center;
  padding: 20px 16px;
  background: var(--bg-primary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

[data-theme="dark"] .admin-stat-card {
  background: #161B22;
  border-color: #30363D;
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--accent-color);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1;
}

.stat-value.text-warning {
  color: var(--warning-color);
}

.stat-value.text-success {
  color: var(--success-color);
}

.stat-value.text-accent {
  color: var(--accent-color);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==================== FILES LIST (Admin Panel) ==================== */
.files-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
  padding: 4px;
}

.file-item {
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
  cursor: pointer;
}

[data-theme="dark"] .file-item {
  background: #161B22;
  border-color: #30363D;
}

.file-item:hover {
  border-color: var(--accent-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.file-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  word-break: break-word;
}

.file-chunks {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent-color);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* v3.5: File actions container */
.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
}

.file-item:hover .file-delete-btn {
  opacity: 1;
}

.file-delete-btn:hover {
  background: #dc354520;
  color: #dc3545;
}

.file-delete-btn svg {
  width: 16px;
  height: 16px;
}

.file-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.file-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.file-meta-item svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

@media (max-width: 768px) {
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 16px 20px;
    gap: 12px;
  }

  .admin-stat-card {
    padding: 16px 12px;
  }

  .stat-value {
    font-size: 2rem;
  }

  .file-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ==================== USER MANAGEMENT (Admin Panel) ==================== */
#users-container {
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
}

.users-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: all 0.2s ease;
}

[data-theme="dark"] .user-card {
  background: #161B22;
  border-color: #30363D;
}

.user-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .user-card:hover {
  box-shadow: 0 2px 12px rgba(129, 140, 248, 0.1);
}

.user-card.selected {
  border-color: var(--accent-color);
  background: var(--accent-light);
}

[data-theme="dark"] .user-card.selected {
  background: rgba(129, 140, 248, 0.1);
}

.user-card .user-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-color);
  cursor: pointer;
  flex-shrink: 0;
}

.user-card .user-avatar {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 12px;
  background: var(--accent-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-card .user-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card .user-email {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.provider-badge.google {
  background: rgba(66, 133, 244, 0.1);
  color: #4285F4;
  border-color: rgba(66, 133, 244, 0.3);
}

.provider-badge.local {
  background: rgba(129, 140, 248, 0.1);
  color: var(--accent-color);
  border-color: rgba(129, 140, 248, 0.3);
}

.user-card .admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(124, 58, 237, 0.15);
  color: #7C3AED;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.user-dates {
  display: flex;
  gap: 16px;
  margin-top: 6px;
}

.user-dates small {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-activate {
  background: var(--success-color);
  color: white;
}

.btn-activate:hover {
  background: #2ea043;
  transform: translateY(-1px);
}

.btn-deactivate {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-deactivate:hover {
  background: rgba(248, 81, 73, 0.1);
  color: var(--danger-color);
  border-color: var(--danger-color);
}

/* User Management Tabs */
.user-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.user-tab {
  padding: 10px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-tab:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.user-tab.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 15px;
  margin: 0;
}

/* Bulk actions */
.bulk-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  margin-bottom: 16px;
}

.bulk-actions-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bulk-actions-left label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

#selected-count {
  font-size: 13px;
  color: var(--text-tertiary);
}

.btn-bulk-activate {
  padding: 8px 16px;
  background: var(--success-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-bulk-activate:hover {
  background: #2ea043;
}

.btn-bulk-activate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive User Management */
@media (max-width: 768px) {
  .user-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .user-card .user-checkbox {
    position: absolute;
    top: 12px;
    right: 12px;
  }

  .user-card {
    position: relative;
  }

  .user-card .user-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 14px;
  }

  .user-details {
    width: 100%;
  }

  .user-dates {
    flex-direction: column;
    gap: 4px;
  }

  .user-actions {
    width: 100%;
  }

  .user-actions .btn-sm {
    flex: 1;
    text-align: center;
  }

  .bulk-actions {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .bulk-actions-left {
    justify-content: space-between;
  }
}

/* ==================== COT (Chain of Thought) TOGGLE ==================== */
.cot-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cot-toggle-label {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.cot-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cot-toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.cot-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background-color: var(--text-tertiary);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.cot-checkbox:checked + .cot-toggle-slider {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

.cot-checkbox:checked + .cot-toggle-slider::after {
  transform: translateX(20px);
  background-color: white;
}

.cot-label-text {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.cot-checkbox:checked ~ .cot-label-text {
  color: var(--accent-color);
}

.cot-info-button {
  padding: 4px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cot-info-button:hover {
  background: var(--bg-hover);
  color: var(--accent-color);
}

.cot-reasoning-container {
  display: flex;
  align-items: center;
  padding-left: 12px;
  border-left: 1px solid var(--border-color);
}

.cot-sub-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}

.cot-sub-option input[type="checkbox"] {
  cursor: pointer;
}

.cot-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cot-toggle:hover {
  background: var(--bg-hover);
}

.cot-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.cot-panel {
  display: none;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-top: 8px;
}

.cot-panel[style*="display: block"],
.cot-panel.active {
  display: block !important;
}

.cot-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--accent-light);
  color: var(--accent-color);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

/* ==================== THINKING LOADER ==================== */
.thinking-loader {
  display: flex;
  justify-content: flex-start;
  padding: 16px 20px;
  animation: fadeIn 0.3s ease;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.thinking-loader-content {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  padding: 12px 20px;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .thinking-loader-content {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.thinking-brain {
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinking-brain svg {
  width: 24px;
  height: 24px;
  color: var(--accent-color);
  animation: rotate 2s linear infinite;
}

.thinking-pulse {
  animation: pulse 1.5s ease-in-out infinite;
  transform-origin: center;
}

.thinking-text {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  transition: opacity 0.2s ease;
  min-width: 200px;
}

[data-theme="dark"] .thinking-text {
  color: #F0F6FC;
}

.thinking-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.thinking-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.thinking-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.8);
  }
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ==================== DEEP SEARCH RESULTS ==================== */
.deep-search-results {
  margin: 20px 0;
  padding: 0;
}

.deep-search-result {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .deep-search-result {
  background: #161B22;
  border-color: #30363D;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.deep-result-answer {
  padding: 24px;
}

/* Synthesis section */
.synthesis {
  color: var(--text-primary);
  line-height: 1.6;
}

[data-theme="dark"] .synthesis {
  color: #F0F6FC;
}

.synthesis h3 {
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 600;
  margin: 24px 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
}

[data-theme="dark"] .synthesis h3 {
  color: #F0F6FC;
  border-bottom-color: #30363D;
}

.synthesis h4 {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 20px 0 12px 0;
}

[data-theme="dark"] .synthesis h4 {
  color: #8B949E;
}

.synthesis p {
  margin: 12px 0;
  color: var(--text-secondary);
}

[data-theme="dark"] .synthesis p {
  color: #8B949E;
}

.synthesis strong {
  color: var(--text-primary);
  font-weight: 600;
}

[data-theme="dark"] .synthesis strong {
  color: #F0F6FC;
}

.synthesis ul,
.synthesis ol {
  margin: 16px 0;
  padding-left: 24px;
  color: var(--text-secondary);
}

[data-theme="dark"] .synthesis ul,
[data-theme="dark"] .synthesis ol {
  color: #8B949E;
}

.synthesis li {
  margin: 8px 0;
  line-height: 1.6;
}

.synthesis li strong {
  color: var(--text-primary);
}

[data-theme="dark"] .synthesis li strong {
  color: #F0F6FC;
}

.synthesis blockquote {
  margin: 20px 0;
  padding: 16px 20px;
  background: rgba(210, 153, 34, 0.1);
  border-left: 4px solid var(--warning-color);
  border-radius: 8px;
  color: var(--warning-color);
}

[data-theme="dark"] .synthesis blockquote {
  background: rgba(210, 153, 34, 0.1);
  border-left-color: var(--warning-color);
  color: #D29922;
}

.synthesis blockquote p {
  color: inherit;
  margin: 0;
}

.synthesis hr {
  margin: 24px 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .synthesis hr {
  border-top-color: #30363D;
}

/* Search Results */
.search-results {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--border-color);
}

[data-theme="dark"] .search-results {
  border-top-color: #30363D;
}

.search-results h3 {
  color: var(--text-primary);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
}

[data-theme="dark"] .search-results h3 {
  color: #F0F6FC;
}

.search-results h4 {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  margin: 20px 0 12px 0;
}

[data-theme="dark"] .search-results h4 {
  color: #8B949E;
}

/* Web Result Cards */
.result.web-result {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

[data-theme="dark"] .result.web-result {
  background: #0D1117;
  border-color: #30363D;
}

.result.web-result:hover {
  border-color: var(--success-color);
  box-shadow: 0 2px 8px rgba(63, 185, 80, 0.1);
}

[data-theme="dark"] .result.web-result:hover {
  border-color: var(--success-color);
  box-shadow: 0 2px 8px rgba(63, 185, 80, 0.2);
}

.result.web-result strong {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
}

[data-theme="dark"] .result.web-result strong {
  color: #F0F6FC;
}

.result.web-result a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--success-color);
  text-decoration: none;
  font-weight: 500;
  margin-top: 8px;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.result.web-result a:hover {
  color: var(--accent-color);
  text-decoration: underline;
}

/* Search Stats */
.search-stats {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border-left: 4px solid var(--success-color);
}

[data-theme="dark"] .search-stats {
  background: rgba(63, 185, 80, 0.1);
  border-left-color: var(--success-color);
}

.search-stats small {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

[data-theme="dark"] .search-stats small {
  color: #8B949E;
}

/* Deep Result Meta */
.deep-result-meta {
  padding: 20px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .deep-result-meta {
  background: #0D1117;
  border-top-color: #30363D;
}

.deep-result-meta details {
  cursor: pointer;
}

.deep-result-meta summary {
  font-weight: 600;
  color: var(--text-primary);
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
  list-style: none;
  user-select: none;
}

[data-theme="dark"] .deep-result-meta summary {
  color: #F0F6FC;
  background: #161B22;
  border-color: #30363D;
}

.deep-result-meta summary:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
}

[data-theme="dark"] .deep-result-meta summary:hover {
  background: #21262D;
  border-color: var(--accent-color);
}

.deep-result-meta summary::-webkit-details-marker {
  display: none;
}

.deep-result-meta details[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}

.deep-result-meta pre {
  margin: 0;
  padding: 16px;
  background: #1f2937;
  color: var(--success-color);
  border: 1px solid var(--border-color);
  border-top: none;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  font-family: 'Fira Code', 'Courier New', monospace;
}

[data-theme="dark"] .deep-result-meta pre {
  background: #0D1117;
  border-color: #30363D;
  color: #3FB950;
}

.deep-result-meta details[open] pre {
  animation: fadeIn 0.3s ease;
}

/* ==================== VIDEO MODAL ==================== */
.video-submit-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent-color);
  color: white !important;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.video-submit-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.video-submit-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.video-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  background: var(--text-tertiary);
}

.video-status-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.video-status-badge.status-processing {
  background: rgba(210, 153, 34, 0.15);
  color: var(--warning-color);
  border: 1px solid var(--warning-color);
}

.video-status-badge.status-transcribing {
  background: rgba(88, 166, 255, 0.15);
  color: var(--info-color);
  border: 1px solid var(--info-color);
}

.video-status-badge.status-analyzing {
  background: rgba(124, 58, 237, 0.15);
  color: #7C3AED;
  border: 1px solid #7C3AED;
}

.video-status-badge.status-completed {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success-color);
  border: 1px solid var(--success-color);
}

.video-status-badge.status-error {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger-color);
  border: 1px solid var(--danger-color);
}

/* ==================== STREAMING INDICATOR ==================== */
.streaming-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--accent-light);
  border-radius: 16px;
  font-size: 12px;
  color: var(--accent-color);
}

.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-color);
  animation: blink 1s infinite;
  margin-left: 2px;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ==================== LOADING STATES ==================== */
.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.processing {
  background: var(--accent-light);
  border-color: var(--accent-color);
}

.completed {
  background: rgba(63, 185, 80, 0.1);
  border-color: var(--success-color);
}

.highlighted {
  background: var(--accent-light) !important;
  border-color: var(--accent-color) !important;
  animation: highlightPulse 2s ease-in-out;
}

@keyframes highlightPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px var(--accent-light); }
}

/* ==================== RESPONSIVE COT/DEEP-SEARCH ==================== */
@media (max-width: 768px) {
  .cot-toggle {
    display: block;
    padding: 8px 12px;
  }

  .cot-text {
    font-size: 13px;
  }

  .cot-panel {
    display: none;
  }

  .cot-panel[style*="display: block"],
  .cot-panel.active {
    display: block !important;
  }

  .deep-result-answer {
    padding: 16px;
  }

  .synthesis h3 {
    font-size: 1.1rem;
  }

  .synthesis h4 {
    font-size: 1rem;
  }

  .result.web-result {
    padding: 12px;
  }

  .deep-result-meta {
    padding: 16px;
  }

  .deep-result-meta pre {
    font-size: 0.75rem;
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .cot-text {
    font-size: 12px;
  }
}

/* ================================================================
   USER GUIDE MODAL STYLES
   ================================================================ */

.modal-large {
  max-width: 900px !important;
}

.guide-modal-body {
  max-height: 65vh;
  overflow-y: auto;
}

/* Guide Navigation */
.guide-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  flex-wrap: wrap;
}

.guide-nav-btn {
  flex: 1;
  min-width: 100px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.guide-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.guide-nav-btn.active {
  background: var(--primary-color);
  color: white;
}

/* Guide Sections */
.guide-section {
  display: none;
}

.guide-section.active {
  display: block;
}

.guide-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-color);
}

/* Guide Cards */
.guide-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 18px;
  margin-bottom: 16px;
  transition: all 0.2s ease;
}

.guide-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.guide-card h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.guide-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* Guide Examples */
.guide-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.guide-example-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.guide-examples code {
  display: inline-block;
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  font-family: monospace;
  color: var(--primary-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.guide-examples code:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Guide Buttons Grid */
.guide-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.guide-button-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
  transition: all 0.2s ease;
}

.guide-button-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.guide-button-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-middle));
  border-radius: 12px;
  color: white;
}

.guide-button-card h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.guide-button-card p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Guide Format List */
.guide-format-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.guide-format-list li {
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.guide-format-list li:last-child {
  border-bottom: none;
}

.guide-format-list li strong {
  color: var(--primary-color);
}

/* Responsive Guide */
@media (max-width: 768px) {
  .guide-nav {
    flex-direction: column;
  }

  .guide-nav-btn {
    width: 100%;
  }

  .guide-buttons-grid {
    grid-template-columns: 1fr;
  }

  .modal-large {
    max-width: 95% !important;
  }

  .guide-modal-body {
    max-height: 55vh;
  }
}

/* Dark theme adjustments */
[data-theme="dark"] .guide-card {
  background: var(--bg-secondary);
}

[data-theme="dark"] .guide-examples code {
  background: var(--bg-primary);
}

[data-theme="dark"] .guide-button-card {
  background: var(--bg-secondary);
}

/* ========================================
   PROJECTS SYSTEM STYLES - v3.1
   ======================================== */

/* Projects Section in Sidebar */
.projects-section {
  padding: 0 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}

.projects-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.projects-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.projects-toggle-icon {
  transition: transform 0.2s ease;
}

.projects-toggle.expanded .projects-toggle-icon {
  transform: rotate(90deg);
}

.new-project-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.new-project-btn:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

/* Projects Header Actions (v3.2.4) */
.projects-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle-archived-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-archived-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.85);
}

.toggle-archived-btn.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

/* Archived Project Styling (v3.2.4) */
.project-item.archived {
  opacity: 0.6;
  border-left: 3px solid var(--text-muted);
}

.project-item.archived:hover {
  opacity: 0.8;
}

.project-item.archived .project-item-name::after {
  content: " (archiviato)";
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Archive Button (v3.2.4) */
.project-archive-zone {
  margin-right: auto;
}

.btn-archive {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-archive:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.btn-archive.unarchive {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
  color: #10b981;
}

.btn-archive.unarchive:hover {
  background: rgba(16, 185, 129, 0.2);
}

/* Projects List */
.projects-list {
  padding: 4px 0 8px 0;
  max-height: 200px;
  overflow-y: auto;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.project-item:hover {
  background: var(--bg-hover);
}

.project-item.active {
  background: var(--bg-active);
  border-left-color: var(--accent-color);
}

.project-item-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.project-item-info {
  flex: 1;
  min-width: 0;
}

.project-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* v3.2.14: Clickable project name to open modal */
.project-item .project-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color 0.2s ease;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
}

.project-item .project-name:hover {
  color: var(--accent-color);
  background: rgba(var(--accent-rgb, 59, 130, 246), 0.1);
  text-decoration: underline;
}

.project-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.project-item-actions,
.project-actions {
  display: none;
  gap: 4px;
  align-items: center;
}

.project-item:hover .project-item-actions,
.project-item:hover .project-actions {
  display: flex;
}

.project-item-btn,
.project-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.project-item-btn:hover,
.project-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-color);
}

.project-item-btn.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Current Project Indicator in Header */
.current-project-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-primary);
  max-width: 250px;
}

.current-project-indicator .project-icon {
  font-size: 14px;
}

.current-project-indicator .project-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.clear-project-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.clear-project-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Project Modal Styles */
#project-modal .modal-body {
  padding: 20px;
}

.form-row {
  display: flex;
  gap: 20px;
}

.form-group-half {
  flex: 1;
}

.form-group-third {
  flex: 1;
}

.form-help {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Icon Selector */
.icon-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
}

.icon-btn.selected {
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.1);
}

/* Color Selector */
.color-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.color-btn {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-primary);
}

/* Form Actions */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Checkbox Label */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--accent-color);
}

/* Documents Tab Styles */
.documents-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.documents-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.stats-separator {
  color: var(--border-color);
}

.upload-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* Upload Zone */
.documents-upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  margin-bottom: 16px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.documents-upload-zone:hover,
.documents-upload-zone.drag-over {
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.05);
}

.upload-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

.upload-zone-content svg {
  opacity: 0.5;
}

.upload-zone-content p {
  font-size: 14px;
  margin: 0;
}

.upload-zone-content small {
  font-size: 12px;
  opacity: 0.7;
}

/* Documents List */
.documents-list {
  max-height: 300px;
  overflow-y: auto;
}

.document-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.document-item:hover {
  background: var(--bg-hover);
}

.document-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.document-info {
  flex: 1;
  min-width: 0;
}

.document-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.document-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.document-status.pending {
  background: rgba(234, 179, 8, 0.1);
  color: #eab308;
}

.document-status.processing {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.document-status.indexed {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.document-status.failed {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* v3.2.11: Agent-generated document styles */
.document-item.agent-generated {
  border-left: 3px solid var(--accent-color, #8b5cf6);
}

.agent-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  margin-left: 6px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: white;
  font-size: 9px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
}

.document-actions {
  display: flex;
  gap: 4px;
}

.document-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.document-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.document-btn.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.document-btn.preview:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
}

.document-btn.download:hover {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

/* ============================================================================
   PREVIEW MODAL - v3.1
   ============================================================================ */

#preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.preview-modal-content {
  background: var(--bg-primary);
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.2s ease;
}

.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.preview-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.preview-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.preview-filename {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-language {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 500;
  flex-shrink: 0;
}

.preview-modal-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.preview-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preview-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.preview-btn.copy:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.3);
}

.preview-btn.close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.preview-modal-body {
  flex: 1;
  overflow: auto;
  padding: 0;
  min-height: 0;
}

.preview-content {
  margin: 0;
  padding: 20px;
  background: var(--bg-secondary);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 100%;
}

.preview-content code {
  font-family: inherit;
  background: none;
  padding: 0;
}

.preview-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 0 0 12px 12px;
  flex-shrink: 0;
}

.preview-stats {
  font-size: 12px;
  color: var(--text-secondary);
}

.preview-truncated {
  font-size: 12px;
  color: #f59e0b;
  font-weight: 500;
}

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

/* Documents Empty State */
.documents-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}

.documents-empty svg {
  opacity: 0.3;
  margin-bottom: 16px;
}

.documents-empty p {
  font-size: 14px;
  margin: 0 0 8px 0;
}

.documents-empty small {
  font-size: 12px;
  opacity: 0.7;
}

/* Project Modal Footer */
.project-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.project-danger-zone {
  display: flex;
  gap: 8px;
}

.project-export-zone {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 280px;
  max-width: 400px;
  animation: toast-in 0.3s ease;
}

.toast.toast-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
}

.toast-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.toast-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toast.success {
  border-left: 3px solid #22c55e;
}

.toast.error {
  border-left: 3px solid #ef4444;
}

.toast.warning {
  border-left: 3px solid #eab308;
}

.toast.info {
  border-left: 3px solid #3b82f6;
}

/* Dark theme adjustments for Projects */
[data-theme="dark"] .documents-upload-zone:hover,
[data-theme="dark"] .documents-upload-zone.drag-over {
  background: rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .document-item {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .toast {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

/* ==================== v3.1: SAVE TO PROJECT BUTTON ==================== */
.save-to-project-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--accent-color) 0%, #8b5cf6 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

pre:hover .save-to-project-btn {
  opacity: 1;
  transform: translateY(0);
}

.save-to-project-btn:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.save-to-project-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.save-to-project-btn:active {
  transform: scale(0.98);
}

/* Project notification toast */
.project-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border-left: 4px solid var(--accent-color);
  font-size: 14px;
  z-index: 10000;
  animation: slideInNotification 0.3s ease;
}

.project-notification.success {
  border-left-color: #10b981;
}

.project-notification.error {
  border-left-color: #ef4444;
}

.project-notification.info {
  border-left-color: #3b82f6;
}

.project-notification.fade-out {
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s ease;
}

@keyframes slideInNotification {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Dark theme adjustments */
[data-theme="dark"] .save-to-project-btn {
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] .project-notification {
  background: var(--bg-secondary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .projects-list {
    max-height: 150px;
  }

  .current-project-indicator {
    max-width: 180px;
    padding: 4px 10px;
    font-size: 12px;
  }

  .form-row {
    flex-direction: column;
    gap: 16px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }
}

/* ============================================ */
/* v3.2: Agent Mode Styles                      */
/* ============================================ */

.agent-mode-header {
  display: flex;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
  border-radius: 12px;
  margin-bottom: 20px;
}

.agent-mode-icon {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-color);
  border-radius: 12px;
  color: white;
}

.agent-mode-icon svg {
  width: 36px;
  height: 36px;
}

.agent-mode-info h4 {
  margin: 0 0 8px 0;
  font-size: 18px;
  color: var(--text-primary);
}

.agent-mode-info p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.agent-mode-description {
  margin-bottom: 24px;
}

.agent-mode-description h5 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.agent-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.agent-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.step-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-color);
  color: white;
  border-radius: 50%;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

.step-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-content strong {
  font-size: 13px;
  color: var(--text-primary);
}

.step-content span {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.agent-enable-label {
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.agent-enable-label .checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-enable-label .checkbox-text strong {
  color: var(--text-primary);
}

.agent-enable-label .checkbox-text small {
  color: var(--text-secondary);
  font-size: 12px;
}

.agent-settings {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.agent-execution-section {
  margin-top: 24px;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 0 0 16px 0;
}

.agent-execution-section h5 {
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.agent-status {
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.status-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.status-badge.running {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.status-badge.completed {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.status-badge.paused {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.status-phase {
  font-size: 13px;
  color: var(--text-secondary);
}

.progress-bar-container {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), #8b5cf6);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.execution-log {
  max-height: 150px;
  overflow-y: auto;
  margin-top: 12px;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
}

.log-entry {
  padding: 2px 0;
  color: var(--text-secondary);
}

.log-entry.info {
  color: var(--text-secondary);
}

.log-entry.warning {
  color: #f59e0b;
}

.log-entry.error {
  color: #ef4444;
}

.agent-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-agent-execute,
.btn-agent-pause,
.btn-agent-resume,
.btn-agent-abort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-warning {
  background: #f59e0b;
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.agent-requirements {
  margin-top: 20px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.requirement-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.req-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
}

.req-icon.req-pending {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.req-icon.req-ok {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.req-icon.req-fail {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* v3.2.12: Agent Document Requirement Section */
.agent-document-requirement {
  margin: 16px 0;
  animation: fadeIn 0.3s ease;
}

.requirement-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(245, 158, 11, 0.1));
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 12px;
  margin-bottom: 16px;
}

.requirement-alert-icon {
  flex-shrink: 0;
  color: #f59e0b;
}

.requirement-alert-content strong {
  display: block;
  color: #d97706;
  font-size: 14px;
  margin-bottom: 4px;
}

.requirement-alert-content p {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}

.suggested-files {
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.suggested-files h6 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.suggested-files-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.suggested-file {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.suggested-file:hover {
  border-color: var(--primary-color);
  background: var(--bg-tertiary);
}

.suggested-file .file-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.suggested-file .file-info {
  flex: 1;
  min-width: 0;
}

.suggested-file .file-info strong {
  display: block;
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.suggested-file .file-info small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-go-to-documents {
  width: 100%;
  justify-content: center;
  gap: 8px;
}

@media (max-width: 600px) {
  .suggested-files-grid {
    grid-template-columns: 1fr;
  }
}

/* Dark theme for document requirement */
[data-theme="dark"] .requirement-alert {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.1));
  border-color: rgba(251, 191, 36, 0.25);
}

[data-theme="dark"] .requirement-alert-content strong {
  color: #fbbf24;
}

/* Responsive adjustments for Agent Mode */
@media (max-width: 768px) {
  .agent-steps {
    grid-template-columns: repeat(2, 1fr);
  }

  .agent-mode-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .agent-actions {
    flex-direction: column;
  }

  .agent-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Dark theme adjustments for Agent Mode */
[data-theme="dark"] .agent-mode-header {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
}

[data-theme="dark"] .agent-step {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .agent-enable-label {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .agent-status {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .execution-log {
  background: var(--bg-secondary);
}

/* ============================================
   AGENT EXECUTION HISTORY (v3.2.3)
   ============================================ */

.agent-history-section {
  margin-top: 24px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.history-header h5 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.history-loading,
.history-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.history-loading .spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* History Item Card */
.history-item {
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-item:hover {
  border-color: var(--accent-color);
  background: var(--bg-tertiary);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.history-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  margin-right: 12px;
}

.history-item-phase {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  text-transform: capitalize;
}

/* v3.2.13: Delete button for history items */
.history-item-delete {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin-left: 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.history-item:hover .history-item-delete {
  display: flex;
}

.history-item-delete:hover {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
}

.history-item-delete:active {
  background: rgba(220, 53, 69, 0.25);
}

.history-item-delete svg {
  width: 14px;
  height: 14px;
}

/* v3.2.14: Force stop button for running executions */
.history-item-force-stop {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin-left: 4px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.history-item:hover .history-item-force-stop {
  display: flex;
}

.history-item-force-stop:hover {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.history-item-force-stop:active {
  background: rgba(255, 193, 7, 0.25);
}

.history-item-force-stop svg {
  width: 14px;
  height: 14px;
}

.history-item-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.history-item-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-item-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-item-progress .mini-bar {
  width: 60px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.history-item-progress .mini-bar-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 2px;
}

/* Status colors for history items */
.history-item.status-completed {
  border-left: 3px solid #10b981;
}

.history-item.status-failed {
  border-left: 3px solid #ef4444;
}

.history-item.status-paused {
  border-left: 3px solid #f59e0b;
}

.history-item.status-running {
  border-left: 3px solid #3b82f6;
}

/* v3.2.8: Interrupted (can resume) */
.history-item.status-interrupted {
  border-left: 3px solid #8b5cf6; /* purple */
}

/* ============================================
   EXECUTION DETAIL MODAL (v3.2.3)
   ============================================ */

.execution-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

.execution-detail-modal {
  background: var(--bg-primary);
  border-radius: 12px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

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

.execution-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.execution-detail-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.close-modal-btn:hover {
  color: var(--text-primary);
}

.execution-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Execution Summary */
.execution-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 20px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Execution Tabs */
.execution-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 16px;
}

.exec-tab-btn {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.exec-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.exec-tab-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Tab Content */
.exec-tab-content {
  display: none;
}

.exec-tab-content.active {
  display: block;
}

/* Tasks Tab */
.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-radius: 6px;
  border-left: 3px solid var(--border-color);
}

.task-item.task-completed {
  border-left-color: #10b981;
}

.task-item.task-failed {
  border-left-color: #ef4444;
}

.task-item.task-in-progress {
  border-left-color: #3b82f6;
}

.task-item.task-pending {
  border-left-color: var(--text-muted);
}

.task-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.task-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.task-item-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: capitalize;
}

.task-item-status.status-completed {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.task-item-status.status-failed {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.task-item-status.status-in_progress {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.task-item-status.status-pending {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.task-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Logs Tab */
.logs-container {
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 12px;
}

.log-item {
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  display: flex;
  gap: 12px;
}

.log-item:hover {
  background: var(--bg-tertiary);
}

.log-timestamp {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.log-phase {
  color: var(--accent-color);
  min-width: 80px;
  text-transform: capitalize;
}

.log-message {
  color: var(--text-primary);
  word-break: break-word;
}

.log-item.level-warning .log-message {
  color: #f59e0b;
}

.log-item.level-error .log-message {
  color: #ef4444;
}

.log-item.level-debug .log-message {
  color: var(--text-muted);
}

/* Report Tab */
.report-container {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.report-container pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}

.report-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Execution Detail Footer */
.execution-detail-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

/* Dark theme adjustments for History */
[data-theme="dark"] .history-item {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .history-item:hover {
  background: rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .execution-detail-modal {
  background: var(--bg-primary);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .execution-summary {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .logs-container {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .report-container {
  background: var(--bg-tertiary);
}

/* Responsive adjustments for History */
@media (max-width: 768px) {
  .execution-detail-modal {
    max-height: 100vh;
    border-radius: 0;
  }

  .execution-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .execution-tabs {
    flex-wrap: wrap;
  }

  .exec-tab-btn {
    flex: none;
    min-width: 80px;
  }
}

/* ========================================
   STATISTICS DASHBOARD (v3.2.5)
   ======================================== */

.stats-dashboard {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Stats Header */
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-header h3::before {
  content: '📊';
}

.btn-refresh-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-refresh-stats:hover {
  background: var(--bg-hover);
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.btn-refresh-stats svg {
  width: 14px;
  height: 14px;
}

.btn-refresh-stats.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
  transform: translateY(-2px);
}

/* Stat Icons */
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.documents {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
  color: #3b82f6;
}

.stat-icon.chunks {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.1));
  color: #10b981;
}

.stat-icon.conversations {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
  color: #8b5cf6;
}

.stat-icon.messages {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.1));
  color: #f59e0b;
}

.stat-icon.executions {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(236, 72, 153, 0.1));
  color: #ec4899;
}

.stat-icon.storage {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.1));
  color: #6366f1;
}

/* Stat Info */
.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-value.loading {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  height: 28px;
  width: 60px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Stats Sections */
.stats-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
}

.stats-section h4 {
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Activity Timeline */
.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 8px;
  border-left: 3px solid var(--accent-color);
}

.timeline-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

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

.timeline-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.timeline-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* File Types Distribution */
.file-types-distribution {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-type-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-type-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.file-type-info {
  flex: 1;
  min-width: 0;
}

.file-type-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.file-type-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.file-type-progress {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.file-type-progress.pdf { background: linear-gradient(90deg, #ef4444, #f87171); }
.file-type-progress.docx { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.file-type-progress.txt { background: linear-gradient(90deg, #6b7280, #9ca3af); }
.file-type-progress.md { background: linear-gradient(90deg, #10b981, #34d399); }
.file-type-progress.json { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.file-type-progress.other { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }

.file-type-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: right;
}

.file-types-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Dark theme adjustments for Statistics */
[data-theme="dark"] .stat-card {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .stats-section {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .timeline-item {
  background: var(--bg-secondary);
}

/* Responsive adjustments for Statistics */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card {
    padding: 12px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .stat-value {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}

/* ========================================
   AGENT TEMPLATES (v3.2.6)
   ======================================== */

.agent-templates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.agent-template-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 12px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.agent-template-btn:hover {
  border-color: var(--accent-color);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.agent-template-btn.selected {
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.agent-template-btn .template-icon {
  font-size: 24px;
  line-height: 1;
}

.agent-template-btn .template-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.agent-template-btn .template-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.3;
}

/* Dark theme adjustments for Agent Templates */
[data-theme="dark"] .agent-template-btn {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .agent-template-btn:hover {
  background: var(--bg-hover);
}

[data-theme="dark"] .agent-template-btn.selected {
  background: rgba(99, 102, 241, 0.15);
}

/* Responsive adjustments for Agent Templates */
@media (max-width: 768px) {
  .agent-templates-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .agent-templates-grid {
    grid-template-columns: 1fr;
  }

  .agent-template-btn {
    flex-direction: row;
    text-align: left;
    gap: 12px;
    padding: 12px;
  }

  .agent-template-btn .template-icon {
    font-size: 20px;
  }

  .agent-template-btn .template-name,
  .agent-template-btn .template-desc {
    display: block;
  }
}

/* ========================================
   v3.0.1: MFR Custom Constraints Styles
   ======================================== */

.mfr-constraints-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.mfr-constraints-section > label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.mfr-constraints-section .badge-info {
  background: var(--primary-color);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
}

.mfr-constraints-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.mfr-constraint-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
}

.mfr-constraint-item .constraint-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mfr-constraint-item .constraint-description {
  flex: 1;
  min-width: 0;
}

.mfr-constraint-item .constraint-severity {
  width: 140px;
  flex-shrink: 0;
}

.mfr-constraint-item .btn-remove-constraint {
  flex-shrink: 0;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.mfr-constraint-item .btn-remove-constraint:hover {
  background: var(--danger-color);
  border-color: var(--danger-color);
  color: white;
}

.form-select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
}

.mfr-constraint-templates {
  margin-top: 12px;
}

.mfr-constraint-templates > small {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.constraint-template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.constraint-template-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.constraint-template-chips .chip:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

@media (max-width: 768px) {
  .mfr-constraint-item .constraint-row {
    flex-wrap: wrap;
  }

  .mfr-constraint-item .constraint-description {
    width: 100%;
    flex: none;
  }

  .mfr-constraint-item .constraint-severity {
    flex: 1;
  }
}

/* ==================== ATTACH DOCUMENT BUTTON (v3.0.2) ==================== */
/* Allows attaching documents to existing conversations */

.attach-doc-button {
  position: relative;
  min-width: 36px;
  transition: all 0.3s ease;
}

.attach-doc-button svg {
  color: var(--text-tertiary);
  transition: all 0.3s ease;
}

.attach-doc-button:hover {
  border-color: #8b5cf6;
}

.attach-doc-button:hover svg {
  color: #8b5cf6;
}

.attach-doc-button.has-files {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  border-color: transparent;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

.attach-doc-button.has-files svg {
  color: white;
}

/* Badge showing number of attached files */
.attach-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: badge-pop 0.3s ease-out;
}

@keyframes badge-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Dark mode */
[data-theme="dark"] .attach-doc-button:hover {
  border-color: #a78bfa;
}

[data-theme="dark"] .attach-doc-button:hover svg {
  color: #a78bfa;
}

/* Attached files bar (above input) */
.attached-files-bar {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  margin-bottom: -1px;
}

.attached-files-bar.visible {
  display: flex;
}

.attached-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-primary);
  max-width: 200px;
  animation: chip-slide 0.2s ease-out;
}

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

.attached-file-chip .file-icon {
  color: #8b5cf6;
  flex-shrink: 0;
}

.attached-file-chip .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attached-file-chip .remove-file {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: rgba(239, 68, 68, 0.1);
  border: none;
  border-radius: 50%;
  color: #ef4444;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.attached-file-chip .remove-file:hover {
  background: #ef4444;
  color: white;
}

.attached-file-chip .remove-file svg {
  width: 12px;
  height: 12px;
}

/* Upload progress indicator */
.attach-upload-progress {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 8px;
  font-size: 12px;
  color: #8b5cf6;
}

.attach-upload-progress.visible {
  display: flex;
}

.attach-upload-progress .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(139, 92, 246, 0.2);
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Attached documents indicator in message */
.attached-docs-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
  font-size: 11px;
  color: #8b5cf6;
  margin-left: 8px;
}

.attached-docs-indicator svg {
  width: 12px;
  height: 12px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .attached-files-bar {
    padding: 8px 10px;
    gap: 6px;
  }

  .attached-file-chip {
    padding: 4px 8px;
    font-size: 11px;
    max-width: 150px;
  }
}


/* ==========================================
   IMAGE GENERATION STYLES (v3.1)
   Generated images in chat + viewer modal
   ========================================== */

/* Generated image container in chat message */
.generated-image-container {
  display: inline-block;
  position: relative;
  max-width: 300px;
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-tertiary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.generated-image-container:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.generated-image-preview {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.generated-image-preview:hover {
  opacity: 0.9;
}

.image-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
}

.image-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--accent-color);
  cursor: pointer;
  font-size: 18px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.image-action-btn:hover {
  background: var(--accent-color);
  color: white;
  transform: scale(1.05);
}

/* Image viewer modal overlay */
.image-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.image-viewer-overlay.closing {
  animation: fadeOut 0.2s ease forwards;
}

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

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

.image-viewer-modal {
  background: var(--bg-surface);
  border-radius: 16px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.image-viewer-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.image-viewer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.image-viewer-close:hover {
  background: var(--danger-color);
  color: white;
}

.image-viewer-body {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  max-height: calc(90vh - 140px);
}

.image-viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-viewer-img.loaded {
  opacity: 1;
}

.image-viewer-footer {
  display: flex;
  justify-content: center;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}

.image-viewer-download {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-middle));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.image-viewer-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.image-viewer-download svg {
  width: 18px;
  height: 18px;
}

/* Image generation skeleton loader */
.image-generating-skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 250px;
  height: 200px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  margin: 12px 0;
  animation: pulse 2s ease-in-out infinite;
}

.image-generating-skeleton .skeleton-icon {
  font-size: 48px;
  margin-bottom: 12px;
  animation: bounce 1.5s ease-in-out infinite;
}

.image-generating-skeleton .skeleton-text {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

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

/* Mobile responsive for image generation */
@media (max-width: 768px) {
  .generated-image-container {
    max-width: 100%;
  }

  .image-viewer-modal {
    max-width: 95vw;
    max-height: 95vh;
    margin: 10px;
    border-radius: 12px;
  }

  .image-viewer-header {
    padding: 12px 16px;
  }

  .image-viewer-body {
    padding: 12px;
  }

  .image-viewer-footer {
    padding: 12px 16px;
  }

  .image-actions {
    gap: 8px;
    padding: 8px;
  }

  .image-action-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
}

/* ================================================================
   v3.5: SOURCES PANEL FOR CITATIONS
   ================================================================ */

.sources-panel {
  margin-top: 16px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-bg, #f9fafb);
  font-size: 0.9em;
}

[data-theme="dark"] .sources-panel {
  background: rgba(30, 30, 40, 0.6);
  border-color: rgba(255, 255, 255, 0.1);
}

.sources-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-secondary, #f3f4f6);
  cursor: pointer;
  transition: background 0.2s ease;
  user-select: none;
}

[data-theme="dark"] .sources-panel-header {
  background: rgba(40, 40, 50, 0.8);
}

.sources-panel-header:hover {
  background: var(--surface-hover, #e5e7eb);
}

[data-theme="dark"] .sources-panel-header:hover {
  background: rgba(50, 50, 60, 0.9);
}

.sources-panel-icon {
  font-size: 1.1em;
}

.sources-panel-title {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
}

[data-theme="dark"] .sources-panel-title {
  color: #e5e7eb;
}

.sources-panel-count {
  background: var(--accent-color, #6366f1);
  color: white;
  font-size: 0.75em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
}

.sources-conflict-badge {
  font-size: 0.9em;
  animation: pulse 2s infinite;
}

.sources-panel-toggle {
  color: var(--text-secondary, #6b7280);
  font-size: 0.8em;
  transition: transform 0.2s ease;
}

.sources-panel-content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.sources-panel.collapsed .sources-panel-content {
  display: none;
}

/* Source Items */
.sources-item {
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

[data-theme="dark"] .sources-item {
  background: rgba(40, 40, 50, 0.6);
  border-color: rgba(255, 255, 255, 0.08);
}

.sources-item:hover {
  border-color: var(--accent-color, #6366f1);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.sources-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.sources-item-id {
  font-weight: 700;
  color: var(--accent-color, #6366f1);
  font-size: 0.85em;
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.sources-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary, #1f2937);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

[data-theme="dark"] .sources-item-name {
  color: #e5e7eb;
}

.sources-item-badge {
  font-size: 0.85em;
}

.sources-item-badge.high {
  color: #22c55e;
}

.sources-item-badge.medium {
  color: #eab308;
}

.sources-item-badge.low {
  color: #f97316;
}

.sources-item-snippet {
  font-size: 0.85em;
  color: var(--text-secondary, #6b7280);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Confidence Level Borders */
.sources-item.confidence-high {
  border-left: 3px solid #22c55e;
}

.sources-item.confidence-medium {
  border-left: 3px solid #eab308;
}

.sources-item.confidence-low {
  border-left: 3px solid #f97316;
}

/* Conflicts Section */
.sources-conflicts {
  margin-top: 10px;
  padding: 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
}

[data-theme="dark"] .sources-conflicts {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
}

.sources-conflicts-title {
  font-weight: 600;
  color: #dc2626;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.sources-conflict-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85em;
  padding: 4px 0;
}

.conflict-citations {
  font-weight: 600;
  color: var(--text-primary, #1f2937);
}

[data-theme="dark"] .conflict-citations {
  color: #e5e7eb;
}

.conflict-type {
  color: var(--text-secondary, #6b7280);
  font-style: italic;
}

/* Citation Highlight in Response */
.citation-highlight {
  background: rgba(99, 102, 241, 0.2);
  border-radius: 3px;
  padding: 1px 3px;
  font-weight: 600;
  color: var(--accent-color, #6366f1);
  transition: all 0.3s ease;
}

.citation-highlight.flash {
  background: rgba(99, 102, 241, 0.4);
  animation: citationFlash 0.5s ease;
}

@keyframes citationFlash {
  0%, 100% { background: rgba(99, 102, 241, 0.2); }
  50% { background: rgba(99, 102, 241, 0.5); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .sources-panel-content {
    max-height: 200px;
  }

  .sources-item-name {
    max-width: 120px;
  }

  .sources-item-header {
    flex-wrap: wrap;
  }
}

/* ========================================
   v3.5: TIER USAGE WIDGET
   ======================================== */

.tier-usage-widget {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.tier-usage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Tier badge colors */
.tier-badge.tier-starter {
  background: linear-gradient(135deg, #6b7280, #4b5563);
  color: #fff;
}

.tier-badge.tier-pro {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
}

.tier-badge.tier-enterprise {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

.tier-usage-header .tier-usage-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tier-usage-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tier-usage-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tier-usage-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tier-usage-info .tier-usage-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.tier-usage-value {
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 500;
}

.tier-progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.tier-progress-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 2px;
  transition: width 0.3s ease, background 0.3s ease;
}

/* Progress bar colors based on usage */
.tier-progress-fill.usage-low {
  background: #22c55e;
}

.tier-progress-fill.usage-medium {
  background: #f59e0b;
}

.tier-progress-fill.usage-high {
  background: #ef4444;
}

.tier-progress-fill.usage-unlimited {
  background: linear-gradient(90deg, #22c55e 0%, #22c55e 100%);
  width: 100% !important;
  opacity: 0.3;
}

/* Feature disabled styles */
.feature-disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  position: relative;
}

.feature-disabled::after {
  content: '';
  position: absolute;
  inset: 0;
  cursor: not-allowed;
}

.feature-disabled-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.feature-disabled:hover .feature-disabled-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Lock icon for disabled features */
.feature-lock-icon {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* Tier limit toast */
.tier-limit-toast {
  background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
  border-left: 4px solid #f59e0b !important;
  color: #92400e !important;
}

[data-theme="dark"] .tier-limit-toast {
  background: linear-gradient(135deg, #78350f, #92400e) !important;
  color: #fef3c7 !important;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .tier-usage-widget {
    padding: 10px 12px;
  }

  .tier-usage-header {
    flex-wrap: wrap;
  }
}
