/* ========== Plateforme (IA, dashboard, intégrations, stats, auth) ========== */
/* ==================== Module: Copilot & Assistants IA ==================== */
/* Assistant flottant + styles chat .agent-* (dashboard + FAB) */

:root {
  --assistant-accent: var(--sf-color-cta);
  --assistant-accent-glow: rgba(37, 99, 235, 0.35);
  --copilot-fab-size: 50px;
  --agent-input-height: 40px;
  --agent-input-radius: 10px;
}

.copilot-fab {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  right: 1.5rem;
  z-index: 1020;
  width: var(--copilot-fab-size);
  height: var(--copilot-fab-size);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: var(--sf-color-cta);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--assistant-accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--sf-motion-fast) var(--sf-ease-out), box-shadow var(--sf-motion-fast) var(--sf-ease-out);
}
/* Sur pages dense (paramètres CRM) : FAB ne capte pas les clics hors son disque */
body[data-app="crm"] .copilot-fab,
body[data-page*="parametre"] .copilot-fab {
  pointer-events: auto;
}
.copilot-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--assistant-accent-glow); }
.copilot-fab.is-open { transform: rotate(45deg); background: var(--sf-color-cta-hover); }

.copilot-fab-badge {
  position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 999px; background: #ef4444; color: #fff;
  font-size: var(--font-size-2xs); font-weight: 700; line-height: 16px; text-align: center;
}
.copilot-fab-badge:empty, .copilot-fab-badge[hidden] { display: none; }
.copilot-fab-badge--pulse { animation: copilot-badge-pulse 0.9s ease-in-out 2; }
@keyframes copilot-badge-pulse { 50% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) {
  .copilot-fab-badge--pulse { animation: none; }
  .copilot-fab, .copilot-panel { transition: none; }
}

.copilot-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1025;
  display: none;
  pointer-events: none;
}
.copilot-backdrop.is-visible { display: block; pointer-events: auto; }

.copilot-panel {
  position: fixed;
  bottom: calc(1.5rem + var(--copilot-fab-size) + 0.5rem + env(safe-area-inset-bottom, 0px));
  right: 1.5rem;
  z-index: 1030;
  width: min(440px, calc(100vw - 1.5rem));
  max-width: calc(100vw - 1.5rem);
  height: min(78dvh, 620px);
  max-height: calc(100dvh - 5rem);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.16);
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease, width 0.25s ease, height 0.25s ease;
}
.copilot-panel.is-open { transform: none; opacity: 1; pointer-events: auto; }
.copilot-panel.is-expanded {
  width: min(640px, calc(100vw - 1.5rem));
  height: min(85dvh, 720px);
}

