/* ============================================================
   STYLE.CSS - MODE NORMAL (MODERNE)
   Ne s'applique QUE lorsque body.n'a pas' terminal-mode'
   ============================================================ */

/* ========================================
   🎨 VARIABLES & THÈME DARK MODE
   ======================================== */
:root {
  /* Couleurs principales */
  --bg-primary: #0a0a0c;
  --bg-secondary: #111216;
  --bg-tertiary: #1a1c22;
  --bg-elevated: #22242c;
  --bg-hover: #2c2f3a;
  --bg-active: #353947;
  
  /* Textes */
  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-muted: #a0a0b0;
  --text-inverse: #0a0a0c;
  
  /* Accents */
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.1);
  --accent-border: rgba(59, 130, 246, 0.3);
  
  /* États */
  --error: #f87171;
  --error-glow: rgba(248, 113, 113, 0.1);
  --success: #4ade80;
  --success-glow: rgba(74, 222, 128, 0.1);
  --warning: #fbbf24;
  --warning-glow: rgba(251, 191, 36, 0.1);
  
  /* Bordures */
  --border-color: #2a2d36;
  --border-light: #363a45;
  
  /* Ombres */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.8);
  --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.9);
  
  /* Typographie */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Espacements */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;
  
  /* Layout */
  --sidebar-width: 300px;
  --input-max-height: 200px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.terminal-mode {
  /* Rien - terminal.css prend le relais */
}

::selection {
  background: var(--accent);
  color: var(--text-inverse);
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-full);
}

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

/* ========================================
   🔐 AUTH PAGES
   ======================================== */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--spacing-xl);
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.auth-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.02) 2px,
    rgba(255, 255, 255, 0.02) 4px
  );
  animation: gridMove 20s linear infinite;
  pointer-events: none;
}

@keyframes gridMove {
  0% { transform: translateY(0); }
  100% { transform: translateY(50px); }
}

.auth-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-2xl);
  padding: var(--spacing-xl);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  animation: authSlideUp 0.6s ease;
  position: relative;
  z-index: 1;
}

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

.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: var(--spacing-sm);
  color: var(--text-primary);
  text-align: center;
}

.auth-form {
  margin-bottom: var(--spacing-lg);
}

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: all 0.2s;
}

.form-group input:hover {
  border-color: var(--border-light);
}

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

.form-group input::placeholder {
  color: var(--text-muted);
}

/* ========================================
   🔘 BOUTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-xl);
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.25s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.1);
}

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

.btn-google {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  width: 100%;
}

.btn-google:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

/* ========================================
   📋 AUTH DIVIDER & FOOTER
   ======================================== */
.auth-divider {
  margin: var(--spacing-xl) 0;
  text-align: center;
  position: relative;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 60px);
  height: 1px;
  background: var(--border-color);
}

.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-divider span {
  background: var(--bg-secondary);
  padding: 0 var(--spacing-md);
  position: relative;
}

.auth-footer {
  margin-top: var(--spacing-xl);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ========================================
   ⚠️ ALERTES
   ======================================== */
.alert {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-lg);
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid;
}

.alert-error {
  background: var(--error-glow);
  color: var(--error);
  border-color: var(--error);
}

.alert-success {
  background: var(--success-glow);
  color: var(--success);
  border-color: var(--success);
}

/* ========================================
   💬 LAYOUT CHAT
   ======================================== */
.chat-container {
  display: flex;
  height: 100vh;
  background: var(--bg-primary);
  overflow: hidden;
}

/* ========================================
   📑 SIDEBAR
   ======================================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

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

.btn-new-chat {
  width: 100%;
  background: var(--text-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: var(--shadow-md);
}

.btn-new-chat:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.sidebar-search {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-search input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
}

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

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm);
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  margin: var(--spacing-xs) 0;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
  transform: translateX(4px);
}

.conversation-item.active {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.conversation-item .conv-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: var(--spacing-sm);
  color: var(--accent);
  border: 1px solid var(--border-color);
  font-size: 1rem;
  flex-shrink: 0;
}

.conversation-item .conv-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.conversation-item .conv-menu {
  opacity: 0;
  transition: opacity 0.2s;
  margin-left: var(--spacing-xs);
  color: var(--text-muted);
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.conversation-item:hover .conv-menu {
  opacity: 1;
}

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

.sidebar-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--text-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-name a {
  text-decoration: none;
  color: inherit;
}

.user-name a:hover {
  text-decoration: underline;
}

.btn-logout {
  color: var(--text-muted);
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  color: var(--error);
  background: var(--error-glow);
  border-color: var(--error);
  transform: scale(1.05);
}

/* ========================================
   💬 ZONE PRINCIPALE
   ======================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-xl);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* ========================================
   💭 MESSAGES
   ======================================== */
