/* ═══════════════════════════════════════════════════════════
   DWF IA — Stylesheet
   Style inspiré de Google Gemini
════════════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f0f4f9;
  --surface: #ffffff;
  --surface-hover: #f0f4f9;
  --border: #e0e4ea;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-tertiary: #9aa0a6;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-bg: #e8f0fe;
  --user-bubble: #e8f0fe;
  --model-bubble: transparent;
  --sidebar-bg: #f0f4f9;
  --sidebar-w: 280px;
  --header-h: 60px;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
  --transition: .2s ease;
  --font: 'Google Sans Text', 'Google Sans', 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg: #131314;
  --bg-secondary: #1e1f20;
  --bg-tertiary: #282a2c;
  --surface: #1e1f20;
  --surface-hover: #2d2e30;
  --border: #3c4043;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-tertiary: #5f6368;
  --accent: #8ab4f8;
  --accent-hover: #aecbfa;
  --accent-bg: #1a2940;
  --user-bubble: #1a2940;
  --model-bubble: transparent;
  --sidebar-bg: #1e1f20;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; height: 100dvh; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  display: flex;
  transition: background var(--transition), color var(--transition);
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color var(--transition);
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: none; }
a { color: var(--accent); text-decoration: none; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: width var(--transition), min-width var(--transition), transform var(--transition);
  overflow: hidden;
  position: relative;
  z-index: 100;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.sidebar-open-btn {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 10px;
  border-radius: 24px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
}
.new-chat-btn:hover { background: var(--surface-hover); }
.new-chat-btn .material-symbols-outlined { font-size: 22px; color: var(--accent); }

.sidebar-section {
  padding: 2px 8px;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.sidebar-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 12px;
  flex-shrink: 0;
}

/* Quand l'historique est réduit, les agents épinglés prennent tout l'espace (desktop uniquement) */
@media (min-width: 769px) {
  .sidebar:has(#historySection.collapsed) #pinnedAgentsSection {
    flex: 1;
    min-height: 0;
  }
  .sidebar:has(#historySection.collapsed) #pinnedAgentsSection .agents-list {
    max-height: none;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }
}

/* La section Récent prend l'espace restant et scroll en interne */
#historySection {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#historySection.collapsed {
  flex: 0 0 auto;
  overflow: hidden;
}
#historySection.collapsed .history-search-wrap,
#historySection.collapsed .conversations-list {
  display: none;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.sidebar-section-title .material-symbols-outlined { font-size: 14px; }

.sidebar-section-toggle {
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  touch-action: manipulation;
}
.sidebar-section-toggle:hover { color: var(--text-primary); background: var(--surface-hover); }

@media (max-width: 768px) {
  .sidebar-section-toggle {
    min-height: 44px;
    padding: 0 8px;
  }
  .sidebar-chevron {
    font-size: 24px !important;
  }
}

.sidebar-chevron {
  margin-left: auto;
  font-size: 16px !important;
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
#pinnedAgentsSection.collapsed .sidebar-chevron { transform: rotate(-90deg); }

.pinned-agents-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  background: var(--surface-hover);
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: 2px;
}

/* Agents list in sidebar */
.agents-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 192px;
  overflow-y: auto;
  transition: max-height 0.2s ease, opacity 0.15s ease;
}
#pinnedAgentsSection.collapsed .agents-list {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}

.agent-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
  color: var(--text-primary);
}
.agent-sidebar-item:hover { background: var(--surface-hover); }
.agent-sidebar-item.active { background: var(--accent-bg); color: var(--accent); }
.agent-sidebar-item.dragging { opacity: 0.45; }

.agent-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.agent-avatar .material-symbols-outlined { font-size: 14px; }

/* Conversations list */
.conv-group { margin-bottom: 4px; }
.conv-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
  transition: background var(--transition);
}
.conv-group-header:hover { background: var(--surface-hover); color: var(--text-secondary); }
.conv-group-icon { font-size: 13px; }
.conv-group-name { flex: 1; }
.conv-group-count {
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
}
.conv-group-chevron {
  font-size: 16px;
  transition: transform var(--transition);
}
.conv-group-header.collapsed .conv-group-chevron { transform: rotate(-90deg); }
.conv-group-body { padding-left: 6px; }

.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
  color: var(--text-secondary);
  gap: 4px;
}
.conversation-item:hover { background: var(--surface-hover); }
.conversation-item.active { background: var(--accent-bg); color: var(--accent); }

/* Icône épingle */
.conv-pin-icon {
  font-size: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
}
.conversation-item:hover .conv-pin-icon,
.conversation-item.pinned .conv-pin-icon { opacity: 1; }
.conversation-item.pinned .conv-pin-icon { color: var(--accent); }
.conv-pin-icon:hover { color: var(--accent); background: var(--accent-bg); }

.conversation-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Champ de renommage inline */
.conv-rename-input {
  flex: 1;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  outline: none;
  min-width: 0;
}

/* Actions (renommer + supprimer) */
.conv-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.conversation-item:hover .conv-actions { opacity: 1; }

.conv-action-btn {
  display: flex;
  align-items: center;
  padding: 3px;
  border-radius: 4px;
  color: var(--text-tertiary);
  transition: color var(--transition), background var(--transition);
}
.conv-action-btn .material-symbols-outlined { font-size: 14px; }
.conv-action-btn:hover { background: var(--surface-hover); }
.conv-rename-btn:hover { color: var(--accent); }
.conv-delete-btn:hover { color: #ea4335; }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 6px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--transition);
  white-space: nowrap;
}
.sidebar-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.sidebar-item .material-symbols-outlined { font-size: 20px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  transition: background var(--transition);
}

.main-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg);
}

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  height: 24px;
  width: auto;
  object-fit: contain;
  display: block;
}

.header-agent-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.header-agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--accent-bg);
  color: var(--accent);
  width: fit-content;
}
.header-agent-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
  padding-left: 4px;
}

.header-actions { display: flex; gap: 4px; }

/* ── Chat container ─────────────────────────────────────────── */
.chat-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ── Welcome screen ─────────────────────────────────────────── */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.welcome-agent-icon {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin-bottom: 24px;
}

.welcome-title {
  font-size: 36px;
  font-weight: 400;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #CEE44A 0%, #C4A129 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  margin-bottom: 36px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  max-width: 700px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.chip:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.chip .material-symbols-outlined { font-size: 18px; }

/* ── Messages ────────────────────────────────────────────────── */
.messages-container {
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.message {
  display: flex;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  animation: fadeIn .3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  flex-direction: row-reverse;
  align-self: flex-end;
  max-width: 80%;
}

.message.user .message-content {
  background: var(--user-bubble);
  border-radius: 18px 18px 4px 18px;
  padding: 12px 16px;
  color: var(--text-primary);
}

.message.model .message-content {
  background: var(--model-bubble);
  padding: 4px 0;
  flex: 1;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
}

.message.model .message-avatar {
  background: var(--bg-tertiary);
}
.message.model .message-avatar .material-symbols-outlined {
  font-size: 18px;
  color: white;
}
.message-avatar-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0.85;
}

.message.user .message-avatar {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.message-body { flex: 1; min-width: 0; }

.message-text {
  line-height: 1.7;
  font-size: 15px;
  color: var(--text-primary);
}

.message-text p { margin-bottom: 12px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Google Sans Mono', monospace;
}
.message-text pre {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0;
}
.message-text pre code { background: none; padding: 0; }
.message-text ul, .message-text ol { padding-left: 20px; margin-bottom: 12px; }
.message-text li { margin-bottom: 4px; }
.message-text h1, .message-text h2, .message-text h3 {
  font-weight: 600;
  margin-bottom: 8px;
  margin-top: 16px;
}
.message-text strong { font-weight: 600; }
.message-text del { text-decoration: line-through; color: var(--text-secondary); }
.message-text blockquote {
  border-left: 3px solid var(--border);
  padding: 4px 12px;
  margin: 10px 0;
  color: var(--text-secondary);
}
.message-text hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Tableaux Markdown ─────────────────────────────────────── */

.md-table-outer {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.md-table-actions {
  display: flex;
  justify-content: flex-end;
  padding: 6px 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.md-table-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.md-table-copy-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.md-table-copy-btn.copied {
  color: #1e8e3e;
  border-color: #1e8e3e;
  background: rgba(30,142,62,.07);
}
.md-table-copy-btn .material-symbols-outlined {
  font-size: 14px;
}

.md-table-scroll {
  overflow-x: auto;
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.md-table thead {
  background: var(--bg-tertiary);
}

.md-table th {
  padding: 9px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.md-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: top;
}

.md-table tbody tr:last-child td {
  border-bottom: none;
}

.md-table tbody tr:nth-child(even) {
  background: var(--bg-secondary);
}

.md-table tbody tr:hover {
  background: var(--accent-bg);
}

/* Sources RAG */
.sources-container {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
}

.sources-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sources-title .material-symbols-outlined { font-size: 14px; }

.source-item {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.source-item:last-child { margin-bottom: 0; }

.source-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.source-content a {
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}
.source-snippet { color: var(--text-secondary); }

/* Actions de message */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}
.message:hover .message-actions { opacity: 1; }

.message-action-btn {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-tertiary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
}
.message-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.message-action-btn .material-symbols-outlined { font-size: 16px; }
.msg-token-count {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-tertiary);
  opacity: 0.7;
  pointer-events: none;
}
.msg-token-count .material-symbols-outlined { font-size: 13px; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 14px;
  padding: 12px 16px;
}
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

.thinking-block {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.thinking-block summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.thinking-block summary::-webkit-details-marker { display: none; }
.thinking-block summary .material-symbols-outlined { font-size: 16px; color: var(--accent); }
.thinking-content {
  margin: 0;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid var(--border);
  max-height: 300px;
  overflow-y: auto;
  font-family: inherit;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .6; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input area ─────────────────────────────────────────────── */
.input-area {
  padding: 12px 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.input-wrapper {
  max-width: 900px;
  margin: 0 auto;
}

.input-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  min-height: 0;
}
.input-meta-row:empty,
.input-meta-row:has(.hidden:only-child),
.input-meta-row:has(> .hidden ~ .hidden) { display: none; }

.active-agent-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--accent-bg);
  color: var(--accent);
  width: fit-content;
}
.active-agent-chip .material-symbols-outlined { font-size: 16px; }

.remove-agent-btn {
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 50%;
  color: var(--accent);
  transition: background var(--transition);
}
.remove-agent-btn:hover { background: rgba(26,115,232,.15); }
.remove-agent-btn .material-symbols-outlined { font-size: 14px; }

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 12px 12px 18px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,115,232,.1);
}

#messageInput {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 15px;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: hidden; /* géré dynamiquement par JS */
  padding: 0;
  color: var(--text-primary);
  resize: none;
}
#messageInput::placeholder { color: var(--text-tertiary); }

.input-actions { display: flex; align-items: center; gap: 4px; }

.input-action-btn {
  color: var(--text-tertiary);
  transition: color var(--transition);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.input-action-btn:hover {
  color: var(--accent);
  background: var(--accent-bg);
}
.input-action-btn .material-symbols-outlined { font-size: 20px; }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}
.send-btn:disabled { background: var(--border); cursor: not-allowed; }
.send-btn .material-symbols-outlined { font-size: 18px; }

.input-disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS & ICONS
════════════════════════════════════════════════════════════ */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.icon-btn .material-symbols-outlined { font-size: 22px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
}
.btn .material-symbols-outlined { font-size: 18px; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }

.btn-danger {
  background: #fce8e6;
  color: #d32f2f;
}
.btn-danger:hover { background: #f5c6c3; }

/* ═══════════════════════════════════════════════════════════
   MODALS
════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(4px);
  animation: overlayIn .2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}

.modal-large { max-width: 760px; }
.modal-xl { max-width: min(96vw, 1380px); }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}
.modal-header h2 .material-symbols-outlined { color: var(--accent); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Form styles */
.form-group { margin-bottom: 20px; }
.form-group label:not(.agent-toggle-label) {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
}
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
  background: var(--bg);
}
.form-group textarea { min-height: 100px; resize: vertical; }

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.agent-toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  color: var(--text-secondary);
}