.copilot-header {
  padding: 0.55rem 0.85rem;
  min-height: 46px;
  background: var(--sf-color-cta);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.copilot-header-title {
  font-weight: 650;
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}
.copilot-dot { width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }
.copilot-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.copilot-suggestions {
  padding: 0.45rem 0.75rem;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.copilot-suggestions:empty,
.copilot-suggestions[hidden],
.agent-suggestions[hidden] { display: none; }
.copilot-messages { flex: 1; }

.copilot-input-area {
  padding: 0.55rem 0.75rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}
.copilot-textarea {
  flex: 1;
  min-width: 0;
  width: 100%;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--agent-input-radius, 10px);
  padding: 0.55rem 0.75rem;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  min-height: var(--agent-input-height, 40px);
  height: var(--agent-input-height, 40px);
  max-height: 120px;
  resize: none;
  box-sizing: border-box;
}
.copilot-send {
  width: var(--agent-input-height, 40px);
  height: var(--agent-input-height, 40px);
  flex-shrink: 0;
  background: var(--assistant-accent);
  color: #fff;
  border: 0;
  border-radius: var(--agent-input-radius, 10px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.copilot-send:disabled { opacity: 0.5; cursor: not-allowed; }
.copilot-send svg { display: block; }
.copilot-send:focus-visible { outline: 2px solid var(--sf-color-cta); outline-offset: 2px; }

.copilot-close,
.copilot-expand {
  border: 0;
  width: 32px;
  height: 32px;
  opacity: 0.8;
  cursor: pointer;
  border-radius: 6px;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.copilot-close {
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath d='M3 3l10 10M13 3L3 13' fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-width='2.5'/%3e%3c/svg%3e") center / 1rem no-repeat;
  font-size: 0;
  color: transparent;
  line-height: 0;
  overflow: hidden;
}
.copilot-expand {
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath d='M2 6V2h4M14 6V2h-4M2 10v4h4M14 10v4h-4' fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8'/%3e%3c/svg%3e") center / 0.95rem no-repeat;
}
.copilot-expand.is-expanded {
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath d='M6 2v4H2M10 2v4h4M6 14v-4H2M10 14v-4h4' fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8'/%3e%3c/svg%3e") center / 0.95rem no-repeat;
}
.copilot-close:hover,
.copilot-expand:hover { opacity: 1; background-color: rgba(255, 255, 255, 0.15); }
.copilot-close:focus-visible,
.copilot-expand:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Chat partagé */
.copilot-messages,
.agent-messages {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem;
  padding-bottom: 1.25rem;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  min-height: 0;
}
.copilot-messages::-webkit-scrollbar,
.agent-messages::-webkit-scrollbar,
.agent-display-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.copilot-messages::-webkit-scrollbar-track,
.agent-messages::-webkit-scrollbar-track,
.agent-display-body::-webkit-scrollbar-track {
  background: transparent;
}
.copilot-messages::-webkit-scrollbar-thumb,
.agent-messages::-webkit-scrollbar-thumb,
.agent-display-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.copilot-messages::-webkit-scrollbar-thumb:hover,
.agent-messages::-webkit-scrollbar-thumb:hover,
.agent-display-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.agent-welcome {
  color: #4a5568;
  font-size: var(--font-size-sm);
  line-height: 1.45;
  padding: 0.45rem 0.55rem;
  background: #f8fafc;
  border-radius: 8px;
}
.agent-welcome strong { display: block; font-size: var(--font-size-base); color: #1a202c; margin-bottom: 0.15rem; }
.agent-welcome p { margin: 0; }

.agent-msg { display: flex; flex-direction: column; max-width: 92%; }
.agent-msg-user { align-self: flex-end; align-items: flex-end; }
.agent-msg-bot { align-self: flex-start; align-items: flex-start; }
.agent-bubble {
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  font-size: var(--font-size-sm);
  line-height: 1.45;
}
.agent-msg-user .agent-bubble {
  background: var(--sf-color-cta);
  color: #fff;
  border-bottom-right-radius: 4px;
  max-width: 85%;
}
.copilot-panel .agent-msg-user .agent-bubble {
  background: var(--sf-color-cta);
}
.agent-msg-bot .agent-bubble {
  background: #f8fafc;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  max-width: 95%;
}
.agent-msg-bot .agent-bubble p { margin: 0 0 0.35rem; }
.agent-msg-bot .agent-bubble p:last-child { margin-bottom: 0; }
.agent-msg-bot .agent-bubble ul, .agent-msg-bot .agent-bubble ol { margin: 0.35rem 0; padding-left: 1.2rem; }
.agent-msg-bot .agent-bubble code { background: #edf2f7; padding: 0.1rem 0.3rem; border-radius: 3px; }
.agent-typing .agent-bubble { color: #9ca3af; font-style: italic; }

.agent-links, .agent-attachments { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.35rem; }
.agent-link-btn {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  background: #ebf8ff;
  color: #2b6cb0;
  border: 1px solid #bee3f8;
  border-radius: 6px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
}
.agent-link-btn:hover { background: #bee3f8; }

.agent-suggestions { display: flex; gap: 0.35rem; flex-wrap: wrap; padding: 0 0.75rem 0.5rem; }
.agent-choices.agent-suggestions { padding: 0.25rem 0; }
.agent-pill {
  flex-shrink: 0;
  padding: 0.3rem 0.7rem;
  background: #f8fafc;
  color: #4a5568;
  border: 1px solid #dbe3ee;
  border-radius: 100px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.agent-pill:hover { background: var(--sf-color-cta); color: #fff; border-color: var(--sf-color-cta); }

.agent-display {
  margin: 0.6rem 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  overflow: visible;
  max-width: 100%;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  border-left: 3.5px solid var(--sf-color-cta);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.agent-display.source-crm { border-left-color: var(--sf-color-cta); }
.agent-display.source-erp { border-left-color: var(--sf-color-success); }
.agent-display.source-hrm { border-left-color: var(--sf-color-gold-dark); }
.agent-display.source-esg { border-left-color: #059669; }
.agent-display.source-bpm { border-left-color: #d97706; }
.agent-display.source-grc { border-left-color: #dc2626; }
.agent-display.source-marketing { border-left-color: #db2777; }
.agent-display-title {
  padding: 0.55rem 0.85rem;
  background: #f8fafc;
  font-weight: 650;
  font-size: var(--font-size-sm);
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: -0.01em;
}
.agent-display-body {
  padding: 0.65rem 0.85rem 0.85rem;
  overflow: visible;
  min-width: 0;
}
/* Tables / listes denses : scroll interne uniquement (évite de couper les KPI courts) */
.agent-display-type-table .agent-display-body,
.agent-display-type-list .agent-display-body,
.agent-display-type-ranking .agent-display-body {
  max-height: min(28rem, 55vh);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
}
.agent-display-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.agent-display-table th, .agent-display-table td { padding: 0.45rem 0.75rem; border-bottom: 1px solid #f1f5f9; }
.agent-display-table th { background: #f8fafc; text-align: left; font-weight: 600; color: #475569; }
.agent-display-overflow { overflow-x: auto; max-width: 100%; scrollbar-width: thin; margin-top: 0.25rem; }
.agent-display-kv { display: flex; flex-direction: column; gap: 0.15rem; }
.agent-display-kv-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.6rem;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.agent-display-kv-item:hover { background: #f8fafc; }
.agent-display-kv-item:last-child { border-bottom: none; }
.agent-kv-label { color: #64748b; font-weight: 500; flex: 1; min-width: 0; word-break: break-word; }
.agent-kv-value {
  color: #0f172a;
  font-weight: 600;
  text-align: right;
  flex: 0 1 auto;
  max-width: 58%;
  min-width: 0;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}
.agent-display-list-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid #f0f4f8; }
.agent-display-list-item:last-child { border-bottom: none; }
.agent-display-list-main { flex: 1; min-width: 0; }
.agent-display-list-title { font-weight: 600; font-size: var(--font-size-sm); }
.agent-display-list-sub { font-size: var(--font-size-xs); color: #718096; }
.agent-ranking { display: flex; flex-direction: column; gap: 0.55rem; }
.agent-ranking-head { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; gap: 0.5rem; align-items: baseline; }
.agent-ranking-num { font-weight: 700; font-size: var(--font-size-sm); color: #94a3b8; }
.agent-ranking-name { font-weight: 600; font-size: var(--font-size-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-ranking-value { font-weight: 700; font-size: var(--font-size-sm); }
.agent-ranking-bar-track { height: 0.4rem; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.agent-ranking-bar { height: 100%; background: #1e3a5f; border-radius: 999px; }
.agent-ranking-row:first-child .agent-ranking-bar { background: #0f766e; }
.agent-ranking-sub, .agent-ranking-footnote { font-size: var(--font-size-xs); color: #64748b; }
.agent-display-stat-card { display: flex; flex-direction: column; gap: 0.2rem; }
.agent-stat-label { font-size: var(--font-size-xs); color: #718096; }
.agent-stat-value { font-size: var(--font-size-sm); font-weight: 700; color: #1a202c; font-variant-numeric: tabular-nums; }
.agent-stat-trend { font-size: var(--font-size-sm); font-weight: 600; }
.agent-display-success { padding: 0.65rem 0.75rem; background: #f0fff4; border: 1px solid #9ae6b4; border-radius: 8px; border-left: 3px solid #10b981; }
.agent-success-title { font-weight: 650; font-size: var(--font-size-sm); margin-bottom: 0.2rem; color: #22543d; }
.agent-success-text { margin: 0; font-size: var(--font-size-sm); color: #22543d; }
.agent-success-link { display: inline-block; margin-top: 0.35rem; }
.agent-display-default { margin: 0; font-size: var(--font-size-sm); color: #4a5568; }

.agent-form-card { margin: 0.5rem 0; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; max-width: 100%; }
.agent-form-card.agent-form-confirm { border-color: #bee3f8; box-shadow: 0 0 0 1px rgba(49, 130, 206, 0.12); }
.agent-form-title { padding: 0.45rem 0.7rem; background: #f7fafc; font-weight: 600; font-size: var(--font-size-sm); border-bottom: 1px solid #e2e8f0; }
.agent-form-hint { padding: 0.35rem 0.7rem; font-size: var(--font-size-xs); color: #4a5568; background: #fafafa; border-bottom: 1px solid #e2e8f0; }
.agent-form-body { padding: 0.55rem 0.7rem; }
.agent-form-group { margin-bottom: 0.45rem; }
.agent-form-label { display: block; font-size: var(--font-size-sm); font-weight: 500; color: #4a5568; margin-bottom: 0.2rem; }
.agent-form-input { width: 100%; padding: 0.4rem 0.55rem; border: 1px solid #e2e8f0; border-radius: 6px; font-size: var(--font-size-sm); box-sizing: border-box; }
.agent-form-input:focus { outline: none; border-color: var(--sf-color-cta); box-shadow: 0 0 0 3px var(--sf-color-cta-soft); }
.agent-form-input[aria-invalid="true"] { border-color: #fc8181; }
.agent-form-help, .agent-form-group .form-field-error { font-size: var(--font-size-xs); margin-top: 0.2rem; }
.agent-form-group .form-field-error { color: #c53030; }
.agent-form-buttons { display: flex; gap: 0.5rem; padding-top: 0.5rem; border-top: 1px solid #f0f4f8; margin-top: 0.4rem; }
.agent-confirm-btn { padding: 0.4rem 0.9rem; background: var(--sf-color-cta, #2563eb); color: #fff; border: 0; border-radius: var(--sf-radius-sm, 6px); font-weight: 600; cursor: pointer; transition: background var(--sf-motion-fast) var(--sf-ease-out); }
.agent-confirm-btn:hover:not(:disabled) { background: var(--sf-color-cta-hover, #1d4ed8); }
.copilot-panel .agent-confirm-btn { background: var(--sf-color-cta, #2563eb); }
.agent-confirm-btn:disabled { background: var(--sf-color-border, #cbd5e0); cursor: not-allowed; }
.agent-cancel-btn { padding: 0.4rem 0.9rem; background: #fff; color: var(--sf-color-text-muted, #718096); border: 1px solid var(--sf-color-border, #e2e8f0); border-radius: var(--sf-radius-sm, 6px); cursor: pointer; }
.agent-search-select { display: flex; flex-direction: column; gap: 0.35rem; }
.agent-line-items { display: flex; flex-direction: column; gap: 0.45rem; }
.agent-line-item { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.agent-line-item .agent-line-product { flex: 1 1 140px; }
.agent-line-item .agent-line-qty { width: 4rem; }
.agent-line-item .agent-line-price { width: 5.5rem; }
.agent-line-remove { width: 2rem; height: 2rem; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; cursor: pointer; }
.agent-line-add { margin-top: 0.35rem; padding: 0.35rem 0.65rem; font-size: var(--font-size-sm); border: 1px dashed #cbd5e0; border-radius: 6px; background: #f7fafc; cursor: pointer; }

.copilot-fab, .director-feedback-fab { display: none !important; }
body:is([data-app="crm"], [data-app="erp"], [data-app="hrm"], [data-app="marketing"], [data-app="bpm"], [data-app="grc"], [data-app="esg"], [data-app="general"], [data-app="conseiller"]):not(.access-denied) :is(.copilot-fab, .director-feedback-fab) {
  display: inline-flex !important;
}
body.access-denied :is(.copilot-fab, .director-feedback-fab, .copilot-panel, .copilot-backdrop, .director-feedback-panel, .director-feedback-backdrop) {
  display: none !important;
}
.director-feedback-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9005;
  display: none;
  background: rgba(15, 23, 42, 0.36);
}
.director-feedback-backdrop.is-visible { display: block; }
.director-feedback-fab {
  position: fixed;
  right: calc(1.5rem + var(--copilot-fab-size) + 0.75rem);
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  z-index: 1020;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 50%;
  background: #fff;
  color: #1f2937;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.14);
  cursor: pointer;
}
.director-feedback-panel {
  position: fixed;
  right: 1.5rem;
  bottom: calc(1.5rem + var(--copilot-fab-size) + 0.5rem + env(safe-area-inset-bottom, 0px));
  z-index: 9010;
  display: none;
  width: min(420px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 7rem);
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  overflow: auto;
}
/* Sans copilot (ex. conseiller) : FAB seul en bas-droite */
body:not(:has(#copilotFab)) .director-feedback-fab { right: 1.5rem; }
body:not(:has(#copilotFab)) .director-feedback-panel {
  bottom: calc(1.5rem + 48px + 0.5rem + env(safe-area-inset-bottom, 0px));
}
.director-feedback-panel.is-open { display: block; }
.director-feedback-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.director-feedback-header-title { font-size: var(--font-size-base); font-weight: 700; }
.director-feedback-close {
  border: 0;
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath d='M3 3l10 10M13 3L3 13' fill='none' stroke='%2364748b' stroke-linecap='round' stroke-width='2.5'/%3e%3c/svg%3e") center / 1.1rem no-repeat;
  width: 32px;
  height: 32px;
  cursor: pointer;
  opacity: 0.6;
  font-size: 0;
  color: transparent;
  line-height: 0;
  overflow: hidden;
}
.director-feedback-close:hover { opacity: 1; }
.director-feedback-body { display: grid; gap: var(--space-2); padding: 0.9rem 1rem 1rem; }
.director-feedback-body .form-label { margin-bottom: 0; }
.director-feedback-body textarea.form-control { min-height: 110px; resize: vertical; }

@media (max-width: 768px) {
  .copilot-fab { right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
  .copilot-panel {
    right: 0.5rem;
    bottom: calc(1rem + var(--copilot-fab-size) + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 1rem);
    height: calc(100dvh - 4.5rem);
    max-height: calc(100dvh - 4.5rem);
    border-radius: 12px;
  }
  .director-feedback-fab { right: calc(1rem + var(--copilot-fab-size) + 0.65rem); bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
  .director-feedback-panel {
    right: 0.75rem;
    bottom: calc(1rem + var(--copilot-fab-size) + 0.5rem + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 1.5rem);
  }
  body:not(:has(#copilotFab)) .director-feedback-fab { right: 1rem; }
  body:not(:has(#copilotFab)) .director-feedback-panel {
    bottom: calc(1rem + 48px + 0.5rem + env(safe-area-inset-bottom, 0px));
  }
  .agent-msg-user .agent-bubble, .agent-msg-bot .agent-bubble { max-width: 95%; }
}

/* ==================== Module: Inline Agent IA ==================== */
/* Agent inline partagé — compact (formations HRM, règles BPM) */
.sf-inline-agent-section,
.hrm-formations-section {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    background: #fafbfc;
}
.sf-inline-agent--compact {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.65rem;
    margin-bottom: 0.75rem;
}
.sf-inline-agent__toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.35rem;
}
.sf-inline-agent__label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}
.sf-inline-agent__messages {
    min-height: 0;
    max-height: 18rem;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.5rem;
    background: #fff;
    margin-top: 0.45rem;
}
.sf-inline-agent__messages:empty {
    display: none;
    margin: 0;
    padding: 0;
    border: none;
}
.sf-inline-agent__msg {
    max-width: 94%;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    font-size: var(--font-size-sm);
    line-height: 1.4;
    margin-bottom: 0.3rem;
    white-space: pre-wrap;
}
.sf-inline-agent__msg:last-child {
    margin-bottom: 0;
}
.sf-inline-agent__msg--user {
    margin-left: auto;
    background: #e8f0fe;
    color: #1e3a5f;
}
.sf-inline-agent__msg--assistant {
    margin-right: auto;
    background: #f1f5f9;
    color: #334155;
}
.sf-inline-agent__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex: 1;
    min-width: 0;
}
.sf-inline-agent--compact .sf-inline-agent-suggest {
    font-size: var(--font-size-xs);
    padding: 0.1rem 0.45rem;
    line-height: 1.35;
}
.sf-inline-agent__input {
    display: flex;
    gap: 0.35rem;
    align-items: flex-end;
}
.sf-inline-agent__input textarea {
    min-height: 38px;
    height: 38px;
    max-height: 4rem;
    resize: none;
    font-size: var(--font-size-sm);
    padding: 0.45rem 0.5rem;
    line-height: 1.35;
    box-sizing: border-box;
}
.sf-inline-agent__input .btn {
    flex-shrink: 0;
    height: 38px;
    padding: 0 0.65rem;
    font-size: var(--font-size-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.sf-inline-agent__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}
.sf-inline-agent__actions .btn {
    font-size: var(--font-size-xs);
    padding: 0.15rem 0.45rem;
}

/* --- Améliorations Ergonomie Conseiller : Toasts & Split-Screen --- */
.sf-toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 280px;
    max-width: 420px;
    padding: 0.75rem 1rem;
    background: var(--card-bg, #ffffff);
    color: var(--text-color, #1e293b);
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #3b82f6;
    margin-bottom: 0.5rem;
    pointer-events: auto;
    animation: sfToastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: var(--font-size-sm);
    font-weight: 500;
}
.sf-toast--success {
    border-left-color: #10b981;
}
.sf-toast--error {
    border-left-color: #ef4444;
}
.sf-toast--hide {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
}
@keyframes sfToastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
#wsReconSplitGrid .sf-table-scroll {
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    background: #fff;
}