.message {
  display: flex;
  max-width: 85%;
  animation: messageAppear 0.3s ease;
  position: relative;
  gap: var(--spacing-md);
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 700;
}

.message.user .message-avatar {
  background: var(--text-primary);
  color: var(--text-inverse);
}

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

.message-content {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-xl);
  background: var(--bg-tertiary);
  line-height: 1.7;
  position: relative;
  word-wrap: break-word;
  font-size: 1rem;
  border: 1px solid var(--border-color);
}

.message.user .message-content {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .message-content {
  background: var(--bg-elevated);
  border-bottom-left-radius: var(--radius-sm);
}

.message-content p {
  margin-bottom: var(--spacing-sm);
}

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

/* ========================================
   📝 MARKDOWN
   ======================================== */
.message-content h1,
.message-content h2,
.message-content h3 {
  color: var(--text-primary);
  margin: var(--spacing-lg) 0 var(--spacing-sm) 0;
  font-weight: 700;
}

.message-content h1 { font-size: 1.5rem; border-bottom: 2px solid var(--border-accent); padding-bottom: var(--spacing-sm); }
.message-content h2 { font-size: 1.25rem; border-bottom: 1px solid var(--border-accent); padding-bottom: var(--spacing-sm); }
.message-content h3 { font-size: 1.125rem; }

.message-content ul,
.message-content ol {
  margin: var(--spacing-sm) 0;
  padding-left: var(--spacing-xl);
}

.message-content li {
  margin: var(--spacing-xs) 0;
  color: var(--text-primary);
}

.message-content blockquote {
  border-left: 3px solid var(--accent);
  margin: var(--spacing-md) 0;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.message-content pre {
  background: var(--bg-primary);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin: var(--spacing-md) 0;
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.message-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-primary);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.message-content pre code {
  background: transparent;
  padding: 0;
  border: none;
}

.message-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s;
}

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

.message-content strong {
  font-weight: 700;
  color: var(--text-primary);
}

/* ========================================
   ⚡ STREAMING
   ======================================== */
.message.assistant.streaming .message-content::after {
  content: '▊';
  color: var(--accent);
  animation: cursorBlink 1s infinite;
  margin-left: 2px;
  display: inline-block;
}

@keyframes cursorBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ========================================
   🎯 MESSAGE ACTIONS
   ======================================== */
.message-actions {
  display: flex;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.2s;
  position: absolute;
  bottom: -30px;
  right: 0;
  background: var(--bg-elevated);
  padding: var(--spacing-xs);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

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

.message-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: var(--radius-full);
  transition: all 0.2s;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-actions button:hover {
  color: var(--accent);
  background: var(--bg-hover);
  transform: scale(1.1);
}

/* ========================================
   ⌨️ TYPING INDICATOR
   ======================================== */
.typing-indicator {
  display: flex;
  gap: var(--spacing-xs);
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  width: fit-content;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-md);
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* ========================================
   📥 ZONE DE SAISIE
   ======================================== */
.chat-input-container {
  padding: var(--spacing-lg) var(--spacing-xl) var(--spacing-xl);
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
  position: relative;
  z-index: 2;
}

#chatForm {
  display: flex;
  align-items: flex-end;
  gap: var(--spacing-sm);
  background: var(--bg-elevated);
  border-radius: var(--radius-2xl);
  padding: var(--spacing-sm);
  border: 1px solid var(--border-color);
  transition: all 0.2s;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

#chatForm:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: scale(1.01);
}

#messageInput {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  padding: var(--spacing-md) 0;
  max-height: var(--input-max-height);
  resize: none;
  font-family: var(--font-main);
  line-height: 1.6;
  outline: none;
}

#messageInput::placeholder {
  color: var(--text-muted);
}

#sendButton {
  background: var(--text-primary);
  border: none;
  color: var(--text-inverse);
  cursor: pointer;
  padding: var(--spacing-md);
  border-radius: var(--radius-full);
  transition: all 0.25s;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

#sendButton:hover:not(:disabled) {
  background: var(--accent);
  color: var(--text-primary);
  transform: scale(1.05) rotate(5deg);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

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

.btn-voice-mode {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: var(--spacing-sm);
}

.btn-voice-mode:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

/* ========================================
   👋 WELCOME MESSAGE
   ======================================== */
.welcome-message {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--spacing-2xl);
  background: var(--bg-secondary);
  border-radius: var(--radius-2xl);
  margin: var(--spacing-xl) auto;
  max-width: 600px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

.welcome-message h2 {
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  font-size: 1.75rem;
  font-weight: 700;
}

.welcome-message p {
  font-size: 1rem;
  color: var(--text-muted);
}

