/* ═══════════════════════════════════════════════════════
   Job Assistant — Feuille de styles principale
   Design system : tokens, layout, composants
   ═══════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────── */
:root {
  --bg:          #0f1117;
  --surface:     #1a1d27;
  --surface-2:   #22263a;
  --surface-3:   #2c3050;
  --border:      #2e3248;
  --text:        #e2e8f0;
  --text-muted:  #7c85a2;
  --accent:      #6366f1;
  --accent-h:    #818cf8;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --success:     #10b981;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
  --transition:  .18s ease;
  --sidebar-w:   240px;
  --header-h:    56px;
}

/* ── Thème clair ─────────────────────────────────────── */
body.light {
  --bg:         #eef1f7;
  --surface:    #ffffff;
  --surface-2:  #f4f6fb;
  --surface-3:  #e4e8f3;
  --border:     #cdd3e0;
  --text:       #111827;
  --text-muted: #6b7280;
  --accent:     #4f52e0;
  --accent-h:   #6366f1;
  --shadow:     0 4px 24px rgba(0,0,0,.10);
}
body.light ::-webkit-scrollbar-track { background: var(--surface-2); }
body.light ::-webkit-scrollbar-thumb { background: var(--border); }

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea, select { font: inherit; color: inherit; background: transparent; border: none; outline: none; }
ul, ol { list-style: none; }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ══════════════ LAYOUT ══════════════════════════════ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────── */
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.app-header .logo {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent-h);
  letter-spacing: -.3px;
}
.app-header .logo span { color: var(--text-muted); font-weight: 400; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── Barre de recherche textuelle (header) ──────────── */
.header-search {
  display: flex; align-items: center; gap: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
  position: relative;
  /* PAS de overflow:hidden — le dropdown absolu doit déborder */
}
.header-search:focus-within { border-color: var(--accent); }
.header-search input {
  background: none; border: none;
  color: var(--text); font-size: 13px;
  padding: 6px 10px; width: 210px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.header-search input::placeholder { color: var(--text-muted); }
.header-search button {
  padding: 0 10px; height: 32px;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600;
  border-left: 1px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: background var(--transition);
  white-space: nowrap;
}
.header-search button:hover { background: var(--accent-h); }

/* Dropdown résultats de recherche */
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 200; overflow: hidden; min-width: 320px;
}
.search-dd-empty { padding: 14px 16px; font-size: 13px; color: var(--text-muted); }
.search-dd-group { border-bottom: 1px solid var(--border); }
.search-dd-group:last-child { border-bottom: none; }
.search-dd-label {
  padding: 6px 14px 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
}
.search-dd-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px; cursor: pointer; font-size: 13.5px;
  transition: background var(--transition);
}
.search-dd-item:hover { background: var(--surface-2); }
.search-dd-main { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-dd-sub  { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
}
.sidebar-section { padding: 0 12px; margin-bottom: 8px; }
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 8px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13.5px;
  color: var(--text-muted);
  position: relative;
}
.nav-item:hover  { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); }
.nav-item .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.nav-item .nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-actions { display: none; gap: 4px; }
.nav-item:hover .nav-actions { display: flex; }
.nav-actions button {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
}
.nav-actions button:hover { background: var(--surface); color: var(--text); }

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  color: var(--text-muted);
  font-size: 9px;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 3px;
  transition: background var(--transition), color var(--transition);
}
.theme-toggle:hover { background: var(--surface-3); color: var(--text); }

.btn-add-sujet {
  margin: 8px 12px 0;
  width: calc(100% - 24px);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 13px;
  transition: all var(--transition);
}
.btn-add-sujet:hover { border-color: var(--accent); color: var(--accent); }