.datastore-disabled { opacity: 0.45; pointer-events: none; }
.datastore-disabled select { cursor: not-allowed; }
.feature-disabled { opacity: 0.4; pointer-events: none; }
.rag-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.rag-option-item { display: flex; flex-direction: column; gap: 4px; }
.form-sublabel { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* ── Section N8N webhook ─────────────────────────────────────── */
.n8n-section {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  background: var(--bg-secondary);
}
.n8n-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.n8n-section-header .material-symbols-outlined { font-size: 18px; color: #e8742a; }
.n8n-badge-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #e8742a;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* Color picker */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform var(--transition), border-color var(--transition);
  cursor: pointer;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--text-primary); transform: scale(1.15); }

/* Datastore selector */
.datastore-selector { display: flex; gap: 8px; align-items: center; }
.datastore-selector select { flex: 1; }

/* ── Agents grid ─────────────────────────────────────────────── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.agent-card {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.agent-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.agent-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: white;
}
.agent-card-avatar .material-symbols-outlined { font-size: 20px; }

.agent-card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.agent-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.agent-card-rag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: #e6f4ea;
  color: #137333;
  font-weight: 500;
}
.agent-card-rag .material-symbols-outlined { font-size: 12px; }

.agent-n8n-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: #fff3e0;
  color: #e8742a;
  font-weight: 500;
}
.agent-n8n-badge .material-symbols-outlined { font-size: 12px; }

.agent-card-tags { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.agent-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
}

.agents-tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.agent-tag-filter-btn {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.agent-tag-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.agent-tag-filter-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ── Follow-up suggestion chips ── */
.followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.followup-chip {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}
.followup-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.agent-preview-tooltip {
  position: absolute;
  z-index: 9998;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow-lg);
  text-align: left;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-preview-tooltip.hidden { display: none; }
.agent-card-preview .agent-preview-prompt,
.agent-preview-tooltip .agent-preview-prompt {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.agent-card-preview .agent-preview-meta,
.agent-preview-tooltip .agent-preview-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
}
.agent-card-preview .agent-preview-meta .material-symbols-outlined,
.agent-preview-tooltip .agent-preview-meta .material-symbols-outlined { font-size: 13px; }

.agent-card-actions {
  display: flex;
  gap: 4px;
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}
.agent-card:hover .agent-card-actions { opacity: 1; }

.agent-card-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text-tertiary);
  transition: all var(--transition);
}
.agent-card-btn:hover { color: var(--text-primary); background: var(--surface-hover); }
.agent-card-btn.pinned { color: var(--accent); }
.agent-card-btn .material-symbols-outlined { font-size: 16px; }

.add-agent-btn {
  width: 100%;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
}
.add-agent-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ═══════════════════════════════════════════════════════════
   DOCUMENT EDITOR
════════════════════════════════════════════════════════════ */
.docs-modal-body { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
#docsStep1 { padding: 24px; }
#docsStep2 { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.doc-type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.doc-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px;
  font-weight: 500;
}
.doc-type-btn .material-symbols-outlined { font-size: 32px; }
.doc-type-btn small { font-size: 12px; color: var(--text-tertiary); }
.doc-type-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.doc-type-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

/* Doc editor toolbar */
.doc-editor-container { display: flex; flex-direction: column; height: 100%; }

.doc-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 12px; }

.doc-title-display {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.doc-type-badge {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  background: var(--accent);
  color: white;
  letter-spacing: .05em;
}

/* DOCX editor */
.doc-editor { flex: 1; overflow: hidden; }

.docx-preview {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px;
  height: 100%;
  overflow-y: auto;
}

.docx-title-input {
  width: 100%;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 8px 0;
  margin-bottom: 24px;
  transition: border-color var(--transition);
  border-radius: 0;
}
.docx-title-input:focus { border-bottom-color: var(--accent); outline: none; }

.docx-section { margin-bottom: 24px; }

.docx-section-heading {
  width: 100%;
  font-size: 18px;
  font-weight: 600;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  padding: 4px 0;
  margin-bottom: 10px;
  color: var(--text-primary);
  transition: border-color var(--transition);
  border-radius: 0;
}
.docx-section-heading:focus { border-bottom-color: var(--accent); outline: none; }

.docx-para {
  width: 100%;
  font-size: 14px;
  line-height: 1.8;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-primary);
  margin-bottom: 8px;
  transition: all var(--transition);
  min-height: 80px;
  border-radius: 6px;
}
.docx-para:focus {
  border-color: var(--accent);
  background: var(--bg-secondary);
  outline: none;
}

.docx-add-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-tertiary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
}
.docx-add-section:hover { border-color: var(--accent); color: var(--accent); }

/* PPTX editor */
.pptx-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.slides-panel {
  width: 180px;
  min-width: 180px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow: hidden;
}

.slides-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}

.slides-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slide-thumb {
  aspect-ratio: 16/9;
  border-radius: 6px;
  border: 2px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  background: white;
  padding: 6px;
  position: relative;
}
.slide-thumb:hover { border-color: var(--accent); }
.slide-thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }

.slide-thumb-number {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 9px;
  color: var(--text-tertiary);
}

.slide-thumb-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.slide-thumb-title {
  font-size: 7px;
  font-weight: 600;
  color: #1a73e8;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.slide-thumb-line {
  height: 2px;
  border-radius: 1px;
  background: var(--border);
}

/* Slide editor */
.slide-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 0;
}

.slide-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  padding: 24px;
  overflow: hidden;
}

.slide-canvas {
  aspect-ratio: 16/9;
  width: 100%;
  max-width: 640px;
  background: white;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.slide-canvas-header {
  background: #1a73e8;
  color: white;
  padding: 16px 20px 12px;
  flex-shrink: 0;
}
.slide-canvas-title { font-size: 18px; font-weight: 700; }

.slide-canvas-body {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}
.slide-canvas-bullet {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #202124;
  align-items: flex-start;
}
.slide-canvas-bullet::before {
  content: '•';
  color: #1a73e8;
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1.3;
}

.slide-fields {
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  overflow-y: auto;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slide-field-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}

.slide-title-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg);
}

.slide-bullets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slide-bullet-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.slide-bullet-input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
}

.slide-bullet-del {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: all var(--transition);
}
.slide-bullet-del:hover { color: #ea4335; background: #fce8e6; }
.slide-bullet-del .material-symbols-outlined { font-size: 16px; }

.slide-add-bullet {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 4px;
  cursor: pointer;
  transition: color var(--transition);
}
.slide-add-bullet:hover { color: var(--accent); }
.slide-add-bullet .material-symbols-outlined { font-size: 16px; }

/* Loading */
#docsLoading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.loading-animation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.loading-animation p { font-size: 16px; font-weight: 500; color: var(--text-primary); }
.loading-animation small { color: var(--text-tertiary); }

.gemini-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285F4, #9C27B0, #E91E63, #FBBC04);
  animation: spinnerRotate 1s linear infinite;
  position: relative;
}
.gemini-spinner::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--bg);
}