/* ========================================
   📋 CONTEXT MENU
   ======================================== */
.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xs);
  z-index: 1000;
  min-width: 180px;
  box-shadow: var(--shadow-xl);
  animation: menuAppear 0.2s ease;
}

@keyframes menuAppear {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.menu-item {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
  font-size: 0.875rem;
}

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

/* ========================================
   📚 SOURCES (compact et moderne)
   ======================================== */
.sources-container {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  overflow: hidden;
  transition: all 0.2s;
}

.sources-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
}

.sources-header h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-query {
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
}

.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin: var(--spacing-xs) 0;
}

.source-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-xs) var(--spacing-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 200px;
  max-width: 240px;
}

.source-item:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.source-favicon {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-sm);
  margin-right: 4px;
  vertical-align: middle;
}

.source-domain {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.source-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-snippet {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

.sources-footer {
  margin-top: var(--spacing-xs);
  padding-top: var(--spacing-xs);
  border-top: 1px solid var(--border-color);
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.source-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ========================================
   🎙️ MODAL VOCAL (MODE NORMAL) - VERSION MODERNE
   ======================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(12px); }
}

.glados-modal .modal-content {
  background: rgba(20, 24, 32, 0.9);
  backdrop-filter: blur(16px);
  border-radius: 32px;
  padding: 2rem;
  width: 90%;
  max-width: 900px;
  height: 80vh;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
}

.modal-close {
  position: absolute;
  top: 1.2rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  z-index: 10;
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  transform: scale(1.05);
}

/* Œil GLaDOS moderne */
.glados-lens {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 1.5rem;
  position: relative;
}

.glados-eye {
  width: 110px;
  height: 110px;
  background: radial-gradient(circle at 30% 30%, #1e293b, #0f172a);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5), 0 0 0 5px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.glados-pupil {
  width: 45px;
  height: 45px;
  background: radial-gradient(circle, #60a5fa, #3b82f6);
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.8);
  transition: transform 0.2s ease, background 0.2s ease;
}

/* États de l'œil */
.glados-eye.listening {
  box-shadow: 0 0 0 2px #3b82f6, 0 0 0 5px rgba(59, 130, 246, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
  animation: listeningPulse 1.2s infinite ease-in-out;
}

.glados-eye.listening .glados-pupil {
  background: radial-gradient(circle, #f97316, #ea580c);
  transform: scale(1.15);
  box-shadow: 0 0 20px #f97316;
}

.glados-eye.speaking {
  box-shadow: 0 0 0 2px #10b981, 0 0 0 5px rgba(16, 185, 129, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
  animation: speakingPulse 0.6s infinite alternate;
}

.glados-eye.speaking .glados-pupil {
  background: radial-gradient(circle, #34d399, #059669);
  transform: scale(0.9);
  box-shadow: 0 0 15px #10b981;
}

@keyframes listeningPulse {
  0% { box-shadow: 0 0 0 2px #3b82f6, 0 0 0 5px rgba(59, 130, 246, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 0 0 4px #3b82f6, 0 0 0 8px rgba(59, 130, 246, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.5); }
  100% { box-shadow: 0 0 0 2px #3b82f6, 0 0 0 5px rgba(59, 130, 246, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5); }
}

@keyframes speakingPulse {
  from { box-shadow: 0 0 0 2px #10b981, 0 0 0 5px rgba(16, 185, 129, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5); }
  to { box-shadow: 0 0 0 3px #10b981, 0 0 0 7px rgba(16, 185, 129, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.5); }
}

/* Zone de conversation */
.conversation-log {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 24px;
  padding: 1.2rem;
  margin: 0.5rem 0 1rem;
  overflow-y: auto;
  border: 1px solid rgba(59, 130, 246, 0.2);
  backdrop-filter: blur(4px);
}

.voice-messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Messages vocaux modernes */
.voice-message {
  padding: 0.8rem 1.2rem;
  border-radius: 24px;
  max-width: 85%;
  word-wrap: break-word;
  animation: slideUp 0.2s ease;
  font-size: 0.95rem;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.voice-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  color: white;
  border-bottom-right-radius: 4px;
}

.voice-message.assistant {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

/* Panneau de contrôle */
.voice-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
}

.voice-btn {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(59, 130, 246, 0.5);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.voice-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.3), transparent);
  transition: left 0.4s;
}

.voice-btn:hover::before {
  left: 100%;
}

.voice-btn:hover {
  transform: scale(1.05);
  border-color: #3b82f6;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

.voice-btn.active {
  animation: pulseBtn 1s infinite;
  border-color: #f97316;
  background: linear-gradient(135deg, #f97316, #ea580c);
  box-shadow: 0 0 20px #f97316;
}

@keyframes pulseBtn {
  0% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(249, 115, 22, 0); }
  100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}

.voice-btn svg {
  width: 32px;
  height: 32px;
  stroke: #e2e8f0;
  stroke-width: 1.5;
  fill: none;
}

.voice-btn.active svg {
  stroke: white;
}

.voice-status {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.4rem 1rem;
  border-radius: 40px;
  border-left: 2px solid #3b82f6;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
}

/* Scrollbar personnalisée pour le modal */
.conversation-log::-webkit-scrollbar {
  width: 4px;
}

.conversation-log::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
}

.conversation-log::-webkit-scrollbar-thumb {
  background: #3b82f6;
  border-radius: 10px;
}

/* Responsive */
@media (max-width: 768px) {
  .glados-modal .modal-content {
    width: 95%;
    height: 85vh;
    padding: 1.2rem;
    border-radius: 24px;
  }

  .glados-eye {
    width: 80px;
    height: 80px;
  }

  .glados-pupil {
    width: 35px;
    height: 35px;
  }

  .voice-btn {
    width: 56px;
    height: 56px;
  }

  .voice-btn svg {
    width: 28px;
    height: 28px;
  }

  .voice-message {
    max-width: 95%;
    font-size: 0.85rem;
  }

  .voice-status {
    font-size: 0.75rem;
  }
}

/* ========================================
   📄 PARAMÈTRES
   ======================================== */
.settings-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: var(--bg-primary);
}

.settings-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
}

.settings-card h1 {
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
  color: var(--text-primary);
}

.settings-section {
  margin: 2rem 0;
}

.settings-section h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.settings-section p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  transition: 0.4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: var(--text-primary);
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.status-msg {
  margin-left: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.settings-actions {
  margin-top: 2rem;
  text-align: center;
}

/* ========================================
   ❌ ERREURS
   ======================================== */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  text-align: center;
  padding: var(--spacing-xl);
  background: var(--bg-primary);
}

.error-container h1 {
  font-size: 2.5rem;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  font-weight: 700;
}

.error-container p {
  color: var(--text-secondary);
  font-size: 1.125rem;
  margin-bottom: var(--spacing-xl);
}

/* ========================================
   📱 RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    transition: left 0.4s;
    z-index: 100;
    height: 100%;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .message {
    max-width: 95%;
  }
  
  .chat-input-container {
    padding: var(--spacing-md);
  }
  
  #sendButton {
    width: 44px;
    height: 44px;
  }
}

/* ========================================
   🎨 SYNTAX HIGHLIGHTING
   ======================================== */
pre[class*="language-"] {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  margin: var(--spacing-md) 0 !important;
}

code[class*="language-"],
pre[class*="language-"] {
  font-family: var(--font-mono) !important;
  font-size: 0.875rem !important;
}

.token.comment { color: var(--text-muted) !important; }
.token.keyword { color: #8be9fd !important; }
.token.string { color: #50fa7b !important; }
.token.function { color: #bd93f9 !important; }
.token.number { color: #ff79c6 !important; }

/* ========================================
   🛑 BOUTON STOP TTS
   ======================================== */
.stop-btn {
  background: linear-gradient(135deg, #ff4757 0%, #e33e4d 100%) !important;
  transition: transform 0.2s;
}

.stop-btn:hover {
  transform: scale(1.1);
}


/* ========================================
   🎨 GÉNÉRATION D'IMAGES
   ======================================== */
.btn-image-gen {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0 16px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-image-gen:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: scale(1.02);
}

.image-params-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    width: 280px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    margin-bottom: 10px;
}
.params-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.params-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.params-close:hover {
    color: var(--error);
}
.param-group {
    margin-bottom: 12px;
}
.param-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-secondary);
}
.param-group input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
}
.param-group input[type="range"] {
    width: calc(100% - 40px);
    margin-right: 8px;
    vertical-align: middle;
}
.param-group span {
    display: inline-block;
    width: 32px;
    text-align: center;
    font-size: 0.9rem;
}
.param-group small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.btn-generate {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-full);
    padding: 8px 12px;
    width: 100%;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-generate:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}
.btn-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.message-content .generated-image {
    display: inline-block;
    text-align: center;
    max-width: 100%;
}

.message-content .generated-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.message-content .generated-image button {
    background: var(--accent, #3b82f6);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.message-content .generated-image button:hover {
    background: var(--accent-hover, #2563eb);
}






/* Placeholder de chargement pour les images */
.image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 200px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    margin: 10px 0;
    padding: 20px;
    animation: pulse 1.5s infinite;
}
.image-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid var(--accent, #3b82f6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.image-loading-text {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Grille d'images */
.generated-images-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}
.generated-images-grid .generated-image {
    flex: 1 1 300px;
    max-width: 100%;
    text-align: center;
}