/* ── Main content ────────────────────────────────────── */
.main-content {
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ══════════════ COMPOSANTS ══════════════════════════ */

/* ── Boutons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost { border: 1px solid var(--border); color: var(--text-muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-icon { padding: 7px; }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ── Badge / Tag ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }

/* ── Page title ──────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header .page-actions { margin-left: auto; display: flex; gap: 8px; }

/* ══════════════ KANBAN ══════════════════════════════ */

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}
.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.kanban-col-header .col-count {
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  color: var(--text-muted);
}
.kanban-col[data-statut="todo"]      .kanban-col-header { border-top: 3px solid #6366f1; border-radius: var(--radius) var(--radius) 0 0; }
.kanban-col[data-statut="en_cours"]  .kanban-col-header { border-top: 3px solid #f59e0b; }
.kanban-col[data-statut="bloque"]    .kanban-col-header { border-top: 3px solid #ef4444; }
.kanban-col[data-statut="termine"]   .kanban-col-header { border-top: 3px solid #10b981; }

.kanban-cards {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}
.kanban-cards.drag-over { background: rgba(99,102,241,.07); border-radius: 0 0 var(--radius) var(--radius); }
.drag-placeholder {
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 2px 0;
  pointer-events: none;
  opacity: .7;
}

/* ── Carte Kanban ────────────────────────────────────── */
.k-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: box-shadow var(--transition), transform var(--transition);
  user-select: none;
  /* Flex pour le panneau d'actions à droite */
  display: flex;
  align-items: stretch;
  overflow: hidden; /* clip le panneau aux coins arrondis de la carte */
}
.k-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.k-card.dragging { opacity: .4; cursor: grabbing; }

/* Zone de contenu (texte) */
.k-card-body {
  flex: 1;
  padding: 12px 14px;
  min-width: 0; /* permet la troncature du texte */
}
.k-card-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}
/* Extrait de description : 2 lignes max, troncature CSS garantie */
.k-card-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 4px 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.k-card-meta {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.k-card-sujet {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.k-card-sujet .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.k-card-date { font-size: 11px; color: var(--text-muted); }
.k-card-date-done { color: var(--success); font-weight: 500; }

/* Panneau d'actions (droite) — se révèle au survol */
.k-card-actions {
  width: 0;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface-3);
  border-left: 1px solid transparent;
  transition: width .2s ease, border-color .2s ease;
}
.k-card:hover .k-card-actions {
  width: 44px;   /* 3 boutons empilés en colonne — largeur fixe du panneau */
  border-left-color: var(--border);
}
.k-card-actions button {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.k-card-actions button:hover { background: var(--surface-2); color: var(--text); }

/* Bouton 📝 dans le panneau d'actions : accentué pour signaler le lien note */
.k-card-actions button[data-action="open-note-ref"] {
  color: var(--primary);
}

/* ── Indicateur de retard ────────────────────────────── */
.k-card.overdue  { border-left: 3px solid var(--danger); }
.k-card.due-soon { border-left: 3px solid var(--warning); }

/* ── Tâche gelée : dépend d'un prérequis non terminé (Demande 7) ────── */
.k-card.frozen {
  opacity: .55;
  cursor: not-allowed;
  filter: grayscale(.5);
}
.k-card.frozen .k-card-body { cursor: not-allowed; }

/* ── Badges priorité / dépendance (Demande 7) ────────── */
.k-badge-priorite {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}
.k-badge-priorite-haute { background: var(--warning); color: #1a1a1a; }
.k-badge-dep { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.k-card-date-inherited { font-style: italic; }

/* ══════════════ NOTES ═══════════════════════════════ */

.notes-list { display: flex; flex-direction: column; gap: 10px; }

.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.note-card:hover { border-color: var(--accent); }

.note-card-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
.note-card-icon { font-size: 16px; flex-shrink: 0; }
.note-card-info { flex: 1; min-width: 0; }
.note-card-title {
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-card-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.note-card-preview {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 340px;
}
.note-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.note-card-actions button {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 13px; color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.note-card-actions button:hover { background: var(--surface-2); color: var(--text); }

.note-card-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}
.note-card.open .note-card-body { display: block; }
.note-card.open .note-card-header { border-bottom: 1px solid var(--border); }

.note-viewer {
  width: 100%;
  min-height: 60px;
  background: transparent;
  padding: 12px 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}

/* Styles Markdown compacts — scopés note-viewer et bulles IA du chat */
.note-viewer p, .chat-bubble.ai p { margin: 0 0 8px; }
.note-viewer p:last-child, .chat-bubble.ai p:last-child { margin-bottom: 0; }

/* Titres compacts : jamais plus gros que le corps + hiérarchie visuelle légère */
.note-viewer .md-h, .chat-bubble.ai h2,
.chat-bubble.ai h3, .chat-bubble.ai h4 {
  font-weight: 700; margin: 12px 0 4px; line-height: 1.3; color: var(--text);
}
.note-viewer h3.md-h, .chat-bubble.ai h2 { font-size: 14px; }
.note-viewer h4.md-h, .chat-bubble.ai h3 { font-size: 13.5px; color: var(--text-muted); }
.note-viewer h5.md-h, .chat-bubble.ai h4 { font-size: 13px;   color: var(--text-muted); font-weight: 600; }

.note-viewer ul, .chat-bubble.ai ul,
.note-viewer .md-ul { margin: 4px 0 8px 18px; padding: 0; }
.note-viewer li, .chat-bubble.ai li { margin-bottom: 3px; font-size: 13.5px; }

.note-viewer blockquote, .note-viewer .md-bq,
.chat-bubble.ai blockquote {
  margin: 8px 0; padding: 6px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-muted); font-size: 12.5px;
  font-style: italic; background: var(--surface-2);
  border-radius: 0 4px 4px 0;
}

.note-viewer code, .note-viewer .md-code,
.chat-bubble.ai code {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px; background: var(--surface-3);
  padding: 1px 5px; border-radius: 3px;
  color: var(--accent);
}

.note-viewer hr, .note-viewer .md-hr,
.chat-bubble.ai hr {
  border: none; border-top: 1px solid var(--border);
  margin: 12px 0;
}

.note-viewer .md-task-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.note-viewer .md-task-link:hover {
  background: color-mix(in srgb, var(--primary) 22%, transparent);
}

/* Badge "N tâches liées" dans le titre de la note */
.note-task-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  vertical-align: middle;
  margin-left: 4px;
}

/* Zone de tâches liées dans le corps d'une note */
.note-tasks-zone { margin-top: 12px; }

.note-tasks-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.note-tasks-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.note-task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.note-task-item:last-child { border-bottom: none; }
.note-task-item:hover { background: var(--surface-2); }

.note-task-status {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.note-task-status.todo      { background: color-mix(in srgb, var(--text-muted) 15%, transparent); color: var(--text-muted); }
.note-task-status.en_cours  { background: color-mix(in srgb, #3b82f6 15%, transparent); color: #3b82f6; }
.note-task-status.bloque    { background: color-mix(in srgb, #ef4444 15%, transparent); color: #ef4444; }
.note-task-status.termine   { background: color-mix(in srgb, #22c55e 15%, transparent); color: #22c55e; }

.note-task-titre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Bouton flottant "Créer une tâche" affiché lors d'une sélection de texte dans une note */
.selection-task-btn {
  position: fixed;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  transform: translateX(-50%) translateY(-6px);
  z-index: 9000;
  white-space: nowrap;
  pointer-events: auto;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.selection-task-btn::before { content: '📋'; font-size: 13px; }
.selection-task-btn:hover {
  background: var(--accent-h);
  transform: translateX(-50%) translateY(-8px);
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}

.notes-textarea {
  width: 100%;
  min-height: 200px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  line-height: 1.75;
  resize: vertical;
  color: var(--text);
  transition: border-color var(--transition);
  margin-top: 10px;
}
.notes-textarea:focus { border-color: var(--accent); outline: none; }

/* ── Layout flex pour les modales de tâche (création & édition) ── */
/* La form occupe toute la hauteur du modal-body (flex:1 déjà sur modal-body) */
.tache-form-flex {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
/* La zone description grandit pour remplir l'espace disponible */
.tache-form-desc {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tache-form-desc .form-textarea {
  flex: 1;
  resize: none;
  min-height: 80px;
}
/* Note liée + dates + updates : collés en bas, ne grandissent pas */
.tache-form-bottom {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* ── Badge "N mises à jour" sur la carte Kanban ─────────────────── */
.tache-update-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: color-mix(in srgb, #f59e0b 15%, transparent);
  color: #f59e0b;
  cursor: default;
}

/* ── Section inline dans la modale d'édition de tâche ───────────── */
.tache-updates-zone { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.tache-update-zone-loading { text-align: center; color: var(--text-muted); font-size: 13px; padding: 8px 0; }
.tache-update-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.tache-update-zone-empty { font-size: 12.5px; color: var(--text-muted); font-style: italic; }
.tache-updates-list-inline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.tache-update-item-inline {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12.5px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid #f59e0b;
}
.tache-update-item-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tache-update-item-actions { display: flex; gap: 2px; }
.tache-update-item-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  opacity: .6;
  transition: opacity var(--transition), background var(--transition);
}
.tache-update-item-actions button:hover { opacity: 1; background: var(--surface-3); }
.tache-update-text-inline { line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--text); }

/* ══════════════ EMAILS ══════════════════════════════ */

.email-form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--accent); }
.form-textarea { min-height: 140px; resize: vertical; }

.email-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.email-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.email-item-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.email-item-header:hover { background: var(--surface-3); }
.email-item-objet { font-weight: 500; flex: 1; font-size: 13px; }
.email-item-from { font-size: 12px; color: var(--text-muted); }
.email-item-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.email-item-body {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  white-space: pre-wrap;
  color: var(--text-muted);
  display: none;
}
.email-item.open .email-item-body { display: block; }
.email-item-del {
  margin-left: 8px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.email-item-del:hover { background: rgba(239,68,68,.15); color: var(--danger); }

/* ══════════════ MODAL ═══════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  animation: fadeIn .15s ease;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 800px;
  box-shadow: var(--shadow);
  animation: slideUp .18s ease;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 16px; font-weight: 600;
  flex-shrink: 0;
}
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 18px;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.modal.modal-lg   { max-width: 90%; max-height: 98vh; height: 90%; }
.modal.modal-lg .notes-textarea { min-height: 360px; }
.modal.modal-task { max-width: 90%; height: 90%; }
/* Le corps doit remplir l'espace restant quand la modale a une hauteur fixe */
.modal.modal-lg .modal-body,
.modal.modal-task .modal-body { flex: 1; min-height: 0; }

/* Select "Note liée" : compact au repos, listbox accentuée au focus */
.modal.modal-task select[name="note_id"] {
  font-size: 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  transition: box-shadow 0.12s;
}
.modal.modal-task select[name="note_id"]:not([size="1"]) {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent);
  overflow-x: hidden;
}

/* ── Champ couleur dans modal ────────────────────────── */
.color-picker-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition), border-color var(--transition);
}
.color-swatch:hover, .color-swatch.selected { transform: scale(1.2); border-color: var(--text); }
.color-custom input[type="color"] { width: 28px; height: 28px; padding: 0; border: none; border-radius: 50%; cursor: pointer; }

/* ══════════════ VUES GÉNÉRALES ══════════════════════ */

.view-tabs {
  display: flex; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
}
.view-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
}
.view-tab.active { background: var(--surface-3); color: var(--text); }

/* ══════════════ CARTES SUJETS (Dashboard + Archives) ════════════════ */

/* Grille commune Dashboard et Archives */
.sujet-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* Carte : layout vertical (nom → barre → compteurs) */
.sujet-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid transparent;  /* couleur du sujet injectée en ligne */
  border-radius: var(--radius);
  padding: 14px 14px 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.sujet-card:hover {
  background: var(--surface-3);
  box-shadow: 0 2px 12px rgba(0,0,0,.14);
}
.sujet-card.dormant            { cursor: default; opacity: .7; }
.sujet-card.dormant:hover      { opacity: 1; box-shadow: none; }

.sujet-card-name {
  font-weight: 600; font-size: 13.5px; line-height: 1.35;
}

/* ── Compteurs de tâches par statut ──────────────────── */
/* Bleu = À faire · Orange = En cours · Rouge = Bloqué · Vert = Terminé */
.sc-badges {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 8px;
}
.sc-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px 3px 3px; border-radius: 20px;
}
.sc-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; flex-shrink: 0;
  border-radius: 50%; background: #fff; color: #111;
  font-size: 10px; font-weight: 700;
  overflow: hidden;
}
.sc-badge.todo     { background: rgba(99,102,241,.18); color: #818cf8; }
.sc-badge.en-cours { background: rgba(245,158,11,.18); color: #fbbf24; }
.sc-badge.bloque   { background: rgba(239,68,68,.18);  color: #f87171; }
.sc-badge.termine  { background: rgba(16,185,129,.18); color: #34d399; }
.sc-alert          { font-size: 15px; line-height: 1; cursor: default; }
.sc-alert.due-soon { color: var(--warning); }
.sc-alert.overdue  { color: var(--danger);  }

/* Wrapper archive : carte + bouton Réactiver */
.sujet-card-archive-wrap { display: flex; flex-direction: column; gap: 6px; }
.sujet-card-wake          { width: 100%; }

/* ══════════════ ARCHIVES (anciens styles conservés pour compatibilité) ══════════════ */

.archive-card-name { font-weight: 600; }
.archive-card-date { font-size: 12px; color: var(--text-muted); }

/* ══════════════ EMPTY STATE ══════════════════════════ */

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 12px;
  text-align: center;
}
.empty-state .icon { font-size: 36px; opacity: .5; }
.empty-state p { font-size: 14px; }

/* ══════════════ AIDE RAPIDE — DRAWER ════════════════ */

.help-panel {
  position: fixed; top: 0; right: -450px; bottom: 0;
  width: 450px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0,0,0,.18);
  z-index: 400;
  display: flex; flex-direction: column;
  transition: right .22s ease;
  overflow: hidden;
}
.help-panel--open { right: 0; }

.help-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
  background: var(--surface-2);
}
.help-close {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 14px; color: var(--text-muted);
  transition: background var(--transition);
}
.help-close:hover { background: var(--surface-3); color: var(--text); }

.help-body {
  flex: 1; overflow-y: auto;
  padding: 10px 0 24px;
  display: flex; flex-direction: column; gap: 2px;
}

.help-section { padding: 10px 18px 4px; }
.help-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 8px; padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.help-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.help-list li {
  font-size: 12.5px; color: var(--text-muted);
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  line-height: 1.5;
}
/* Mot-clé / raccourci mis en valeur */
.hi {
  display: inline-block;
  font-size: 11.5px; font-weight: 600; color: var(--text);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
  white-space: nowrap;
}

/* Badges colorés (retard / avertissement) */
.help-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  border-radius: 4px; padding: 1px 6px;
}
.help-badge.danger { background: rgba(239,68,68,.15); color: #ef4444; }
.help-badge.warn   { background: rgba(245,158,11,.15); color: #f59e0b; }

/* Touche clavier */
.help-list kbd {
  display: inline-block;
  font-size: 11px; font-family: inherit;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
  color: var(--text); white-space: nowrap;
}

/* Grille Markdown cheatsheet */
.help-md-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 4px 10px; margin-top: 8px;
  font-size: 12px;
}
.help-md-grid code {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 11.5px; color: var(--accent);
  background: var(--surface-3); border-radius: 3px;
  padding: 1px 5px; white-space: nowrap;
}
.help-md-grid span { color: var(--text-muted); align-self: center; }

/* ══════════════ TOAST ═══════════════════════════════ */

#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideInRight .2s ease;
  max-width: 340px;
}
.toast.success { background: #064e3b; color: #6ee7b7; border: 1px solid #10b981; }
.toast.error   { background: #450a0a; color: #fca5a5; border: 1px solid #ef4444; }
.toast.info    { background: #1e1b4b; color: #a5b4fc; border: 1px solid #6366f1; }

/* ══════════════ ANIMATIONS ══════════════════════════ */

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

/* ══════════════ UTILITIES ═══════════════════════════ */

.hidden   { display: none !important; }
.flex     { display: flex; }
.gap-2    { gap: 8px; }
.mt-1     { margin-top: 4px; }
.mt-2     { margin-top: 8px; }
.mt-3     { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm  { font-size: 12px; }
.font-600 { font-weight: 600; }
.separator { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ══════════════ PENDING INBOX — JA-014 ═════════════ */

.pending-inbox {
  border: 1px solid rgba(245,158,11,.35);
  border-radius: var(--radius);
  overflow: hidden;
}
.pending-inbox-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(245,158,11,.1);
  font-weight: 600; font-size: 13.5px;
  color: #d97706;
}
body.light .pending-inbox-header { color: #92400e; }
.pending-badge {
  background: #f59e0b; color: #fff;
  font-size: 11.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 99px; min-width: 20px; text-align: center;
}
.pending-list  { display: flex; flex-direction: column; }
.pending-item  { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.pending-item-info  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pending-item-from  { font-size: 12px; color: var(--text-muted); }
.pending-item-objet { font-size: 13px; font-weight: 500; flex: 1; }
.pending-item-date  { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.pending-suggestion {
  font-size: 12.5px; color: var(--text-muted);
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.pending-actions { display: flex; align-items: center; gap: 8px; }

/* ══════════════ IA — WIDGETS ════════════════════════ */

/* Spinner de chargement */
.ai-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-loading {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 13px;
  padding: 12px 0;
}

/* Carte de briefing */
.ai-briefing-card {
  background: linear-gradient(135deg, rgba(99,102,241,.08) 0%, transparent 100%);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: var(--radius);
  padding: 18px 20px;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--text);
}
.briefing-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.briefing-content { }
.briefing-content h3 { font-size: 14px; font-weight: 700; margin: 14px 0 4px; color: var(--text); }
.briefing-content h4 { font-size: 13px; font-weight: 600; margin: 10px 0 2px; }
.briefing-content ul { margin: 4px 0 8px 18px; list-style: disc; }
.briefing-content li { margin-bottom: 2px; }
.briefing-content p  { margin-bottom: 8px; }
.btn-xs {
  padding: 2px 8px; font-size: 11px;
  border-radius: var(--radius-sm);
}

/* ══════════════ POPIN JOURNAL EMAILS ══════════════ */
.modal.modal-email-log { max-width: 660px; max-height: 70vh; }
.modal.modal-email-log .modal-body { padding: 0; overflow-y: auto; gap: 0; }
.email-log { display: flex; flex-direction: column; }
.email-log-row {
  display: grid;
  grid-template-columns: 82px 8px minmax(80px, 140px) 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.email-log-row:last-child { border-bottom: none; }
.email-log-row:hover { background: var(--surface-2); }
.email-log-row.is-new { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.email-log-date  { font-family: monospace; font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.email-log-sujet { font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-log-titre { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-log-new-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.email-log-badge {
  background: var(--accent); color: #fff;
  border-radius: 20px; padding: 1px 7px;
  font-size: 11px; font-weight: 700; vertical-align: middle;
}

/* ── Emails pending (non classés) ── */
.pending-email-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2); border-radius: 8px;
  flex-wrap: wrap;
}
.pending-email-meta {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: wrap;
}
.pending-email-sender {
  font-size: 12px; font-weight: 700; color: var(--text); white-space: nowrap;
}
.pending-email-subject {
  font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.pending-email-date {
  font-size: 11px; color: var(--text-muted); white-space: nowrap; font-family: monospace;
}
.pending-email-summary {
  width: 100%; font-size: 12px; color: var(--text-muted); line-height: 1.5;
  margin-top: 4px;
}

/* Alerte de surcharge */
.collision-alert {
  background: rgba(239,68,68,.07);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.collision-period {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(239,68,68,.15);
  font-size: 13px;
}
.collision-period:last-child { border-bottom: none; padding-bottom: 0; }
.collision-date { font-weight: 600; color: var(--danger); min-width: 140px; }
.collision-tasks { display: flex; gap: 6px; flex-wrap: wrap; }
.collision-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 99px;
  font-size: 11px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border);
}

/* Modale résultats IA (JA-010) */
.ai-result-type {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600;
  margin-bottom: 10px;
}
.ai-result-type.actionnable { background: rgba(239,68,68,.12); color: var(--danger); }
.ai-result-type.informatif  { background: rgba(99,102,241,.12); color: var(--accent-h); }

.ai-resume {
  font-size: 13.5px; color: var(--text-muted);
  line-height: 1.65; margin-bottom: 14px;
}

.ai-tasks-list { display: flex; flex-direction: column; gap: 8px; }
.ai-task-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.ai-task-item input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.ai-task-label { flex: 1; }
.ai-task-titre { font-size: 13px; font-weight: 500; }
.ai-task-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ai-task-date  { font-size: 11.5px; color: var(--accent-h); margin-top: 2px; }

/* Résultat de recherche sémantique */
.search-result {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 13.5px;
  line-height: 1.8;
  white-space: pre-wrap;
}

/* ══════════════ ASSISTANT IA — CHAT ══════════════════ */

/* Shell plein-écran dans main-content */
.chat-shell {
  display: flex; flex-direction: column;
  height: calc(100vh - 56px); /* hauteur disponible sous le header */
  max-height: 100%;
}
.chat-header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
/* Titre + badges à gauche ; bouton effacer à droite */
.chat-header-left  { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }
.chat-header-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* Zone de messages scrollable */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}

/* Écran de bienvenue */
.chat-welcome {
  margin: auto;
  text-align: center; max-width: 480px;
  color: var(--text-muted); font-size: 14px; line-height: 1.7;
}
.chat-suggestions {
  display: flex; flex-direction: column; gap: 8px; margin-top: 20px;
}
.chat-suggestion {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 14px;
  font-size: 13px; text-align: left; cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.chat-suggestion:hover { background: var(--surface-3); border-color: var(--accent); }

/* Bulles de conversation */
.chat-bubble {
  display: flex; gap: 10px; max-width: 82%;
}
.chat-bubble.user {
  flex-direction: row-reverse; align-self: flex-end;
}
.chat-bubble.ai { align-self: flex-start; }

.chat-avatar {
  font-size: 18px; flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border-radius: 50%;
  border: 1px solid var(--border);
}

.chat-content {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 14px;
  font-size: 13.5px; line-height: 1.75; color: var(--text);
}
.chat-bubble.user .chat-content {
  background: var(--accent); color: #fff; border-color: transparent;
}
/* Styles du contenu markdown rendu */
.chat-content p  { margin: 0 0 8px; }
.chat-content p:last-child { margin-bottom: 0; }
.chat-content ul { margin: 4px 0 8px 16px; padding: 0; }
.chat-content li { margin-bottom: 3px; }
.chat-content h2, .chat-content h3, .chat-content h4 {
  margin: 10px 0 4px; font-weight: 600;
}

/* Indicateur de frappe (3 points animés) */
.chat-typing-dots {
  display: flex; gap: 4px; align-items: center; padding: 2px 0;
}
.chat-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  animation: dot-bounce .9s infinite ease-in-out;
}
.chat-typing-dots span:nth-child(2) { animation-delay: .15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(.7); opacity: .5; }
  40%           { transform: scale(1);  opacity: 1;  }
}

/* Zone de saisie */
.chat-input-zone {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.chat-input {
  flex: 1; resize: none; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 13.5px; padding: 10px 12px; line-height: 1.5;
  min-height: 42px; max-height: 140px; overflow-y: auto;
  transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--accent); outline: none; }
.chat-input::placeholder { color: var(--text-muted); }

/* Jauge de consommation quotidienne de tokens dans le header du chat */
.token-gauge-widget {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; white-space: nowrap;
}
.tgw-consumed { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tgw-bar-wrap {
  width: 60px; height: 5px; border-radius: 3px;
  background: var(--surface-3); overflow: hidden; flex-shrink: 0;
}
.tgw-bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease, background .4s ease; }
.tgw-rest { font-size: 10.5px; opacity: .75; }
.tgw-caveat { font-size: 10px; color: #f59e0b; opacity: .8; white-space: nowrap; cursor: help; }
.chat-provider-badge {
  font-size: 11px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 2px 8px; white-space: nowrap; cursor: default;
}

/* Wrapper colonne textarea + badge de portée */
.chat-input-wrapper {
  display: flex; flex-direction: column; flex: 1; gap: 4px;
}

/* Filtre par sujet (syntaxe /[nom du sujet]) */
.chat-scope-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  border-radius: 20px; padding: 2px 10px;
  font-size: 11.5px; font-weight: 600;
  margin-bottom: 6px;
}
.chat-scope-badge button {
  background: none; border: none; color: #fff;
  cursor: pointer; font-size: 12px; line-height: 1; padding: 0 2px;
  opacity: .8;
}
.chat-scope-badge button:hover { opacity: 1; }

/* ══════════════ SIDEBAR TOGGLE & RESPONSIVE ══════════════ */

/* ── Backdrop overlay (utilisé en mobile) ───────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
}

/* ── Sidebar rétractible — desktop uniquement ───────────── */
@media (min-width: 769px) {
  .app-shell.sidebar-collapsed {
    grid-template-columns: 0px 1fr;
  }
  .app-shell.sidebar-collapsed .sidebar {
    width: 0; min-width: 0;
    overflow: hidden; padding: 0; border-right: none;
  }
}

/* ── Tablette et mobile (≤ 768px) ───────────────────────── */
@media (max-width: 768px) {
  /* Grille sans colonne sidebar — la sidebar devient un overlay fixe */
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0; top: var(--header-h); bottom: 0;
    width: 280px; z-index: 300;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  /* Header compact */
  .app-header { padding: 0 12px; gap: 8px; }
  #btn-header-kanban,
  #btn-header-archives { display: none; }
  .header-search input { width: 130px; }

  /* Contenu : padding réduit */
  .main-content { padding: 16px; }

  /* Modales : quasi plein écran */
  .modal { max-width: calc(100vw - 20px) !important; margin: 10px; }

  /* Kanban : scroll horizontal */
  .kanban-board { overflow-x: auto; }
}

/* ── Paramètres IA ───────────────────────────────────────── */
.settings-card        { max-width: 560px; }
.settings-hint        { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; line-height: 1.5; }
.settings-footer      { display: flex; align-items: center; gap: 16px; margin-top: 24px; }
.settings-status      { font-size: 13px; color: var(--text-muted); }
.key-input-row        { display: flex; gap: 8px; align-items: center; }
.key-input-row .form-input { flex: 1; }
.settings-key-status  { font-size: 12.5px; margin: 4px 0 8px; line-height: 1.5; }
.settings-key-status code { font-family: monospace; background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 3px; }
.settings-key-status.ok   { color: var(--success); }
.settings-key-status.info { color: var(--text-muted); }
.settings-key-status.warn { color: #f59e0b; }

/* ── Planning annuel ─────────────────────────────────────────────── */
.planning-scroll {
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 24px;
}

.planning-grid {
  position: relative;
  user-select: none;
  cursor: crosshair;
  flex-shrink: 0;
}

.planning-grid > div { position: absolute; box-sizing: border-box; }

.planning-corner {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  left: 0; top: 0;
  z-index: 3;
}

.planning-month-hdr {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  top: 0;
  z-index: 2;
}

.planning-day-num {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5px;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  left: 0;
  z-index: 2;
}

.planning-row-bg  { left: 0; background: transparent; z-index: 0; }
.planning-row-alt { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }

.planning-cell {
  border-right:  1px solid color-mix(in srgb, var(--border) 40%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
  z-index: 0;
  transition: background .1s;
  display: flex;
  align-items: center;
}
.planning-cell:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }

.planning-cell-invalid {
  background: repeating-linear-gradient(
    135deg,
    transparent, transparent 4px,
    color-mix(in srgb, var(--border) 30%, transparent) 4px,
    color-mix(in srgb, var(--border) 30%, transparent) 5px
  );
  pointer-events: none;
}

#planning-jalons-layer {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
  z-index: 11;
}

.planning-milestone-dot {
  position: absolute;
  border-radius: 50%;
  pointer-events: auto;
  cursor: default;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
  transition: transform .1s;
}

.planning-milestone-dot:hover {
  transform: scale(1.4);
  z-index: 12;
}

.planning-cell-weekend {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
}

.planning-cell-weekend:hover {
  background: color-mix(in srgb, #f59e0b 22%, transparent);
}

.planning-cell-dow {
  font-size: 9px;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0.55;
  padding: 0 3px;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

.planning-cell-weekend .planning-cell-dow {
  opacity: 0.8;
  font-weight: 600;
  color: #b45309;
}

.planning-drag-preview {
  position: absolute;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  border: 2px dashed var(--primary);
  border-radius: 3px;
  pointer-events: none;
  z-index: 15;
}

#planning-blocks-layer {
  position: absolute !important;
  top: 0 !important; left: 0 !important;
  width: 100% !important; height: 100% !important;
  pointer-events: none;
  z-index: 10;
}

.planning-block {
  position: absolute;
  border: 1.5px solid;
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto;
  transition: filter .15s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 4px;
}
.planning-block:hover { filter: brightness(1.15); z-index: 20 !important; }

.planning-block-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 100%;
  padding: 3px 2px;
  pointer-events: none;
  line-height: 1.2;
}

.planning-error {
  position: absolute;
  top: 50px; left: 36px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Petit mobile (≤ 480px) ─────────────────────────────── */
@media (max-width: 480px) {
  .app-header { padding: 0 8px; gap: 6px; }
  .header-search { display: none; }
  .main-content { padding: 12px; }
  .card { padding: 14px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-actions { width: 100%; overflow-x: auto; padding-bottom: 2px; }
}

/* ══════════════ AUTHENTIFICATION (pages hors SPA) ══════════════ */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.auth-logo {
  font-weight: 700;
  font-size: 20px;
  color: var(--accent-h);
  text-align: center;
  margin-bottom: 4px;
}
.auth-logo span { color: var(--text-muted); font-weight: 400; }
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.auth-error, .auth-success {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.auth-error   { background: rgba(239,68,68,.12);  color: var(--danger);  border-color: rgba(239,68,68,.3); }
.auth-success { background: rgba(16,185,129,.12); color: var(--success); border-color: rgba(16,185,129,.3); }
.auth-links { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.auth-links a { color: var(--accent-h); }
.auth-links a:hover { text-decoration: underline; }
.auth-btn-block { width: 100%; justify-content: center; margin-top: 8px; }
.auth-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ══════════════ RAPPORT MENSUEL ═════════════════════ */

.report-range { display: flex; align-items: center; gap: 6px; }
.report-range-sep { color: var(--text-muted); font-size: 13px; }

.report-sujets { display: flex; flex-direction: column; gap: 12px; }

.report-sujet-card { transition: background var(--transition); }
/* Sujet soldé : plus aucune tâche ouverte sur les tâches remontées dans le rapport */
.report-sujet-card.is-complete { background: rgba(16,185,129,.12); }

.report-sujet-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.report-sujet-nom { font-weight: 600; }
.report-sujet-done { font-size: 12px; font-weight: 500; color: var(--success); }
.report-sujet-count { font-size: 12px; color: var(--text-muted); }

.report-taches-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.report-taches-list li { font-size: 13px; }
.report-tache-row { display: flex; align-items: center; gap: 8px; }
.report-tache-date { margin-left: auto; color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* Journal de suivi (tache_updates) déplié sous chaque tâche du rapport */
.report-tache-updates {
  list-style: none; margin: 4px 0 2px 22px; padding-left: 10px;
  border-left: 2px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.report-tache-updates li { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.report-tache-update-date { color: var(--text-muted); margin-right: 4px; white-space: nowrap; }

.report-restantes { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.report-restantes-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.report-restantes-none { margin-top: 12px; font-size: 12px; color: var(--success); }