@keyframes spinnerRotate { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  animation: toastIn .3s ease;
  min-width: 280px;
  border-left: 4px solid var(--accent);
}
.toast.success { border-color: #34a853; }
.toast.error { border-color: #ea4335; }
.toast.warning { border-color: #fbbc04; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════════════════════
   APP WRAPPER
════════════════════════════════════════════════════════════ */
.app-wrapper {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   LOGIN SCREEN
════════════════════════════════════════════════════════════ */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 90%;
  text-align: center;
}

.login-logo {
  margin-bottom: 8px;
}

.login-agent-icon {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.login-title {
  font-size: 32px;
  font-weight: 600;
  background: linear-gradient(135deg, #CEE44A 0%, #C4A129 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.entra-signin-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: var(--shadow);
  margin-top: 8px;
}
.entra-signin-btn:hover {
  background: var(--surface-hover);
  border-color: #2564cf;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.login-note {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   USER PROFILE IN SIDEBAR
════════════════════════════════════════════════════════════ */
.user-profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285F4, #9C27B0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { flex: 1; overflow: hidden; }

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-token-pct {
  font-size: 10px;
  color: var(--text-tertiary);
}
.user-token-pct.token-pct--warning { color: #f59e0b; }
.user-token-pct.token-pct--danger  { color: #ef4444; }

.logout-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--text-tertiary);
}
.logout-btn:hover { color: #ea4335; background: #fce8e6; }
.logout-btn .material-symbols-outlined { font-size: 18px; }

/* ═══════════════════════════════════════════════════════════
   ADMIN PANEL
════════════════════════════════════════════════════════════ */
.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.admin-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: all var(--transition);
}
.admin-tab:hover { color: var(--text-primary); background: var(--surface-hover); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-tab .material-symbols-outlined { font-size: 16px; }

.admin-section-header { margin-bottom: 12px; }
.admin-section-header h3 { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.admin-section-desc { font-size: 13px; color: var(--text-secondary); }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 24px;
}
.settings-row-info { display: flex; flex-direction: column; gap: 3px; }
.settings-row-label { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.settings-row-desc { font-size: 13px; color: var(--text-secondary); }

/* Légende des permissions */

/* ═══ ADMIN UTILISATEURS — MASTER / DETAIL ═══ */

.users-layout {
  display: flex;
  height: calc(100vh - 220px);
  min-height: 400px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
}

/* ── Panneau gauche (liste) ── */
.users-master-panel {
  width: 300px;
  min-width: 280px;
  flex-shrink: 0;
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

.users-master-toolbar {
  padding: 12px;
  border-bottom: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.users-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  transition: border-color var(--transition);
}
.users-search-wrap:focus-within { border-color: var(--accent); }
.users-search-wrap .material-symbols-outlined { font-size: 16px; color: var(--text-tertiary); }
.users-search-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}

.users-role-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.role-filter-chip {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.role-filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.role-filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.users-list {
  flex: 1;
  overflow-y: auto;
}

.users-list-empty {
  padding: 24px 16px;
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
}

.users-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.users-list-item:hover { background: var(--surface-hover); }
.users-list-item.active { background: var(--accent-bg); border-left: 3px solid var(--accent); padding-left: 11px; }
.users-list-item.bulk-selected { background: var(--accent-bg); }
.users-list-checkbox { flex-shrink: 0; width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

.users-bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--accent-bg);
  border-bottom: 1px solid var(--accent);
  flex-wrap: wrap;
}
.users-bulk-count { font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.users-bulk-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.users-bulk-group-select { font-size: 12px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-primary); color: var(--text-primary); max-width: 160px; }

.users-list-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285F4, #9C27B0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}
.users-list-avatar img { width: 100%; height: 100%; object-fit: cover; }

.users-list-info { flex: 1; overflow: hidden; }
.users-list-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.users-list-email { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.users-list-group { display: flex; align-items: center; gap: 2px; font-size: 10px; color: var(--accent); margin-top: 2px; }
.users-list-group .material-symbols-outlined { font-size: 11px; }

.users-list-role {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
  background: var(--accent-bg);
  color: var(--accent);
}
.users-list-role.admin { background: #fce8e620; color: #d32f2f; border: 1px solid #d32f2f40; }
.users-list-role.superadmin { background: #9c27b020; color: #9c27b0; border: 1px solid #9c27b040; }
.users-list-role.user { background: var(--accent-bg); color: var(--accent); border: 1px solid rgba(66,133,244,.2); }

/* ── Panneau droit (détail) ── */
.users-detail-panel {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.users-back-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  width: 100%;
  text-align: left;
}
.users-back-btn:hover { background: var(--accent-bg); }
.users-back-btn .material-symbols-outlined { font-size: 18px; }

.users-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-tertiary);
  padding: 48px;
}
.users-detail-empty .material-symbols-outlined { font-size: 48px; opacity: .4; }
.users-detail-empty p { font-size: 14px; }

.users-detail-content { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

/* ── Header utilisateur dans le détail ── */
.detail-user-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1.5px solid var(--border);
}
.detail-user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285F4, #9C27B0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}
.detail-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-user-info { flex: 1; }
.detail-user-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.detail-user-email { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* ── Sections du détail ── */
.detail-section {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
}
.detail-section-title .material-symbols-outlined { font-size: 15px; color: var(--accent); }

.detail-edit-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.detail-edit-btn:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.detail-edit-btn .material-symbols-outlined { font-size: 13px; }

/* ═══ FIN MASTER / DETAIL ═══ */

/* Ancienne table — conservé pour compatibilité badges existants */
.user-perm-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  flex: 1;
}

.user-perm-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285F4, #9C27B0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}
.user-perm-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-perm-details { overflow: hidden; }
.user-perm-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-perm-email {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-group-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  padding: 1px 7px;
  border-radius: 12px;
  background: rgba(66,133,244,.12);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid rgba(66,133,244,.25);
}
.user-group-badge .material-symbols-outlined { font-size: 12px; }

.user-perm-role {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}
.user-perm-role.admin { background: #fce8e6; color: #d32f2f; }
.user-perm-role.user { background: var(--accent-bg); color: var(--accent); }

.user-perm-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  min-width: 140px;
}

.perm-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 6px;
  transition: background var(--transition);
  cursor: pointer;
}
.perm-checkbox-wrap:hover { background: var(--surface-hover); }

.perm-toggle-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  flex: 1;
}

.perm-toggle-label .material-symbols-outlined {
  font-size: 14px;
  color: var(--text-tertiary);
}

.perm-checkbox-wrap:has(input:checked) .perm-toggle-label {
  color: var(--text);
}

.perm-checkbox-wrap:has(input:checked) .perm-toggle-label .material-symbols-outlined {
  color: var(--accent);
}

/* Toggle switch style */
.perm-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
}
.perm-toggle input { opacity: 0; width: 0; height: 0; }
.perm-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  transition: background var(--transition);
}
.perm-toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.perm-toggle input:checked + .perm-toggle-slider { background: var(--accent); }
.perm-toggle input:checked + .perm-toggle-slider::before { transform: translateX(16px); }

.user-perm-role-select {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   WORKFLOW BUILDER
════════════════════════════════════════════════════════════ */

.modal-workflow-fullscreen {
  max-width: calc(100vw - 32px);
  width: 100%;
  max-height: calc(100vh - 32px);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.workflow-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-selector {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 200px;
  max-width: 280px;
}

/* Builder 3-column layout */
.workflow-builder-body {
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  flex: 1;
  overflow: hidden;
  border-top: 1px solid var(--border);
}

/* ── Left panel ── */
.workflow-agent-list {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow: hidden;
}

.workflow-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.workflow-panel-title .material-symbols-outlined { font-size: 16px; color: var(--accent); }

.workflow-agent-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workflow-agent-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: grab;
  transition: all var(--transition);
  user-select: none;
}
.workflow-agent-chip:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: translateX(2px);
}
.workflow-agent-chip:active { cursor: grabbing; }

.workflow-agent-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Canvas ── */
.workflow-canvas-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.workflow-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.workflow-connect-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.workflow-connect-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.workflow-connect-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.workflow-connect-btn .material-symbols-outlined { font-size: 16px; }

.workflow-canvas-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
}

.workflow-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 400px;
}

/* SVG overlay for edge lines */
.workflow-edges-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.workflow-edge-line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 3;
  opacity: .7;
}
.workflow-edge-seq {
  stroke-dasharray: none;
  stroke-width: 2.5;
  opacity: 1;
}

/* ── Nodes on canvas ── */
.workflow-node {
  position: absolute;
  width: 150px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: move;
  user-select: none;
  z-index: 2;
  transition: border-color var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  box-shadow: var(--shadow);
}
.workflow-node:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }

.workflow-node.orchestrator {
  border-color: #fbbc04;
  box-shadow: 0 0 0 3px rgba(251,188,4,.2), var(--shadow-lg);
}
.workflow-node.connect-source { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,115,232,.25); }

.workflow-node-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.workflow-node-avatar .material-symbols-outlined { font-size: 18px; }

.workflow-node-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.3;
}

/* ── Workflow mode toggle ── */
.workflow-mode-toggle {
  display: flex;
  gap: 8px;
}
.workflow-mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
}
.workflow-mode-option:hover { border-color: var(--accent); background: var(--accent-bg); }
.workflow-mode-option:has(input:disabled) { opacity: 0.6; cursor: default; pointer-events: none; }
.workflow-mode-option input[type="radio"] { display: none; }
.workflow-mode-option:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.workflow-mode-option .material-symbols-outlined { font-size: 20px; flex-shrink: 0; }
.workflow-mode-option strong { display: block; font-size: 12px; font-weight: 600; }
.workflow-mode-option small { display: block; font-size: 10px; opacity: 0.7; }

/* ── Sequential node badge ── */
.workflow-node-seq-num {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.workflow-node-crown {
  font-size: 14px;
  color: #fbbc04;
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border-radius: 50%;
  line-height: 1;
}

.workflow-node-actions {
  display: flex;
  gap: 2px;
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.workflow-node:hover .workflow-node-actions { opacity: 1; }

.workflow-node-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  transition: all var(--transition);
  border: none;
}
.workflow-node-btn:hover { color: var(--text-primary); background: var(--surface-hover); }
.workflow-node-btn.set-orchestrator:hover { color: #fbbc04; }
.workflow-node-btn.remove-node:hover { color: #ea4335; background: #fce8e6; }
.workflow-node-btn .material-symbols-outlined { font-size: 13px; }

/* ── Right panel ── */
.workflow-properties {
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow-y: auto;
  padding: 0;
}

.workflow-properties .workflow-panel-title {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.workflow-properties .form-group {
  padding: 0 14px;
  margin-bottom: 16px;
}
.workflow-properties .form-group:first-of-type { margin-top: 12px; }

.workflow-orchestrator-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 38px;
}
.workflow-orchestrator-display .material-symbols-outlined { font-size: 16px; color: #fbbc04; }

/* ── Utilisateurs assignés au workflow ──────────────────── */
.wf-users-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  margin-left: 6px;
}
.wf-users-assigned {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  margin-bottom: 8px;
}
.wf-no-assigned { font-size: 12px; color: var(--text-tertiary); align-self: center; }
.wf-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 10px;
  border-radius: 20px;
  background: var(--accent-light, rgba(66,133,244,.12));
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--accent-muted, rgba(66,133,244,.25));
}
.wf-user-badge-remove {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 15px; line-height: 1;
  padding: 0 2px; opacity: .6; transition: opacity .15s;
}
.wf-user-badge-remove:hover { opacity: 1; }

.wf-users-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1.5px solid var(--border);
  border-radius: 8px 8px 0 0;
  border-bottom: none;
  background: var(--surface);
}
.wf-users-search-wrap .material-symbols-outlined { font-size: 16px; color: var(--text-tertiary); }
.wf-users-search-wrap input {
  flex: 1; border: none; background: transparent;
  padding: 7px 0; font-size: 13px; color: var(--text);
  outline: none;
}

.workflow-users-select {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px;
  border: 1.5px solid var(--border);
  border-radius: 0 0 8px 8px;
  background: var(--bg);
}

.workflow-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 5px 6px;
  border-radius: 6px;
  transition: background var(--transition);
  cursor: pointer;
}
.workflow-user-item:hover { background: var(--surface-hover); }
.workflow-user-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.wf-user-name { flex: 1; font-size: 13px; }
.wf-user-email { font-size: 11px; color: var(--text-tertiary); }

/* ── Workflow mode toggle (grille 2 colonnes) ────────────── */
.workflow-mode-toggle {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Workflow slots canvas (modes parallèle / synthèse) ──── */
.wf-slots-canvas {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  height: 100%;
  padding: 24px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.wf-slots-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}
.wf-synthesis-slot-row {
  display: flex;
  justify-content: center;
  width: 100%;
}
.wf-drop-slot {
  width: 160px;
  min-height: 120px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.wf-drop-slot:hover, .wf-drop-slot.drag-over {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.wf-drop-slot.wf-slot-filled {
  border-style: solid;
  background: var(--surface);
}
.wf-synthesis-slot {
  width: 200px;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.wf-synthesis-slot.wf-slot-filled { background: var(--surface); }
.wf-slot-icon { font-size: 28px; color: var(--text-tertiary); }
.wf-slot-label { font-size: 12px; font-weight: 500; color: var(--text-tertiary); text-align: center; }
.wf-slot-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.wf-slot-name { font-size: 12px; font-weight: 600; text-align: center; word-break: break-word; line-height: 1.3; }
.wf-slot-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 0;
  display: flex;
  align-items: center;
  line-height: 1;
}
.wf-slot-remove:hover { color: var(--danger); }
.wf-slot-remove .material-symbols-outlined { font-size: 16px; }

/* ── Options workflow (streamSteps, canvas) ─────────────── */
.wf-options-group { padding-bottom: 0 !important; margin-bottom: 10px !important; }

.wf-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.wf-option-text {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
}
.wf-option-text .material-symbols-outlined {
  font-size: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.wf-option-text div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wf-option-text span { font-size: 12px; font-weight: 500; color: var(--text-primary); line-height: 1.3; }
.wf-option-text small { font-size: 10px; color: var(--text-tertiary); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.toggle-switch { position: relative; display: inline-block; width: 34px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 10px;
  transition: background .2s;
  cursor: pointer;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(14px); }

/* ── Chat : messages workflow en étapes (streamSteps) ──── */
.wf-steps-message .message-body { flex: 1; }
.wf-steps-list { display: flex; flex-direction: column; gap: 12px; }

.wf-step {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.wf-step-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
}
.wf-step-header .material-symbols-outlined { font-size: 16px; color: var(--accent); }
.wf-step-agent { flex: 1; }
.wf-step-canvas-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 11px; font-weight: 500;
  background: var(--accent-bg); color: var(--accent);
  transition: background var(--transition);
}
.wf-step-canvas-btn:hover { background: var(--accent); color: #fff; }
.wf-step-canvas-btn .material-symbols-outlined { font-size: 13px; }
.wf-step-badge {
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--surface);
  border-radius: 20px;
  padding: 2px 8px;
}
.wf-step-body { padding: 10px 14px; font-size: 14px; line-height: 1.6; }
.wf-step-loading { opacity: 0.75; }
.wf-step-typing { display: flex; align-items: center; gap: 4px; min-height: 36px; }
.wf-step-sources { padding: 0 14px 10px; }

/* ═══ GROUPES ADMIN ═══════════════════════════════════════ */
.groups-panel {
  display: flex;
  gap: 16px;
  min-height: 400px;
}

/* ── Colonne liste ── */
.groups-list-col {
  display: flex;
  flex-direction: column;
  width: 260px;
  flex-shrink: 0;
}
.groups-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.groups-list-header h3 { margin: 0; font-size: 15px; }
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background var(--transition);
}
.btn-ghost:hover { background: var(--surface-hover); }

.group-create-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.group-create-form .form-control { flex: 1; min-width: 0; }
.group-create-actions { display: flex; gap: 6px; }

.groups-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}
.groups-empty {
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 12px;
}
.group-card {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.group-card:hover { border-color: var(--accent); background: var(--accent-bg); }
.group-card.active { border-color: var(--accent); background: var(--accent-bg); }
.group-card-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}
.group-card-name .material-symbols-outlined { font-size: 16px; color: var(--accent); }
.group-card-env { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--accent); margin-top: 3px; }
.group-card-env .material-symbols-outlined { font-size: 12px; }
.group-card-desc { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.group-card-meta { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* ── Colonne détail ── */
.group-detail {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  min-width: 0;
}
.group-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.group-detail-header h4 { flex: 1; font-size: 15px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-danger-sm {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 6px; border: 1px solid #ea4335;
  background: transparent; color: #ea4335; font-size: 12px; cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}
.btn-danger-sm:hover { background: #ea433520; }
.btn-danger-sm .material-symbols-outlined { font-size: 15px; }

.group-detail-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.group-section > label:first-child {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.group-perms-list { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; }
.group-perms-list .perm-checkbox-wrap { flex-direction: column; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-secondary); gap: 6px; }
.group-perms-list .perm-checkbox-wrap:has(input:checked:not(:disabled)) { border-color: var(--accent); background: var(--accent-bg); }
.group-perms-list .perm-toggle-label { flex-direction: column; align-items: center; gap: 3px; font-size: 11px; text-align: center; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .groups-panel { flex-direction: column; gap: 12px; min-height: unset; }
  .groups-list-col { width: 100%; }
  .groups-list { max-height: 280px; }
  .group-create-form { flex-direction: column; align-items: stretch; }
  .group-create-form .form-control { width: 100%; }
  .group-create-actions { justify-content: flex-end; }
  .group-detail { border-radius: var(--radius); min-height: 0; }
  .group-detail-header { padding: 10px 12px; }
  .group-detail-body { padding: 12px; gap: 12px; }
  .group-perms-list { gap: 6px; }
  .group-perms-list .perm-checkbox-wrap { padding: 8px 12px; }
  .btn-danger-sm span:not(.material-symbols-outlined) { display: none; }
}

/* ═══ BANNIÈRE MISE À JOUR SW ══════════════════════════════ */
.sw-update-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  white-space: nowrap;
  animation: slideUp .25s ease;
  font-size: 14px;
}
.sw-update-banner .material-symbols-outlined { color: var(--accent); font-size: 20px; }
.sw-update-reload {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.sw-update-reload:hover { opacity: .85; }
.sw-update-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  padding: 2px;
  transition: color .15s;
}
.sw-update-close:hover { color: var(--text); }
.sw-update-close .material-symbols-outlined { font-size: 18px; }

@media (max-width: 480px) {
  .sw-update-banner { bottom: 72px; left: 12px; right: 12px; transform: none; font-size: 13px; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@media (max-width: 480px) {
  @keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ═══ IMAGES GÉNÉRÉES ══════════════════════════════════════ */
.generated-images-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}
.generated-image-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}
.generated-image {
  max-width: 100%;
  max-height: 520px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  display: block;
  cursor: zoom-in;
}
.generated-image-actions {
  display: flex;
  gap: 8px;
}
.generated-img-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.generated-img-btn:hover { background: var(--surface-hover); border-color: var(--accent); color: var(--accent); }
.generated-img-btn .material-symbols-outlined { font-size: 15px; }

/* ═══════════════════════════════════════════════════════════
   UTILITIES
════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   TOAST — PERSISTENT ERROR + CLOSE BUTTON
════════════════════════════════════════════════════════════ */
.toast-message { flex: 1; }
.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text-primary); background: var(--surface-hover); }

/* ═══════════════════════════════════════════════════════════
   SSE INTERRUPTED MESSAGE (Feature 6)
════════════════════════════════════════════════════════════ */
.message.interrupted .message-content {
  border-left: 3px solid #f59e0b;
  padding-left: 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.message-interrupted-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.interrupted-label {
  font-size: 13px;
  color: #b45309;
  font-weight: 500;
}
.btn-regenerate {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fbbf24;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-regenerate:hover { background: #fde68a; border-color: #f59e0b; }
.btn-regenerate .material-symbols-outlined { font-size: 15px; }

[data-theme="dark"] .message.interrupted .message-content { border-color: #d97706; }
[data-theme="dark"] .interrupted-label { color: #fbbf24; }
[data-theme="dark"] .btn-regenerate { background: #292524; color: #fbbf24; border-color: #78350f; }
[data-theme="dark"] .btn-regenerate:hover { background: #3d2e1e; }

/* ── Réessayer inline retry button (Feature 3) ──────────── */
.btn-retry-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--accent);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-retry-inline:hover { background: var(--accent-bg); border-color: var(--accent); }

/* ═══════════════════════════════════════════════════════════
   AUTO-SAVE INDICATOR (Feature 4)
════════════════════════════════════════════════════════════ */
.autosave-label {
  font-size: 12px;
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity .4s ease;
  white-space: nowrap;
  pointer-events: none;
}
.autosave-label.visible { opacity: 1; }

/* ═══════════════════════════════════════════════════════════
   GLOBAL SEARCH MODAL (Feature 5)
════════════════════════════════════════════════════════════ */
.modal-search {
  max-width: 620px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.search-modal-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-modal-icon {
  font-size: 22px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.search-modal-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-primary);
  outline: none;
}
.search-modal-input::placeholder { color: var(--text-tertiary); }
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 80px;
}
.search-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-tertiary);
  font-size: 14px;
}
.search-result-item {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
  border: 1.5px solid transparent;
}
.search-result-item:hover,
.search-result-item.selected {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.search-result-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.search-result-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-date {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}
.search-highlight {
  background: #fef08a;
  color: #78350f;
  border-radius: 2px;
  padding: 0 1px;
}
[data-theme="dark"] .search-highlight { background: #713f12; color: #fef08a; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-content { width: 100%; }
  .modal-xl { max-width: 100%; max-height: 100vh; border-radius: 0; }
  .pptx-layout { flex-direction: column; }
  .slides-panel { width: 100%; min-width: 0; height: 120px; border-right: none; border-bottom: 1px solid var(--border); }
  .slides-list { flex-direction: row; }
  .slide-thumb { width: 80px; flex-shrink: 0; }
}

/* ═══════════════════════════════════════════════════════════
   PIÈCES JOINTES — INPUT
════════════════════════════════════════════════════════════ */
.input-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 2px;
}
.input-attachments:empty { display: none; }

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 6px;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 16px;
  font-size: 12px;
  color: var(--accent);
  max-width: 200px;
}
.attachment-chip span:first-child { flex-shrink: 0; }
.attachment-chip > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip button {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--accent);
  opacity: .7;
  flex-shrink: 0;
}
.attachment-chip button:hover { opacity: 1; }

/* Badges dans les messages */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.message-attachment-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--surface-variant);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.message-attachment-badge .material-symbols-outlined { font-size: 14px; }

/* ── Image attachment preview (input zone) ───────────────── */
.attachment-chip.attachment-chip-image {
  position: relative;
  padding: 0;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.attachment-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attachment-chip-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.65) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 4px;
  opacity: 0;
  transition: opacity .15s;
}

.attachment-chip.attachment-chip-image:hover .attachment-chip-overlay {
  opacity: 1;
}

.attachment-chip-name {
  font-size: 9px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin-bottom: 2px;
}

.attachment-chip-overlay button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 1;
  color: #fff;
}

.attachment-chip-overlay button .material-symbols-outlined {
  font-size: 12px;
}

/* ── Scroll-to-bottom button ─────────────────────────────── */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 80px;
  right: 20px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: opacity .2s, transform .2s;
  opacity: 1;
  cursor: pointer;
}

.scroll-to-bottom-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.scroll-to-bottom-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.scroll-to-bottom-btn .material-symbols-outlined {
  font-size: 20px;
}

/* ── Undo delete toast ───────────────────────────────────── */
.toast-undo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-undo-btn {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}

.toast-undo-btn:hover {
  background: var(--accent-bg);
}

/* ═══════════════════════════════════════════════════════════
   AGENTS — GRILLE PARTAGÉS / PERSONNELS
════════════════════════════════════════════════════════════ */
.agents-grid-section-label {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 0 2px;
  margin-top: 8px;
}
.agents-grid-section-label:first-child { margin-top: 0; }
.agents-grid-section-label .material-symbols-outlined { font-size: 16px; }

.agent-card-shared {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.agent-shared-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: 10px;
  padding: 2px 6px;
}
.agent-shared-badge .material-symbols-outlined { font-size: 13px; }

/* Badge agent partagé dans la sidebar */
.agent-sidebar-item .material-symbols-outlined[title="Agent partagé"] {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════════════════════
   ADMIN — ONGLETS
════════════════════════════════════════════════════════════ */
.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.admin-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -1px;
}
.admin-tab:hover { color: var(--accent); background: var(--accent-bg); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-bg); }
.admin-tab .material-symbols-outlined { font-size: 18px; }

/* ═══════════════════════════════════════════════════════════
   ADMIN — AGENTS PARTAGÉS
════════════════════════════════════════════════════════════ */
.shared-agent-admin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--surface);
}
.shared-agent-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shared-agent-avatar .material-symbols-outlined { color: white; font-size: 16px; }
.shared-agent-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.shared-agent-name { font-weight: 500; font-size: 13px; overflow-wrap: break-word; word-break: break-word; }
.shared-agent-desc { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shared-agent-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 768px) {
  .shared-agent-admin-row { flex-wrap: wrap; }
  .shared-agent-info { width: 100%; flex-basis: 100%; order: 1; }
  .shared-agent-avatar { order: 2; }
  .shared-agent-actions { order: 2; margin-left: auto; }
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  gap: 4px;
}
.btn-sm .material-symbols-outlined { font-size: 15px; }
.btn-danger {
  background: #fce8e6;
  color: #c5221f;
  border: 1px solid #f5c6c4;
}
.btn-danger:hover { background: #f5c6c4; }

/* Assignation agents dans le tableau users */
.user-perm-agents {
  min-width: 140px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.user-perm-agents-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.btn-assign-agents {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 2px;
  border-radius: 4px;
  transition: color var(--transition);
  margin-left: auto;
}
.btn-assign-agents:hover { color: var(--accent); }
.btn-assign-agents .material-symbols-outlined { font-size: 14px; }
.btn-assign-datasources {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 2px;
  border-radius: 4px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--transition);
  margin-left: auto;
}
.btn-assign-datasources:hover { color: var(--accent); }
.btn-assign-datasources .material-symbols-outlined { font-size: 14px; }
.user-perm-agents-list { display: flex; flex-wrap: wrap; gap: 4px; }
/* ═══════════════════════════════════════════════════════════
   TÉLÉVERSEMENT — MODAL
════════════════════════════════════════════════════════════ */
.upload-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 16px;
}
.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.upload-drop-zone.drag-over { transform: scale(1.01); }

.upload-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 6px;
}

.upload-file-icon {
  font-size: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.upload-filename {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-filename-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.upload-folder-label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
}
.upload-folder-label .material-symbols-outlined { font-size: 13px; }

/* Barre de progression */
.upload-progress-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .15s ease;
}

.upload-progress-wrap.done .upload-progress-bar { background: #34a853; }
.upload-progress-wrap.error .upload-progress-bar { background: #ea4335; }

/* Pourcentage + statut */
.upload-progress-pct {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.upload-status { font-size: 12px; font-weight: 500; flex-shrink: 0; }
.upload-status.uploading { color: var(--text-tertiary); }
.upload-status.success { color: #34a853; }
.upload-status.error { color: #ea4335; }
.upload-status.pending { color: var(--accent); }

/* File d'attente avant envoi */
.upload-queue-row {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.upload-queue-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.upload-queue-remove:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.upload-queue-remove .material-symbols-outlined { font-size: 16px; }

#uploadQueueFooter {
  display: flex;
  justify-content: flex-end;
  padding: 8px 0 4px;
}

/* ═══════════════════════════════════════════════════════════
   UPLOAD MODAL — LAYOUT
════════════════════════════════════════════════════════════ */
.upload-modal-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  min-height: 420px;
  padding: 0 !important;   /* override modal-body padding */
}
.upload-left-panel {
  border-right: 1px solid var(--border);
  padding: 20px 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.upload-right-panel {
  padding: 20px 20px 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

/* Fil d'Ariane */
.bucket-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  overflow: hidden;
}
.bucket-breadcrumb > .material-symbols-outlined { font-size: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.breadcrumb-path {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}
.breadcrumb-item {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  color: var(--accent);
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.breadcrumb-item:hover { background: var(--accent-bg); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 500; cursor: default; pointer-events: none; }
.breadcrumb-sep { color: var(--text-tertiary); font-size: 12px; }

/* Explorateur */
.bucket-explorer {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-y: auto;
  background: var(--bg-secondary);
  min-height: 0;
}
.explorer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  text-align: left;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
}
.explorer-item:last-child { border-bottom: none; }
.explorer-item:hover { background: var(--surface-hover); }
.explorer-item .material-symbols-outlined { font-size: 17px; flex-shrink: 0; }
.explorer-folder .material-symbols-outlined:first-child { color: #fbbc04; }
.explorer-up .material-symbols-outlined { color: var(--text-tertiary); }
.explorer-file { cursor: default; }
.explorer-file .material-symbols-outlined:first-child { color: var(--text-tertiary); }
.explorer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.explorer-meta { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.explorer-chevron { color: var(--text-tertiary) !important; margin-left: auto; font-size: 16px !important; }

/* Badge destination */
.upload-destination-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  overflow: hidden;
}
.upload-destination-badge .material-symbols-outlined { font-size: 15px; flex-shrink: 0; }
#uploadDestText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════
   FOLDER BROWSER (ancien — conservé pour compatibilité)
════════════════════════════════════════════════════════════ */
.folder-browser {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-secondary);
  max-height: 220px;
  overflow-y: auto;
}

.folder-browser-placeholder,
.folder-browser-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  color: var(--text-tertiary);
  font-size: 13px;
}
.folder-browser-placeholder .material-symbols-outlined { font-size: 18px; }

.folder-browser-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font);
  transition: background var(--transition);
}
.folder-browser-item:last-of-type { border-bottom: none; }
.folder-browser-item:hover { background: var(--surface-hover); }
.folder-browser-item.selected {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
}
.folder-browser-item .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.folder-browser-item.selected .material-symbols-outlined { color: var(--accent); }
.folder-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item-check { margin-left: auto; font-size: 16px !important; }

.folder-new-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  border-top: 1px dashed var(--border);
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
  font-family: var(--font);
  font-weight: 500;
  transition: background var(--transition);
}
.folder-new-btn:hover { background: var(--accent-bg); }
.folder-new-btn .material-symbols-outlined { font-size: 18px; }

.folder-new-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
}
.folder-new-wrap .material-symbols-outlined { color: var(--accent); font-size: 18px; flex-shrink: 0; }
.folder-new-wrap input {
  flex: 1;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font);
  outline: none;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN — DATASTORES
════════════════════════════════════════════════════════════ */
.datastore-admin-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  background: var(--surface);
  transition: box-shadow var(--transition);
}
.datastore-admin-card:hover { box-shadow: var(--shadow); }
.datastore-admin-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.datastore-admin-icon .material-symbols-outlined { color: var(--accent); font-size: 22px; }
.datastore-admin-info { flex: 1; min-width: 0; }
.datastore-admin-name { font-weight: 500; font-size: 14px; margin-bottom: 2px; }
.datastore-admin-id {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.datastore-admin-actions { flex-shrink: 0; }
.datastore-location-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-left: 4px;
  letter-spacing: .5px;
}

/* ═══════════════════════════════════════════════════════════
   ÉDITEUR DE DOCUMENTS WORD
════════════════════════════════════════════════════════════ */

.modal-fullscreen {
  width: 96vw;
  max-width: 1400px;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header éditeur ────────────────────────────────────────── */
.we-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.we-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.we-header-left .material-symbols-outlined {
  font-size: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.we-doc-name-input {
  flex: 1;
  min-width: 0;
  border: none;
  border-bottom: 2px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font);
  padding: 4px 8px;
  outline: none;
  transition: border-color var(--transition);
}

.we-doc-name-input:focus {
  border-bottom-color: var(--accent);
}

.we-doc-name-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.we-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.we-template-select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  max-width: 200px;
}
.we-template-select:focus { outline: none; border-color: var(--primary); }

/* ── Corps : 2 panneaux ────────────────────────────────────── */
.we-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  flex: 1;
  overflow: hidden;
  border-top: 1px solid var(--border);
}

/* ── Panneau éditeur ───────────────────────────────────────── */
.we-editor-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

/* Quill toolbar */
.we-editor-panel .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  padding: 6px 12px;
}

.we-editor-panel .ql-container {
  border: none;
  flex: 1;
  overflow-y: auto;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text-primary);
}

.we-editor-panel .ql-editor {
  padding: 32px 48px;
  min-height: 100%;
  line-height: 1.7;
}

.we-editor-panel .ql-editor h1 { font-size: 28px; margin: 20px 0 10px; }
.we-editor-panel .ql-editor h2 { font-size: 22px; margin: 18px 0 8px; }
.we-editor-panel .ql-editor h3 { font-size: 18px; margin: 16px 0 6px; }

/* Quill dark mode */
[data-theme="dark"] .we-editor-panel .ql-toolbar {
  background: var(--bg-secondary);
  border-color: var(--border);
}
[data-theme="dark"] .we-editor-panel .ql-toolbar .ql-stroke { stroke: var(--text-secondary); }
[data-theme="dark"] .we-editor-panel .ql-toolbar .ql-fill { fill: var(--text-secondary); }
[data-theme="dark"] .we-editor-panel .ql-toolbar .ql-picker-label { color: var(--text-secondary); }
[data-theme="dark"] .we-editor-panel .ql-toolbar .ql-picker-options {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}
[data-theme="dark"] .we-editor-panel .ql-container { background: var(--bg); color: var(--text-primary); }
[data-theme="dark"] .we-editor-panel .ql-editor.ql-blank::before { color: var(--text-tertiary); }

/* ── Panneau GCS ───────────────────────────────────────────── */
.we-gcs-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px;
  overflow-y: auto;
  background: var(--bg-secondary);
}

.we-gcs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.we-gcs-header .material-symbols-outlined { font-size: 16px; color: var(--accent); }

.we-gcs-panel .form-group {
  margin-bottom: 0;
}

.we-gcs-panel .bucket-explorer {
  flex: 1;
  min-height: 120px;
  max-height: 300px;
}

.we-gcs-panel .upload-destination-badge {
  margin-top: 4px;
}

/* ── Redimensionnement d'images (éditeur Word) ─────────────── */

/* Image sélectionnée dans Quill */
.we-editor-panel .ql-editor img.we-img-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  cursor: pointer;
}

/* Overlay de redimensionnement */
.we-img-resize-overlay {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  box-sizing: border-box;
  border: 2px solid var(--accent);
}

.we-img-resize-overlay > * {
  pointer-events: auto;
}

/* Handle coin bas-droit */
.we-img-resize-handle {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  cursor: se-resize;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* Toolbar flottante au-dessus de l'image */
.we-img-resize-toolbar {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  font-family: var(--font);
}

.we-img-resize-toolbar input[type="number"] {
  width: 64px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 13px;
  text-align: center;
  -moz-appearance: textfield;
}

.we-img-resize-toolbar input[type="number"]::-webkit-outer-spin-button,
.we-img-resize-toolbar input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.we-img-resize-toolbar input[type="number"]:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

/* ── Streaming cursor ──────────────────────────────────────── */

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: blink .9s step-start infinite;
}

/* ── History search ───────────────────────────────────────── */

.history-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 8px 3px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.history-search-wrap:focus-within {
  border-color: var(--accent);
}

.history-search-wrap .material-symbols-outlined {
  font-size: 17px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.history-search-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  min-width: 0;
}

.history-search-wrap input::placeholder {
  color: var(--text-tertiary);
}

/* ── Responsive sidebar (mobile) ─────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 199;
}

.sidebar-overlay.visible {
  display: block;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 200;
    width: var(--sidebar-w) !important;
    transform: translateX(0);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
  }

  .sidebar.collapsed {
    transform: translateX(-100%) !important;
    width: var(--sidebar-w) !important;
  }

  /* Sections : scroll global, plus de scroll par bloc */
  #historySection {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
  }
  .conversations-list {
    max-height: none !important;
    overflow-y: auto;
    transition: none;
  }
  #pinnedAgentsSection .agents-list {
    max-height: none !important;
    overflow-y: auto;
    transition: none;
  }

  /* Footer collé en bas de la sidebar */
  .sidebar-footer {
    position: sticky;
    bottom: 0;
    background: var(--sidebar-bg);
    z-index: 1;
    margin-top: 0;
  }

  .main {
    margin-left: 0 !important;
  }

  #sidebarOpenBtn {
    display: flex !important;
  }
}

/* ════════════════════════════════════════════════════════════
   AGENT CONFIRM DIALOG
════════════════════════════════════════════════════════════ */
.agent-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100; /* au-dessus des modals (z-index 1000) */
  padding: 16px;
  backdrop-filter: blur(4px);
  animation: overlayIn .2s ease;
}

.agent-confirm-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 360px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.agent-confirm-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.agent-confirm-icon .material-symbols-outlined {
  font-size: 28px;
}

.agent-confirm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.agent-confirm-msg {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 0 4px;
}

.agent-confirm-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.agent-confirm-cancel,
.agent-confirm-continue {
  flex: 1;
  padding: 9px 0;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .15s, background .15s;
}

.agent-confirm-cancel {
  background: var(--surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.agent-confirm-continue {
  background: var(--accent);
  color: #fff;
}

.agent-confirm-cancel:hover,
.agent-confirm-continue:hover {
  opacity: .85;
}

/* ════════════════════════════════════════════════════════════
   TOKEN BADGE
════════════════════════════════════════════════════════════ */
.token-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  transition: opacity .2s;
  user-select: none;
}

.token-badge:hover {
  opacity: 1;
}

.token-badge .material-symbols-outlined {
  font-size: 13px;
}
.token-badge--warning { color: #f59e0b; opacity: 0.9; }
.token-badge--danger  { color: #ef4444; opacity: 1; }

/* ════════════════════════════════════════════════════════════
   EXPLORER MODAL
════════════════════════════════════════════════════════════ */
.explorer-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 0;
  height: 100%;
  min-height: 0;
}

.explorer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.explorer-toolbar select {
  flex: 0 0 auto;
  min-width: 180px;
  max-width: 260px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
}

.explorer-toolbar select:focus {
  outline: none;
  border-color: var(--accent);
}

.explorer-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.explorer-breadcrumb-sep {
  color: var(--text-muted);
  font-size: 14px;
  user-select: none;
}

.explorer-breadcrumb-item {
  background: none;
  border: none;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s;
}

.explorer-breadcrumb-item:hover {
  background: var(--surface-hover);
}

.explorer-breadcrumb-item.current {
  color: var(--text-primary);
  font-weight: 500;
  cursor: default;
}

.explorer-breadcrumb-item.current:hover {
  background: none;
}

/* Scrollable file list */
.explorer-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Empty / loading state */
.explorer-empty {
  padding: 48px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Base row */
.explorer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}

.explorer-row:last-child {
  border-bottom: none;
}

.explorer-folder-row {
  cursor: pointer;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  color: var(--text-primary);
}

.explorer-folder-row:hover,
.explorer-file-row:hover {
  background: var(--surface-hover);
}

.explorer-row-icon {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--text-secondary);
  width: 24px;
  text-align: center;
}

.explorer-folder-row .explorer-row-icon {
  color: #f6a623;
}

.explorer-row-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-file-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.explorer-file-link:hover {
  text-decoration: underline;
}

.explorer-row-meta {
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
  min-width: 80px;
}

.explorer-open-btn {
  flex-shrink: 0;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}

.explorer-open-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.explorer-delete-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  display: flex;
  align-items: center;
}
.explorer-delete-btn .material-symbols-outlined { font-size: 18px; }
.explorer-delete-btn:hover {
  background: #fce8e6;
  color: #c62828;
  border-color: #f28b82;
}

.explorer-row-chevron {
  flex-shrink: 0;
  font-size: 18px;
  color: var(--text-muted);
}

/* Responsive: hide meta on small screens */
@media (max-width: 480px) {
  .explorer-row-meta {
    display: none;
  }
  .explorer-toolbar select {
    min-width: 120px;
  }
}

/* ════════════════════════════════════════════════════════════
   IMPERSONATION
════════════════════════════════════════════════════════════ */
.impersonation-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #b71c1c;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.impersonation-banner .material-symbols-outlined { font-size: 18px; }
.impersonation-banner strong { font-weight: 700; }
.impersonation-stop-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.impersonation-stop-btn:hover { background: rgba(255,255,255,.25); }
.impersonation-stop-btn .material-symbols-outlined { font-size: 15px; }
.impersonation-timer { font-size: 12px; opacity: .75; white-space: nowrap; }

body.impersonating .app-wrapper,
body.impersonating .login-screen {
  margin-top: 38px;
}

/* ═══════════════════════════════════════════════════════════
   ÉCRAN COMPTE EN ATTENTE
════════════════════════════════════════════════════════════ */
.pending-icon {
  font-size: 64px;
  color: var(--primary);
  opacity: .6;
}

.pending-card .login-subtitle {
  line-height: 1.6;
}

.unassigned-icon {
  font-size: 64px;
  color: var(--text-tertiary);
  opacity: .7;
}

.unassigned-card .login-subtitle {
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════
   ENVIRONNEMENTS — FORMULAIRE CRÉATION
════════════════════════════════════════════════════════════ */
#envCreateForm {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
#envCreateForm .form-control { width: 100%; flex: none; }
#envCreateForm .group-create-actions { justify-content: flex-end; }

/* ═══════════════════════════════════════════════════════════
   ENVIRONNEMENTS — MEMBRES & PENDING
════════════════════════════════════════════════════════════ */
.env-list-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.env-list-search-wrap .material-symbols-outlined { font-size: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.env-list-search {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
}
.env-list-search::placeholder { color: var(--text-tertiary); }

.env-members-scroll {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.env-members-scroll::-webkit-scrollbar { width: 4px; }
.env-members-scroll::-webkit-scrollbar-track { background: transparent; }
.env-members-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.env-list-empty { font-size: 13px; color: var(--text-tertiary); padding: 4px 0; }

.env-role-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-left: auto;
  transition: all var(--transition);
}
.env-role-btn .material-symbols-outlined { font-size: 13px; }
.env-role-btn--promote { color: var(--accent); border-color: rgba(66,133,244,.3); }
.env-role-btn--promote:hover { background: var(--accent-bg); border-color: var(--accent); }
.env-role-btn--demote { color: #ea4335; border-color: rgba(234,67,53,.3); }
.env-role-btn--demote:hover { background: rgba(234,67,53,.08); border-color: #ea4335; }
.env-role-btn:disabled { opacity: .4; cursor: not-allowed; }

.env-assign-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.env-inline-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.env-inline-form .form-control { flex: 1; min-width: 160px; font-size: 13px; }

.env-member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  flex-shrink: 0;
}
.env-member-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-member-email { font-size: 12px; color: var(--text-tertiary); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.pending-member-row {
  border-left: 3px solid #f29900;
  background: rgba(242,153,0,.06);
}

/* ── Users list — ligne pending ── */
.users-list-item.user-pending {
  border-left: 3px solid #f29900;
  background: rgba(242,153,0,.05);
}
.users-list-item.user-pending:hover { background: rgba(242,153,0,.1); }

/* ── Badge "En attente" sur item user ── */
.pending-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  flex-shrink: 0;
  background: rgba(242,153,0,.15);
  color: #d08000;
  border: 1px solid rgba(242,153,0,.35);
}

/* ── Chip filtre "En attente" ── */
.pending-filter-chip { border-color: rgba(242,153,0,.5); color: #d08000; }
.pending-filter-chip:hover { border-color: #f29900; color: #d08000; background: rgba(242,153,0,.08); }
.pending-filter-chip.active { background: #f29900; border-color: #f29900; color: #fff; }

/* ── Ligne activation inline dans le détail user ── */
.pending-activate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(242,153,0,.07);
  border: 1px solid rgba(242,153,0,.25);
  flex-wrap: wrap;
}
.pending-activate-row .pending-env-select {
  flex: 1;
  min-width: 140px;
}

/* ── Datastores checkboxes (env & group panels) ── */
.ds-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.ds-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
  transition: background .15s;
}
.ds-checkbox-item:hover { background: var(--hover-bg); }
.ds-checkbox-item input[type="checkbox"] { flex-shrink: 0; accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.ds-checkbox-name { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-checkbox-id { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }

/* ── Panneau "Accès" unifié (datastores/agents/workflows — user/group/env) ── */
.access-panel { display: flex; flex-direction: column; gap: 4px; }
.access-subheading {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin: 12px 0 4px;
}
.access-subheading:first-child { margin-top: 0; }
.ds-checkbox-item.access-locked { cursor: default; opacity: .7; }
.ds-checkbox-item.access-locked:hover { background: transparent; }
.access-locked-badge {
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--accent-light, rgba(126,87,255,.14));
  color: var(--accent);
}

@media (max-width: 600px) {
  .pending-activate-row { flex-direction: column; align-items: stretch; }
  .pending-activate-row .btn { width: 100%; justify-content: center; }
}

.btn-impersonate {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid #b71c1c;
  border-radius: 5px;
  color: #b71c1c;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-impersonate:hover { background: #b71c1c; color: #fff; }
.btn-impersonate .material-symbols-outlined { font-size: 13px; }

/* ════════════════════════════════════════════════════════════
   TOKEN QUOTA
════════════════════════════════════════════════════════════ */
.token-quota-indicator {
  margin: 0 8px 6px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
}
.token-quota-header {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.token-quota-header .material-symbols-outlined { font-size: 14px; }
.token-quota-label { flex: 1; font-weight: 500; }
.token-quota-count { font-weight: 600; color: var(--text-primary); }
.token-quota-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.token-quota-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width .3s;
}
.token-quota-fill.warning { background: #f9a825; }
.token-quota-fill.danger  { background: #ea4335; }

/* ── Admin tokens tab ── */
.tokens-admin-table { display: flex; flex-direction: column; gap: 8px; }
.tokens-admin-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.tokens-user-info { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.tokens-env-badge { display: flex; align-items: center; gap: 3px; font-size: 10px; color: var(--text-tertiary); margin-top: 2px; }
.tokens-env-badge .material-symbols-outlined { font-size: 11px; }
.tokens-usage { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.tokens-used { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.tokens-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.tokens-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.tokens-bar-fill.warning { background: #f9a825; }
.tokens-bar-fill.danger  { background: #ea4335; }
.tokens-limit-cell { display: flex; align-items: center; gap: 6px; }
.tokens-limit-input {
  width: 100px;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
}
.tokens-limit-input:focus { outline: none; border-color: var(--accent); }
.tokens-format-hint { font-size: 11px; color: var(--accent); font-weight: 500; min-width: 60px; }
.tokens-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ── Budget gauge (org_admin Tokens tab) ── */
.tokens-chart-wrap {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  position: relative;
}
.tokens-chart-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.tokens-chart-filter {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  max-width: 220px;
}
#tokensChart { height: 160px !important; }

.env-tokens-chart-wrap {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.env-tokens-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.env-tokens-cb-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.env-tokens-cb-label input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }
.env-tokens-cb-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
#envTokensChart { height: 240px !important; }

.tokens-budget-gauge {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tokens-budget-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tokens-budget-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.tokens-budget-title .material-symbols-outlined { font-size: 16px; color: var(--accent); }
.tokens-budget-sub { display: block; font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.tokens-budget-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tokens-budget-remaining { font-size: 12px; font-weight: 600; color: var(--accent); }
.tokens-budget-remaining.danger { color: #ea4335; }
.tokens-budget-bar-wrap { display: flex; flex-direction: column; gap: 6px; }
.tokens-budget-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.tokens-budget-bar-used {
  position: absolute;
  left: 0; top: 0; height: 100%;
  background: #ea4335;
  border-radius: 4px 0 0 4px;
  transition: width 0.3s;
}
.tokens-budget-bar-assigned {
  position: absolute;
  top: 0; height: 100%;
  background: var(--accent);
  opacity: 0.5;
  transition: width 0.3s, margin-left 0.3s;
}
.tokens-budget-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.tokens-budget-legend span { font-size: 11px; color: var(--text-tertiary); display: flex; align-items: center; gap: 4px; }
.tokens-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tokens-legend-dot.used { background: #ea4335; }
.tokens-legend-dot.assigned { background: var(--accent); opacity: 0.5; }
.tokens-legend-dot.remaining { background: var(--border); }
.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  transition: background .15s, border-color .15s;
}
.btn-sm:hover { background: var(--surface-hover); border-color: var(--accent); }
.btn-sm .material-symbols-outlined { font-size: 14px; }

/* ════════════════════════════════════════════════════════════
   DISCLAIMER / CGU
════════════════════════════════════════════════════════════ */
.disclaimer-modal {
  max-width: 620px;
  padding: 0;
  overflow: hidden;
}
.disclaimer-header {
  text-align: center;
  padding: 32px 32px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, #1557b0 100%);
  color: #fff;
}
.disclaimer-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}
.disclaimer-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #fff;
}
.disclaimer-header p {
  font-size: 13px;
  opacity: 0.85;
  margin: 0;
}
.disclaimer-body {
  padding: 24px 28px;
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.disclaimer-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.disclaimer-section h3 .material-symbols-outlined {
  font-size: 16px;
  color: var(--accent);
}
.disclaimer-section ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.disclaimer-section li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.disclaimer-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 28px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* ═══ LOGS ADMIN ═══ */
.logs-export-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.logs-export-date {
  padding: 5px 8px;
  font-size: 13px;
  width: 140px;
}
.logs-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.logs-filter-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 180px;
  cursor: pointer;
}
.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.logs-table thead th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 1;
}
.logs-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.logs-table tbody tr:hover { background: var(--bg-hover); }
.logs-table td {
  padding: 7px 10px;
  vertical-align: top;
  color: var(--text-primary);
}
.log-ts { white-space: nowrap; color: var(--text-secondary); font-size: 11px; }
.log-ip { white-space: nowrap; color: var(--text-secondary); font-size: 11px; font-family: monospace; }
.log-user { white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.log-details { font-size: 11px; color: var(--text-secondary); max-width: 320px; word-break: break-word; }
.log-detail-key { font-weight: 600; color: var(--text-primary); }
.log-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.log-badge-auth   { background: #e8f0fe; color: #1a73e8; }
.log-badge-chat   { background: #e6f4ea; color: #1e8e3e; }
.log-badge-workflow { background: #fce8b2; color: #b06000; }
.log-badge-admin  { background: #fce4ec; color: #c62828; }
.log-badge-files  { background: #f3e8fd; color: #7b1fa2; }
.log-badge-docs   { background: #e0f7fa; color: #00696f; }
.log-badge-other  { background: var(--bg-secondary); color: var(--text-secondary); }
.logs-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 16px;
  font-size: 14px;
}
.logs-pagination {
  display: flex;
  justify-content: center;
  padding: 16px 0 8px;
}

/* ═══ DATASOURCE FORM ═══ */
.datastore-admin-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.btn-danger-hover:hover {
  background: #fce4ec;
  border-color: #e53935;
  color: #c62828;
}
.datasource-form-panel {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  overflow: hidden;
}
.datasource-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}
.datasource-form-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.datasource-form-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-row {
  display: flex;
  gap: 12px;
}
.required { color: #e53935; margin-left: 2px; }
.optional { color: var(--text-secondary); font-size: 11px; font-weight: 400; }
.datasource-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ═══ CANVAS MODAL ═══ */

.canvas-modal-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  border-radius: 0;
}

.canvas-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.canvas-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--primary);
  min-width: 80px;
}

.canvas-header-left .material-symbols-outlined {
  font-size: 20px;
}

.canvas-header-title {
  font-size: 15px;
}

.canvas-header-center {
  flex: 1;
}

.canvas-title-input {
  width: 100%;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.canvas-title-input:focus {
  border-color: var(--primary);
}

.canvas-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.canvas-template-select {
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  max-width: 220px;
  cursor: pointer;
}

.canvas-template-select:focus {
  border-color: var(--primary);
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.canvas-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.canvas-tool-btn:hover { background: var(--hover); color: var(--text-primary); }
.canvas-tool-btn .material-symbols-outlined { font-size: 18px; }
.canvas-tool-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.canvas-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
  background: var(--bg);
}

.canvas-editor {
  min-height: 100%;
  max-width: 860px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  outline: none;
  word-break: break-word;
}

.canvas-editor:focus {
  outline: none;
}

/* Bouton Éditer dans les actions message */
.message-action-btn.canvas-btn {
  color: var(--primary);
}

/* ═══ TEMPLATES ADMIN ═══ */

.template-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--surface);
  transition: border-color 0.15s;
}

.template-admin-row:hover {
  border-color: var(--primary);
}

.template-admin-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.template-admin-info .material-symbols-outlined {
  color: var(--primary);
  font-size: 20px;
}

.template-admin-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.template-admin-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid #ea4335;
  color: #ea4335;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-danger-outline:hover {
  background: #ea4335;
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ════════════════════════════════════════════════════════════
   OPTIMISATIONS MOBILE
════════════════════════════════════════════════════════════ */

/* Le bouton + mobile est caché par défaut (desktop) */
.mobile-add-btn { display: none !important; }

/* Select admin mobile caché par défaut (desktop) */
.admin-tab-select { display: none; }

@media (max-width: 768px) and (pointer: coarse) {

  /* 1. Header : masquer le titre texte */
  .header-logo { height: 20px; }

  /* 2. Actions messages : toujours visibles, Citer + token count masqués */
  .message-actions { opacity: 1; }
  .quote-btn { display: none; }
  .msg-token-count { display: none; }

  /* 3. Bouton attach remplacé par + sur mobile */
  #attachFileBtn { display: none !important; }
  .mobile-add-btn { display: flex !important; }

  /* 7. Taille de police globale */
  body { font-size: 15px; }

  /* Champ de saisie : 16px évite le zoom automatique iOS + meilleure lisibilité */
  #messageInput { font-size: 16px; }

  /* 8. Token quota : masquer le label, garder barre + % */
  .token-quota-label { display: none; }
  .token-quota-indicator { padding: 6px 8px; }

  /* 9. Chip agent actif : tronquer le nom si trop long */
  #activeAgentName {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Admin : onglets → select déroulant */
  .admin-tabs { display: none; }
  .admin-tab-select {
    display: block !important;
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 500;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    margin-bottom: 16px;
  }

  /* Admin utilisateurs — master/detail mobile : stack navigation */
  .users-layout {
    height: calc(100vh - 180px);
    position: relative;
  }
  .users-master-panel {
    width: 100%;
    min-width: unset;
    border-right: none;
    position: absolute;
    inset: 0;
    transform: translateX(0);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 1;
  }
  .users-detail-panel {
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 2;
    border-left: none;
  }
  .users-layout.showing-detail .users-master-panel { transform: translateX(-100%); }
  .users-layout.showing-detail .users-detail-panel { transform: translateX(0); }
  .users-back-btn { display: flex; }

  .user-perm-checkboxes { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .perm-checkbox-wrap { flex: 1; min-width: 120px; }

  /* Admin tokens : wrap propre */
  .tokens-admin-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .tokens-user-info { min-width: unset; }
  .tokens-limit-cell { width: 100%; }
  .tokens-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
  .tokens-budget-header { flex-direction: column; }
  .tokens-budget-actions { width: 100%; justify-content: space-between; }
  .logs-export-bar { display: none; }

  /* Téléversement : passer en colonne unique, upload en premier */
  .upload-modal-body {
    grid-template-columns: 1fr;
    min-height: unset;
  }
  .upload-left-panel {
    order: 1;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }
  .upload-right-panel {
    order: 2;
    padding: 16px;
  }

  /* 4. Suggestion chips : scroll horizontal, tap-friendly */
  .suggestion-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    max-width: 100%;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .suggestion-chips::-webkit-scrollbar { display: none; }
  .chip {
    flex-shrink: 0;
    padding: 10px 16px;
    font-size: 13px;
  }
  .followup-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .followup-chips::-webkit-scrollbar { display: none; }
  .followup-chip {
    flex-shrink: 0;
    padding: 7px 14px;
    font-size: 13px;
  }

  /* 5. Modals : bottom sheet sur mobile */
  .modal-overlay {
    align-items: flex-end;
  }
  .modal,
  .modal-large {
    max-width: 100% !important;
    width: 100%;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    animation: modalInMobile .3s ease;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-header {
    padding: 14px 16px 10px;
  }

  @keyframes modalInMobile {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ═══ GÉNÉRATEUR PPTX ═══ */
.pptx-modal-body {
  display: flex;
  gap: 24px;
  height: calc(80vh - 80px);
  overflow: hidden;
}
.pptx-form-panel {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.pptx-form-row {
  display: flex;
  gap: 12px;
}
.pptx-generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  font-size: 14px;
}
.pptx-generate-btn .material-symbols-outlined { font-size: 18px; }
.pptx-cancel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  font-size: 14px;
}
.pptx-cancel-btn .material-symbols-outlined { font-size: 18px; }
.pptx-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  font-size: 14px;
}
.pptx-download-btn .material-symbols-outlined { font-size: 18px; }
.pptx-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 0;
}
.pptx-progress-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.pptx-preview-stage {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}
.pptx-preview-panel {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.pptx-preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  color: var(--text-tertiary);
  font-size: 13px;
}
.pptx-preview-empty .material-symbols-outlined { font-size: 40px; opacity: 0.4; }
.pptx-slides-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}
.pptx-slide-card {
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 80px;
  position: relative;
  border-left: 4px solid;
}
.pptx-preview-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border-radius: 6px;
  margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,0.12);
}
.pptx-dark {
  background: #1e2d1e;
  border-left-color: #CEE44A;
  color: #eee;
}
.pptx-light {
  background: #f0f5e8;
  border-left-color: #3A7A1A;
  color: #1a2e1a;
}
.pptx-slide-num {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 10px;
  opacity: 0.5;
  font-weight: 600;
}
.pptx-slide-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.5;
  margin-bottom: 4px;
}
.pptx-slide-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.pptx-slide-subtitle { font-size: 12px; opacity: 0.7; }
.pptx-slide-bullets { font-size: 12px; opacity: 0.85; padding-left: 16px; margin: 4px 0 0; line-height: 1.6; }
.pptx-slide-summary {
  font-size: 12px;
  opacity: 0.82;
  margin-top: 6px;
  line-height: 1.55;
}
.pptx-mini-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pptx-mini-card {
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
}
.pptx-light .pptx-mini-card { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.1); }
.pptx-history-panel {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
}
.pptx-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}
.pptx-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  max-height: 220px;
  overflow-y: auto;
}
.pptx-history-empty {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 2px;
}
.pptx-history-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pptx-history-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.pptx-history-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.pptx-history-actions {
  display: flex;
  gap: 8px;
}
.pptx-history-actions button {
  flex: 1;
  min-width: 0;
}

@media (max-width: 700px) {
  .pptx-modal-body { flex-direction: column; height: auto; overflow: visible; }
  .pptx-form-panel { width: 100%; }
  .pptx-preview-panel { min-height: 300px; }
}

/* ── Éditeur pleine page PPTX ──────────────────────────────────────── */

.pptx-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg-primary, #0f0f1a);
  display: flex;
  flex-direction: column;
  isolation: isolate;
}
.pptx-editor-overlay.hidden { display: none; }

.pptx-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  gap: 12px;
}
.pptx-editor-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background .15s;
}
.pptx-editor-back:hover { background: var(--hover); color: var(--text-primary); }
.pptx-editor-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pptx-editor-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pptx-editor-dirty {
  align-self: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(168, 200, 0, 0.14);
  border: 1px solid rgba(168, 200, 0, 0.3);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}
.pptx-editor-btn { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.pptx-editor-btn .material-symbols-outlined { font-size: 16px; }

.pptx-editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Panel miniatures */
.pptx-editor-thumbs {
  width: 160px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pptx-thumb {
  position: relative;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color .15s;
  background: var(--bg-secondary);
}
.pptx-thumb.active { border-color: var(--accent); }
.pptx-thumb:hover:not(.active) { border-color: var(--border-hover, var(--accent)); opacity: .8; }
.pptx-thumb img {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  object-fit: cover;
}
.pptx-thumb-num {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 10px;
  color: #fff;
  background: rgba(0,0,0,.5);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Panel central */
.pptx-editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
  overflow: hidden;
}
.pptx-editor-scaler {
  position: relative;
  width: 100%;
  max-width: calc((100vh - 160px) * (16/9));
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
  border-radius: 4px;
}
.pptx-editor-frame {
  width: 1280px;
  height: 720px;
  border: none;
  transform-origin: top left;
  display: block;
}

.pptx-editor-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 14px;
}
.pptx-editor-hint {
  width: 100%;
  max-width: calc((100vh - 160px) * (16/9));
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
}
.pptx-nav-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--text-primary);
  transition: background .15s;
}
.pptx-nav-btn:hover { background: var(--hover); }
.pptx-nav-btn:disabled { opacity: .4; cursor: default; }

/* Barre de prompt IA */
.pptx-slide-prompt-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: calc((100vh - 160px) * (16/9));
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}
.pptx-prompt-icon {
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
}
.pptx-prompt-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
}
.pptx-prompt-input::placeholder { color: var(--text-muted, var(--text-secondary)); }
.pptx-prompt-submit {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: #000;
  transition: opacity .15s;
  flex-shrink: 0;
}
.pptx-prompt-submit:hover { opacity: .85; }
.pptx-prompt-submit:disabled { opacity: .4; cursor: default; }
.pptx-prompt-submit .material-symbols-outlined { font-size: 16px; }

/* Loading overlay sur la slide pendant le prompt IA */
.pptx-slide-ai-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #fff;
  font-size: 14px;
  z-index: 5;
  border-radius: 4px;
}
.pptx-slide-ai-loading.hidden { display: none; }

/* Loading rendu */
.pptx-render-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #fff;
  font-size: 15px;
  z-index: 10;
}
.pptx-render-loading.hidden { display: none; }

/* ── Utilitaires — migration style="" → classes CSS (strict CSP style-src) ── */
.label-icon { font-size: 16px; vertical-align: middle; }
.label-icon-sm { font-size: 13px; vertical-align: middle; }
.label-icon--primary { font-size: 16px; color: var(--primary); }
.label-icon--warning { font-size: 16px; vertical-align: middle; color: #f29900; }
.label-hint-inline { font-weight: 400; color: var(--text-tertiary); }
.label-note { font-size: 11px; color: #888; font-weight: 400; }
.text-xs-muted { font-size: 12px; color: var(--text-tertiary); }
.text-xs-secondary { font-size: 12px; color: var(--text-secondary); }
.text-xs-accent { font-size: 12px; color: var(--accent); font-weight: 500; }
.text-sm-muted { font-size: 13px; color: var(--text-tertiary); }
.text-sm-bold { font-size: 13px; font-weight: 500; }
.icon-accent-sm { font-size: 16px; color: var(--accent); }
.icon-upload { font-size: 48px; color: var(--text-tertiary); }
.img-resize-icon { font-size: 14px; color: var(--text-secondary); }
.img-resize-label { font-size: 12px; color: var(--text-secondary); }
.upload-drop-title { margin: 8px 0 4px; font-weight: 500; }
.upload-drop-sub { font-size: 13px; color: var(--text-tertiary); margin: 0 0 4px; }
.upload-drop-hint { font-size: 12px; color: var(--text-tertiary); margin: 0 0 16px; }
.form-sublabel-upper { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center-8 { display: flex; gap: 8px; align-items: center; }
.flex-end-12 { display: flex; gap: 12px; justify-content: flex-end; }
.flex-wrap-center { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.mt-6 { margin-top: 6px; }
.mt-10 { margin-top: 10px; }
.mt-24 { margin-top: 24px; }
.mt-1-5r { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.m-0 { margin: 0; }
.p-32 { padding: 32px; }
.admin-desc-inset { padding: 0 4px; margin-bottom: 8px; }
.range-full { width: 100%; margin-top: 6px; }
.w-200 { width: 200px; }
.file-label-btn { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.loading-inline { color: var(--text-tertiary); font-size: 13px; padding: 8px; }
.loading-placeholder { color: var(--text-tertiary); font-size: 14px; padding: 16px; }
.loading-center { margin: 0 auto 8px; }
.modal-body-sm { padding: 20px 24px; }
.modal-mb-12 { margin: 0 0 12px; }
.modal-hint { margin: 0 0 20px; color: var(--text-secondary); font-size: 14px; }
#deleteWorkflowBtn { display: none; }
.color-swatch[data-color="1a73e8"] { background: #1a73e8; }
.color-swatch[data-color="e91e63"] { background: #e91e63; }
.color-swatch[data-color="34a853"] { background: #34a853; }
.color-swatch[data-color="fbbc04"] { background: #fbbc04; }
.color-swatch[data-color="ea4335"] { background: #ea4335; }
.color-swatch[data-color="9c27b0"] { background: #9c27b0; }
.color-swatch[data-color="00bcd4"] { background: #00bcd4; }
.color-swatch[data-color="ff5722"] { background: #ff5722; }

/* ── Couleurs agents via CSS custom property --agent-c (style-src sans unsafe-inline) ── */
.agent-avatar         { background: var(--agent-c, #1a73e8); }
.agent-card-avatar    { background: var(--agent-c, #1a73e8); }
.shared-agent-avatar  { background: var(--agent-c, #1a73e8); }
.workflow-node-avatar { background: var(--agent-c, #1a73e8); }
.workflow-agent-dot   { background: var(--agent-c, #1a73e8); }
.wf-slot-dot          { background: var(--agent-c, #1a73e8); }
.agent-confirm-icon   { background: color-mix(in srgb, var(--agent-c, #1a73e8) 13%, transparent); color: var(--agent-c, #1a73e8); }
.agent-color-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--agent-c, #1a73e8); margin-right: 6px; flex-shrink: 0; }
.env-tokens-cb-dot { background: var(--dot-c, #1a73e8); }
.tokens-budget-bar-used     { width: var(--w, 0%); }
.tokens-budget-bar-assigned { width: var(--w, 0%); left: var(--l, 0%); transition: width 0.3s, left 0.3s; }
.tokens-bar-fill { width: var(--w, 0%); }

/* ── Messages inline utilitaires ── */
.msg-error    { color: #ea4335; padding: 16px; }
.msg-empty-sm { color: var(--text-tertiary); font-size: 12px; padding: 6px; }
.p-16 { padding: 16px; }
.p-24 { padding: 24px; }

/* ── Utilitaires statiques (remplacement inline styles) ── */
.agent-shared-icon    { font-size: 14px; color: var(--text-tertiary); margin-left: auto; }
.agents-grid-empty    { color: var(--text-tertiary); font-size: 14px; grid-column: 1/-1; }
.agent-tags-wrap      { flex-wrap: wrap; gap: 3px; }
.agent-tag-sm         { font-size: 10px; }
.conv-no-result       { padding: 8px 10px; font-size: 12px; color: var(--text-tertiary); }
.tokens-user-name     { font-size: 13px; font-weight: 500; }
.tokens-user-email    { font-size: 11px; color: var(--text-tertiary); }
.tokens-month-label   { color: var(--text-tertiary); font-size: 12px; }
.tokens-limit-hint    { font-size: 11px; color: var(--text-tertiary); }
.tokens-limit-display { font-size: 13px; color: var(--text-secondary); }
.tokens-limit-mgr     { font-size: 11px; color: var(--text-tertiary); }
.user-perm-avatar-sm  { width: 32px; height: 32px; font-size: 13px; }
.shared-agent-meta    { font-size: 11px; color: var(--text-tertiary); }
.icon-inline-sm       { font-size: 13px; vertical-align: middle; }
.icon-sm              { font-size: 14px; }
.icon-sm-lg           { font-size: 16px; }
.icon-warn            { color: #f29900; font-size: 16px; }
.icon-accent-sm       { font-size: 14px; color: var(--accent); }
.icon-yellow          { color: #f9ab00; }
.icon-gold            { color: #fbbc04; }
.text-sm-secondary    { font-size: 13px; color: var(--text-secondary); }
.select-flex          { font-size: 13px; flex: 1; }
.w-full               { width: 100%; }
.flex-no-shrink       { flex-shrink: 0; }
.pptx-slide-title--sm { font-size: 13px; }
.env-list-empty--sm   { font-size: 12px; }
.folder-browser-placeholder.error-state { color: #ea4335; }
.gemini-spinner-sm    { width: 16px !important; height: 16px !important; border-width: 2px !important; }
