/* ═══════════════════════════════════════════════════════════════════════════
   ai-assistant.css — Widget IA JP Digital
   Design : floating chat bubble + panel moderne, responsive
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --ai-brand:         var(--brand, #1f56ff);
  --ai-brand-dark:    var(--brand-deep, #1847d9);
  --ai-brand-light:   var(--surface-2, #e9f0ff);
  --ai-surface:       var(--surface-2, #f8faff);
  --ai-surface-2:     var(--surface, #ffffff);
  --ai-border:        var(--border, #dbe2ef);
  --ai-text:          var(--text, #1d273b);
  --ai-text-muted:    var(--muted, #5f6b83);
  --ai-bot-bg:        var(--surface-2, #eef3ff);
  --ai-user-bg:       var(--brand, #1f56ff);
  --ai-user-text:     #ffffff;
  --ai-shadow:        0 12px 46px rgba(var(--brand-rgb, 31, 86, 255),0.20), 0 4px 16px rgba(0,0,0,0.18);
  --ai-radius:        18px;
  --ai-radius-msg:    14px;
  --ai-z:             9999;
  --ai-panel-w:       380px;
  --ai-panel-h:       560px;
  --ai-command-gap:   16px;
  --ai-command-gap-mobile: 10px;
  --ai-command-radius: 22px;
  --ai-command-radius-mobile: 18px;
  --ai-fab-right:     28px;
  --ai-fab-bottom:    28px;
  --ai-fab-right-mobile: 16px;
  --ai-fab-bottom-mobile: 16px;
}

/* ── Floating Toggle Button ─────────────────────────────────────────────── */
#aiFloatingBtn {
  --ai-brand: #ff6a2b;
  --ai-brand-dark: #32120c;
  --ai-brand-light: #121a26;
  --ai-surface: #0c121c;
  --ai-surface-2: #121a26;
  --ai-border: rgba(255, 173, 92, 0.28);
  --ai-text: #f4f7fb;
  --ai-text-muted: #98a7bb;
  --ai-bot-bg: #121a26;
  --ai-user-bg: #ff6a2b;
  --ai-user-text: #ffffff;
  --ai-shadow: 0 18px 58px rgba(0,0,0,0.46), 0 0 46px rgba(255, 106, 43,0.12), inset 0 1px 0 rgba(255,255,255,0.04);
  --brand: #ff6a2b;
  --brand-rgb: 255, 106, 43;
  --brand-2: #ffb347;
  --brand-2-rgb: 255, 179, 71;
  --accent: #6ee7ff;
  --accent-rgb: 110, 231, 255;
  --brand-deep: #32120c;
  --surface: #0c121c;
  --surface-2: #121a26;
  --border: rgba(255, 173, 92, 0.28);
  --text: #f4f7fb;
  --muted: #98a7bb;
  position: fixed;
  bottom: var(--ai-fab-bottom);
  right: var(--ai-fab-right);
  z-index: var(--ai-z);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(var(--accent-rgb, 110, 231, 255),0.26) 0%, rgba(var(--accent-rgb, 110, 231, 255),0) 34%),
    radial-gradient(circle at 32% 28%, rgba(var(--brand-2-rgb, 255, 179, 71),0.34) 0%, rgba(var(--brand-2-rgb, 255, 179, 71),0) 40%),
    radial-gradient(circle at 72% 72%, rgba(var(--brand-rgb, 255, 106, 43),0.42) 0%, rgba(var(--brand-rgb, 255, 106, 43),0) 48%),
    conic-gradient(from 180deg, #130f18, #261116, #5a1f11, #ff6a2b, #ffd16f, #261116, #130f18);
  border: 1px solid rgba(var(--brand-2-rgb, 255, 179, 71),0.36);
  cursor: pointer;
  box-shadow: 0 10px 38px rgba(var(--brand-rgb, 255, 106, 43),0.34), 0 0 28px rgba(var(--accent-rgb, 110, 231, 255),0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), box-shadow 0.22s, border-radius 0.4s ease;
  outline: none;
  animation: jarvisDrift 6.4s ease-in-out infinite;
  overflow: hidden;
}
#aiFloatingBtn:hover {
  transform: scale(1.10);
  box-shadow: 0 16px 48px rgba(var(--brand-rgb, 255, 106, 43),0.42), 0 0 34px rgba(var(--accent-rgb, 110, 231, 255),0.24);
}
#aiFloatingBtn:active { transform: scale(0.96); }
#aiFloatingBtn svg { width: 28px; height: 28px; fill: #fff; }
#aiFloatingBtn.open svg.icon-chat { display: none; }
#aiFloatingBtn.open svg.icon-close { display: block !important; }
#aiFloatingBtn svg.icon-close { display: none; }

/* Lueur pulsante quand JARVIS ecoute en arriere-plan (panneau ferme) */
#aiFloatingBtn.jarvis-listening {
  box-shadow: 0 10px 40px rgba(var(--brand-rgb, 255, 106, 43),0.38), 0 0 0 4px rgba(var(--brand-2-rgb, 255, 179, 71),0.22), 0 0 30px rgba(var(--accent-rgb, 110, 231, 255),0.56);
  animation: jarvisDrift 6.4s ease-in-out infinite, jarvisListenPulse 1.35s ease-in-out infinite;
}

#aiFloatingBtn.jarvis-opening {
  animation: jarvisCoreIgnition 0.82s cubic-bezier(.18,.84,.24,1), jarvisDrift 6.4s ease-in-out 0.82s infinite;
}

/* Flash dore quand une reponse arrive et le panneau est ferme */
#aiFloatingBtn.jarvis-has-response {
  animation: jarvisDrift 6.4s ease-in-out infinite, jarvisResponseNotif 0.55s ease-in-out 3;
}

#aiFloatingBtn.jarvis-human {
  border-radius: 24px;
  width: 66px;
  height: 74px;
}

#aiFloatingBtn.jarvis-orb {
  border-radius: 50%;
}

#aiFloatingBtn::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  border: 1.5px solid rgba(var(--brand-2-rgb, 255, 179, 71),0.74);
  box-shadow: inset 0 0 14px rgba(var(--accent-rgb, 110, 231, 255),0.14);
  animation: jarvisRingSpin 3.4s linear infinite;
}

#aiFloatingBtn.jarvis-human::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 8px;
  width: 28px;
  height: 34px;
  border-radius: 50% 50% 42% 42%;
  background: linear-gradient(180deg, rgba(var(--accent-rgb, 0, 188, 212),0.9), rgba(var(--brand-rgb, 31, 86, 255),0.9));
  box-shadow: 0 -17px 0 -8px rgba(206,223,255,0.95);
}

/* Badge notification */
#aiBadge {
  position: absolute;
  top: 0;
  right: 0;
  background: #ff4757;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  display: none;
}

/* ── Panel Principal ─────────────────────────────────────────────────────── */
#aiPanel {
  --ai-brand: #ff6a2b;
  --ai-brand-dark: #32120c;
  --ai-brand-light: #121a26;
  --ai-surface: #0c121c;
  --ai-surface-2: #121a26;
  --ai-border: rgba(255, 173, 92, 0.28);
  --ai-text: #f4f7fb;
  --ai-text-muted: #98a7bb;
  --ai-bot-bg: #121a26;
  --ai-user-bg: #ff6a2b;
  --ai-user-text: #ffffff;
  --ai-shadow: 0 18px 58px rgba(0,0,0,0.46), 0 0 46px rgba(255, 106, 43,0.12), inset 0 1px 0 rgba(255,255,255,0.04);
  --brand: #ff6a2b;
  --brand-rgb: 255, 106, 43;
  --brand-2: #ffb347;
  --brand-2-rgb: 255, 179, 71;
  --accent: #6ee7ff;
  --accent-rgb: 110, 231, 255;
  --brand-deep: #090d14;
  --surface: #0c121c;
  --surface-2: #121a26;
  --border: rgba(255, 173, 92, 0.28);
  --text: #f4f7fb;
  --muted: #98a7bb;
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: var(--ai-z);
  width: var(--ai-panel-w);
  max-width: calc(100vw - 32px);
  height: var(--ai-panel-h);
  max-height: calc(100vh - 120px);
  background:
    radial-gradient(circle at 14% 10%, rgba(var(--brand-rgb, 255, 106, 43),0.18) 0%, rgba(var(--brand-rgb, 255, 106, 43),0) 34%),
    radial-gradient(circle at 86% 8%, rgba(var(--accent-rgb, 110, 231, 255),0.10) 0%, rgba(var(--accent-rgb, 110, 231, 255),0) 28%),
    var(--ai-surface);
  border-radius: var(--ai-radius);
  box-shadow: 0 18px 58px rgba(0,0,0,0.46), 0 0 46px rgba(var(--brand-rgb, 255, 106, 43),0.12), inset 0 1px 0 rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1.5px solid var(--ai-border);
  transform-origin: bottom right;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), opacity 0.22s;
  isolation: isolate;
}
#aiPanel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0) 20%),
    repeating-linear-gradient(90deg, rgba(var(--accent-rgb, 110, 231, 255),0.06) 0 1px, transparent 1px 78px),
    repeating-linear-gradient(0deg, rgba(var(--brand-rgb, 255, 106, 43),0.05) 0 1px, transparent 1px 62px);
  opacity: 0.42;
  z-index: 0;
}

#aiPanel::after {
  content: '';
  position: absolute;
  inset: 1px;
  pointer-events: none;
  border: 1px solid rgba(var(--accent-rgb, 110, 231, 255),0.08);
  border-radius: calc(var(--ai-radius) - 2px);
  box-shadow: inset 0 0 40px rgba(var(--brand-rgb, 255, 106, 43),0.05);
  z-index: 0;
}
#aiPanel.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

#aiPanel.jarvis-opening {
  animation: jarvisPanelBoot 0.78s cubic-bezier(.16,.84,.24,1);
}

#aiPanel.jarvis-opening::before {
  opacity: 0.82;
  animation: jarvisBootGrid 0.78s ease-out;
}

#aiPanel.jarvis-opening::after {
  animation: jarvisBootFrame 0.78s ease-out;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#aiHeader {
  background:
    radial-gradient(circle at 14% 24%, rgba(var(--accent-rgb, 110, 231, 255),0.24) 0%, rgba(var(--accent-rgb, 110, 231, 255),0) 34%),
    radial-gradient(circle at 82% 18%, rgba(var(--brand-2-rgb, 255, 179, 71),0.18) 0%, rgba(var(--brand-2-rgb, 255, 179, 71),0) 32%),
    linear-gradient(130deg, #0b1019 0%, #34150f 38%, #ff6a2b 78%, #ffc163 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 190, 112, 0.34);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
#aiHeader::before {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb, 110, 231, 255),0.8), transparent);
  pointer-events: none;
}

#aiHeader::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 24%);
}

#aiPanel.jarvis-opening #aiHeader::after {
  background:
    linear-gradient(120deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 24%),
    linear-gradient(90deg, rgba(var(--accent-rgb, 110, 231, 255),0) 0%, rgba(var(--accent-rgb, 110, 231, 255),0.46) 48%, rgba(var(--accent-rgb, 110, 231, 255),0) 100%);
  animation: jarvisHeaderSweep 0.72s ease-out;
}
#aiHeaderAvatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb, 110, 231, 255),0.38) 0%, rgba(var(--brand-rgb, 255, 106, 43),0.78) 58%, rgba(0,0,0,0.22) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0;
  position: relative;
  box-shadow: inset 0 0 20px rgba(var(--brand-rgb, 255, 106, 43),0.34), 0 0 22px rgba(var(--accent-rgb, 110, 231, 255),0.18);
  transition: border-radius 0.45s ease, transform 0.45s ease;
}

#aiHeaderAvatar::before,
#aiHeaderAvatar::after {
  content: '';
  position: absolute;
  transition: all 0.45s ease;
}

#aiHeaderAvatar::before {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb, 110, 231, 255),0.58);
  box-shadow: 0 0 20px rgba(var(--accent-rgb, 110, 231, 255),0.72);
}

#aiHeaderAvatar::after {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.2px solid rgba(var(--brand-2-rgb, 255, 179, 71),0.72);
  animation: jarvisRingSpin 4.2s linear infinite;
}

#aiPanel.jarvis-human #aiHeaderAvatar {
  border-radius: 18px;
  transform: translateY(-1px);
  animation: jarvisHumanSway 2.8s ease-in-out infinite;
}

#aiPanel.jarvis-human #aiHeaderAvatar::before {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  top: 8px;
  background: rgba(var(--accent-rgb, 0, 188, 212),0.2);
  box-shadow: 0 0 12px rgba(var(--brand-2-rgb, 61, 120, 255),0.58);
}

#aiPanel.jarvis-human #aiHeaderAvatar::after {
  width: 16px;
  height: 13px;
  border-radius: 48% 48% 38% 38%;
  top: 19px;
  border: none;
  background: linear-gradient(180deg, rgba(var(--accent-rgb, 0, 188, 212),0.7), rgba(var(--brand-rgb, 31, 86, 255),0.9));
  animation: none;
}
#aiHeaderInfo { flex: 1; min-width: 0; }

#aiHoloCore {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

#aiHudCanvas {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.9;
  filter: saturate(1.15) blur(0.2px);
}

#aiHeaderActions {
  display: flex;
  gap: 6px;
  z-index: 2;
}

.ai-header-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(var(--brand-2-rgb, 255, 179, 71),0.36);
  background: rgba(10, 16, 24, 0.42);
  color: #eaf2ff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.ai-header-btn:hover {
  transform: translateY(-1px) scale(1.05);
  background: rgba(var(--brand-rgb, 255, 106, 43),0.24);
  border-color: rgba(var(--accent-rgb, 110, 231, 255),0.54);
}

.ai-header-btn.active {
  background: linear-gradient(135deg, rgba(var(--brand-rgb, 255, 106, 43),0.78), rgba(var(--brand-2-rgb, 255, 179, 71),0.58));
  border-color: rgba(var(--accent-rgb, 110, 231, 255),0.62);
  color: #fff;
}

.ai-header-btn.mobile-only {
  display: none;
}

#aiPanel.jarvis-command-center {
  left: var(--ai-command-gap);
  right: var(--ai-command-gap);
  bottom: var(--ai-command-gap);
  width: auto;
  max-width: none;
  height: calc(100dvh - (var(--ai-command-gap) * 2));
  max-height: calc(100dvh - (var(--ai-command-gap) * 2));
  border-radius: var(--ai-command-radius);
  transform-origin: center;
}

#aiPanel.jarvis-command-center.visible {
  transform: scale(1) translateY(0);
}

#aiPanel.jarvis-scene-alert {
  box-shadow: 0 0 0 1px rgba(255,110,110,0.42), 0 18px 60px rgba(255,70,70,0.22), 0 4px 16px rgba(0,0,0,0.38), inset 0 0 42px rgba(255, 90, 90, 0.16), 0 0 36px rgba(255, 120, 90, 0.18);
  animation: jarvisAlertPulse 0.8s ease-in-out infinite;
}

#aiPanel.jarvis-listening {
  box-shadow: 0 0 0 1px rgba(120, 225, 255, 0.34), 0 18px 60px rgba(34, 145, 255, 0.16), 0 4px 16px rgba(0,0,0,0.38), inset 0 0 44px rgba(66, 193, 255, 0.08), 0 0 42px rgba(255, 140, 74, 0.16);
}

#aiPanel.jarvis-scene-scan::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  top: -3px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb, 0, 188, 212),0), rgba(var(--brand-2-rgb, 61, 120, 255),0.9), rgba(var(--accent-rgb, 0, 188, 212),0));
  animation: jarvisScanSweep 1.8s linear infinite;
  pointer-events: none;
}

#aiPanel.jarvis-scene-wake {
  box-shadow: 0 0 0 1px rgba(132,218,255,0.5), 0 18px 60px rgba(64,162,255,0.26), 0 4px 16px rgba(0,0,0,0.38);
  animation: jarvisWakeFlash 0.34s ease-in-out 2;
}

#aiPanel.jarvis-scene-response {
  box-shadow: 0 0 0 1px rgba(132,218,255,0.42), 0 18px 60px rgba(64,162,255,0.20), 0 4px 16px rgba(0,0,0,0.38), inset 0 0 32px rgba(90, 205, 255, 0.08), 0 0 34px rgba(255, 166, 84, 0.14);
}

#aiPanel.jarvis-scene-combat {
  box-shadow: 0 0 0 1px rgba(255,132,92,0.46), 0 18px 60px rgba(255,98,48,0.24), 0 4px 16px rgba(0,0,0,0.4), inset 0 0 56px rgba(255, 102, 64, 0.18), 0 0 48px rgba(255, 167, 86, 0.22);
}

#aiPanel.jarvis-scene-combat::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 108, 61, 0) 0%, rgba(255, 108, 61, 0.08) 48%, rgba(255, 108, 61, 0) 100%);
  animation: jarvisCombatSweep 1.25s linear infinite;
}

#aiHeaderTitle {
  font-weight: 700;
  font-size: 1.02rem;
  color: #ffffff;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#aiHeaderSub {
  font-size: 0.78rem;
  opacity: 0.95;
  color: rgba(236, 244, 255, 0.95);
  display: flex;
  align-items: center;
  gap: 5px;
}
#aiStatusDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb, 0, 188, 212),0.85);
  animation: dotPulse 2.2s infinite;
}

#aiStatusDot.wake {
  background: var(--brand-2, #3d78ff);
  box-shadow: 0 0 10px rgba(var(--brand-2-rgb, 61, 120, 255),0.96), 0 0 22px rgba(var(--accent-rgb, 0, 188, 212),0.4);
  animation: jarvisWakeDot 0.46s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Onglets de mode */
#aiModeBar {
  display: flex;
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.ai-mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.72);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.ai-mode-btn.active {
  background: linear-gradient(135deg, rgba(var(--brand-rgb, 255, 106, 43),0.78), rgba(var(--brand-2-rgb, 255, 179, 71),0.48));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 0 14px rgba(var(--brand-rgb, 255, 106, 43),0.18);
}
.ai-mode-btn:hover:not(.active) { background: rgba(255,255,255,0.10); }

/* ── Messages ─────────────────────────────────────────────────────────────── */
#aiChatPane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

#aiMessages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#aiMessages::-webkit-scrollbar { width: 4px; }
#aiMessages::-webkit-scrollbar-track { background: transparent; }
#aiMessages::-webkit-scrollbar-thumb { background: var(--ai-border); border-radius: 4px; }

#aiScrollToBottomBtn {
  position: absolute;
  right: 14px;
  bottom: 122px;
  z-index: 2;
  border: none;
  border-radius: 999px;
  background: var(--ai-brand);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(var(--brand-rgb, 31, 86, 255),0.24);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#aiScrollToBottomBtn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ai-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: msgIn 0.22s cubic-bezier(.4,0,.2,1);
}

.ai-msg.ai-msg-expiring {
  opacity: 0.38;
  filter: saturate(0.7);
  transition: opacity 0.8s ease, filter 0.8s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-msg.bot { align-self: flex-start; }
.ai-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb, 0, 188, 212),0.28) 0%, rgba(var(--brand-rgb, 31, 86, 255),0.82) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ai-msg.user .ai-msg-avatar { background: var(--ai-user-bg); }

.ai-msg.bot .ai-msg-avatar {
  position: relative;
  font-size: 0;
  overflow: hidden;
}

.ai-msg.bot .ai-msg-avatar::before,
.ai-msg.bot .ai-msg-avatar::after {
  content: '';
  position: absolute;
}

.ai-msg.bot .ai-msg-avatar::before {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb, 0, 188, 212),0.24);
  top: 7px;
  left: 11px;
  animation: jarvisBlink 4.8s ease-in-out infinite;
}

.ai-msg.bot .ai-msg-avatar::after {
  width: 14px;
  height: 9px;
  border-radius: 42% 42% 58% 58%;
  background: rgba(var(--brand-rgb, 31, 86, 255),0.9);
  left: 9px;
  bottom: 6px;
}

.ai-msg-bubble {
  max-width: calc(100% - 50px);
  padding: 10px 14px;
  border-radius: var(--ai-radius-msg);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ai-text);
  background: linear-gradient(180deg, rgba(19, 28, 40, 0.96), rgba(13, 19, 29, 0.98));
  border: 1px solid rgba(var(--accent-rgb, 110, 231, 255),0.10);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  word-break: break-word;
}
.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, rgba(var(--brand-rgb, 255, 106, 43),0.96), rgba(var(--brand-2-rgb, 255, 179, 71),0.84));
  color: var(--ai-user-text);
  border-radius: var(--ai-radius-msg) var(--ai-radius-msg) 4px var(--ai-radius-msg);
  border-color: rgba(255,255,255,0.14);
}
.ai-msg.bot .ai-msg-bubble {
  border-radius: 4px var(--ai-radius-msg) var(--ai-radius-msg) var(--ai-radius-msg);
}

/* Horodatage */
.ai-msg-time {
  font-size: 0.68rem;
  color: var(--ai-text-muted);
  margin-top: 3px;
  display: block;
  text-align: right;
}
.ai-msg.bot .ai-msg-time { text-align: left; }

/* ── Typing indicator ─────────────────────────────────────────────────────── */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(19, 28, 40, 0.96), rgba(13, 19, 29, 0.98));
  border: 1px solid rgba(var(--accent-rgb, 110, 231, 255),0.10);
  border-radius: 4px var(--ai-radius-msg) var(--ai-radius-msg) var(--ai-radius-msg);
  width: fit-content;
}
.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-2, #ffb347);
  opacity: 0.5;
  animation: typing 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ── Quick Suggestions ────────────────────────────────────────────────────── */
#aiSuggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 4px;
  flex-shrink: 0;
}

/* ── Consent Gate ─────────────────────────────────────────────────────────── */
#aiConsentGate {
  display: none;
  margin: 8px 14px 10px;
  padding: 12px;
  border: 1px solid rgba(var(--brand-2-rgb, 61, 120, 255),0.45);
  border-radius: 12px;
  background: rgba(var(--brand-rgb, 31, 86, 255),0.08);
}

#aiConsentGate.visible {
  display: block;
}

.ai-consent-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ai-brand);
  margin-bottom: 6px;
}

.ai-consent-text {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.42;
  color: #2f4368;
}

.ai-consent-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ai-consent-btn {
  border: 1px solid rgba(var(--brand-2-rgb, 61, 120, 255),0.45);
  background: var(--ai-brand-light);
  color: var(--ai-brand-dark);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.74rem;
  cursor: pointer;
}

.ai-consent-btn.primary {
  background: var(--ai-brand);
  color: #fff;
  border-color: var(--ai-brand);
}

.ai-consent-link {
  color: var(--ai-brand);
  font-size: 0.74rem;
  text-decoration: underline;
}
.ai-suggestion {
  background: var(--ai-brand-light);
  color: var(--ai-brand);
  border: 1.5px solid rgba(var(--brand-2-rgb, 61, 120, 255),0.35);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.ai-suggestion:hover {
  background: rgba(var(--brand-rgb, 31, 86, 255),0.08);
  border-color: var(--ai-brand);
}

/* ── Input Zone ───────────────────────────────────────────────────────────── */
#aiInputZone {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 10px 12px 14px;
  border-top: 1.5px solid var(--ai-border);
  background: var(--ai-surface);
  flex-shrink: 0;
}

.ai-mic-notice {
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(var(--brand-rgb, 31, 86, 255),0.18);
  background: rgba(var(--brand-rgb, 31, 86, 255),0.08);
  color: #29415f;
  font-size: 0.76rem;
  line-height: 1.45;
}

.ai-mic-notice[data-tone="warning"] {
  border-color: rgba(255, 145, 77, 0.42);
  background: rgba(255, 164, 91, 0.14);
  color: #75461b;
}
#aiInputRow {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--ai-surface-2);
  border: 1.5px solid var(--ai-border);
  border-radius: 24px;
  padding: 6px 8px 6px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#aiInputRow:focus-within {
  border-color: var(--ai-brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb, 31, 86, 255),0.16);
}
#aiInput {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.88rem;
  color: var(--ai-text);
  resize: none;
  min-height: 22px;
  max-height: 90px;
  line-height: 1.5;
  font-family: inherit;
  padding: 2px 0;
}
#aiInput::placeholder { color: var(--ai-text-muted); }

/* Bouton voix */
#aiVoiceBtn {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  color: var(--ai-text-muted);
}
#aiVoiceBtn:hover { background: var(--ai-border); color: var(--ai-brand); }
#aiVoiceBtn.recording { color: #ff4757; animation: recordPulse 0.8s infinite; }
#aiVoiceBtn:disabled { opacity: 0.45; cursor: not-allowed; }
@keyframes recordPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
#aiVoiceBtn svg { width: 18px; height: 18px; }

#aiHandsFreeBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Bouton envoi */
#aiSendBtn {
  background: var(--ai-brand);
  border: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  color: #fff;
}
#aiSendBtn:hover { background: var(--ai-brand-dark); transform: scale(1.05); }
#aiSendBtn:active { transform: scale(0.95); }
#aiSendBtn:disabled { background: var(--ai-border); color: var(--ai-text-muted); cursor: not-allowed; }
#aiSendBtn svg { width: 16px; height: 16px; }

/* Crédits */
#aiFooterNote {
  font-size: 0.67rem;
  color: var(--ai-text-muted);
  text-align: center;
  padding-top: 6px;
  opacity: 0.7;
}

@keyframes jarvisDrift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(2px, -4px, 0); }
  50% { transform: translate3d(-1px, -6px, 0); }
  75% { transform: translate3d(-3px, -2px, 0); }
}

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

@keyframes jarvisBlink {
  0%, 44%, 46%, 100% { transform: scaleY(1); opacity: 1; }
  45% { transform: scaleY(0.18); opacity: 0.86; }
}

@keyframes jarvisHumanSway {
  0%, 100% { transform: translateY(-1px) rotate(-1.2deg); }
  50% { transform: translateY(0) rotate(1.4deg); }
}

@keyframes jarvisAlertPulse {
  0%, 100% { filter: saturate(1) brightness(1); }
  50% { filter: saturate(1.42) brightness(1.08); }
}

@keyframes jarvisScanSweep {
  0% { transform: translateY(0); }
  100% { transform: translateY(calc(var(--ai-panel-h) - 80px)); }
}

@keyframes jarvisWakeDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.36); opacity: 0.68; }
}

@keyframes jarvisWakeFlash {
  0% { filter: saturate(1.45) brightness(1.1); }
  100% { filter: saturate(1) brightness(1); }
}

@keyframes jarvisCombatSweep {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

@keyframes jarvisListenPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.04); filter: brightness(1.12); }
}

@keyframes jarvisCoreIgnition {
  0% {
    transform: scale(0.88);
    box-shadow: 0 0 0 rgba(var(--brand-rgb, 255, 106, 43),0), 0 0 0 rgba(var(--accent-rgb, 110, 231, 255),0);
    filter: brightness(0.9);
  }
  45% {
    transform: scale(1.12);
    box-shadow: 0 0 0 8px rgba(var(--brand-2-rgb, 255, 179, 71),0.16), 0 0 42px rgba(var(--accent-rgb, 110, 231, 255),0.44);
    filter: brightness(1.16);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 10px 38px rgba(var(--brand-rgb, 255, 106, 43),0.34), 0 0 28px rgba(var(--accent-rgb, 110, 231, 255),0.18);
    filter: brightness(1);
  }
}

@keyframes jarvisPanelBoot {
  0% {
    transform: scale(0.72) translateY(42px) perspective(1200px) rotateX(13deg);
    opacity: 0;
    filter: brightness(0.72) saturate(0.82);
  }
  38% {
    transform: scale(1.02) translateY(-4px) perspective(1200px) rotateX(0deg);
    opacity: 1;
    filter: brightness(1.14) saturate(1.18);
  }
  100% {
    transform: scale(1) translateY(0) perspective(1200px) rotateX(0deg);
    opacity: 1;
    filter: brightness(1) saturate(1);
  }
}

@keyframes jarvisBootGrid {
  0% { opacity: 0.95; filter: brightness(1.3); }
  100% { opacity: 0.42; filter: brightness(1); }
}

@keyframes jarvisBootFrame {
  0% {
    box-shadow: inset 0 0 0 rgba(var(--brand-rgb, 255, 106, 43),0), 0 0 0 rgba(var(--accent-rgb, 110, 231, 255),0);
    border-color: rgba(var(--accent-rgb, 110, 231, 255),0.42);
  }
  50% {
    box-shadow: inset 0 0 48px rgba(var(--brand-rgb, 255, 106, 43),0.14), 0 0 30px rgba(var(--accent-rgb, 110, 231, 255),0.18);
    border-color: rgba(var(--brand-2-rgb, 255, 179, 71),0.46);
  }
  100% {
    box-shadow: inset 0 0 40px rgba(var(--brand-rgb, 255, 106, 43),0.05);
    border-color: rgba(var(--accent-rgb, 110, 231, 255),0.08);
  }
}

@keyframes jarvisHeaderSweep {
  0% {
    opacity: 0;
    transform: translateX(-18%);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0.3;
    transform: translateX(18%);
  }
}

/* ── Mode Diagnostic ─────────────────────────────────────────────────────── */
#aiDiagPane {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-diag-result {
  background: var(--ai-surface-2);
  border: 1.5px solid var(--ai-border);
  border-radius: 12px;
  padding: 14px;
  font-size: 0.86rem;
}
.ai-diag-title {
  font-weight: 700;
  color: var(--ai-brand);
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.ai-diag-urgence {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.ai-diag-urgence.faible  { background: #e8fff0; color: #27ae60; }
.ai-diag-urgence.moyen   { background: #fff8e8; color: #e67e22; }
.ai-diag-urgence.elevé   { background: #ffecec; color: #e74c3c; }
.ai-diag-steps { list-style: none; padding: 0; margin: 6px 0 0; }
.ai-diag-steps li {
  padding: 5px 0 5px 20px;
  position: relative;
  border-bottom: 1px solid var(--ai-border);
  color: var(--ai-text);
}
.ai-diag-steps li:last-child { border-bottom: none; }
.ai-diag-steps li::before {
  content: counter(step);
  counter-increment: step;
  position: absolute;
  left: 0;
  top: 5px;
  width: 16px;
  height: 16px;
  background: var(--ai-brand);
  color: #fff;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.ai-diag-steps { counter-reset: step; }

/* ── Mode Config PC ──────────────────────────────────────────────────────── */
#aiConfigPane {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-config-card {
  background: var(--ai-surface-2);
  border: 1.5px solid var(--ai-border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.86rem;
}
.ai-config-card-title {
  font-weight: 700;
  color: var(--ai-brand);
  font-size: 0.95rem;
  margin-bottom: 6px;
}
.ai-config-component {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--ai-border);
  gap: 8px;
}
.ai-config-component:last-child { border-bottom: none; }
.ai-config-comp-type {
  font-size: 0.70rem;
  font-weight: 700;
  color: var(--ai-text-muted);
  min-width: 80px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ai-config-comp-model { flex: 1; color: var(--ai-text); }
.ai-config-comp-price {
  color: var(--ai-brand);
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
}
.ai-config-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.95rem;
  padding-top: 10px;
  border-top: 2px solid var(--ai-brand);
  color: var(--ai-brand);
  margin-top: 6px;
}
.ai-perf-bar-wrap {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-perf-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}
.ai-perf-label { width: 90px; color: var(--ai-text-muted); font-weight: 600; }
.ai-perf-bar-bg {
  flex: 1;
  height: 7px;
  background: var(--ai-border);
  border-radius: 4px;
  overflow: hidden;
}
.ai-perf-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--ai-brand) 0%, var(--brand-2, #5b82ff) 100%);
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
}
.ai-perf-val { font-weight: 700; color: var(--ai-brand); width: 34px; text-align: right; }

/* ── Recommandation produit inline ──────────────────────────────────────── */
.ai-product-card-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1.5px solid var(--ai-border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 6px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
}
.ai-product-card-inline:hover {
  border-color: var(--ai-brand);
  box-shadow: 0 2px 10px rgba(var(--brand-rgb, 31, 86, 255),0.12);
}
.ai-product-card-inline img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}
.ai-product-card-inline-info { flex: 1; min-width: 0; }
.ai-product-card-inline-name {
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ai-text);
}
.ai-product-card-inline-sub {
  font-size: 0.72rem;
  color: var(--ai-text-muted);
  margin-top: 1px;
}
.ai-product-card-inline-price {
  color: var(--ai-brand);
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
}

/* ── Inputs panes ────────────────────────────────────────────────────────── */
.ai-pane-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
}
.ai-pane-form label {
  font-size: 0.80rem;
  font-weight: 600;
  color: var(--ai-text-muted);
  margin-bottom: 3px;
  display: block;
}
.ai-pane-form input,
.ai-pane-form select,
.ai-pane-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--ai-border);
  border-radius: 10px;
  font-size: 0.86rem;
  font-family: inherit;
  background: var(--ai-surface-2);
  color: var(--ai-text);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.ai-pane-form input:focus,
.ai-pane-form select:focus,
.ai-pane-form textarea:focus { border-color: var(--ai-brand); }
.ai-pane-form textarea { resize: vertical; min-height: 60px; }
.ai-pane-btn {
  background: var(--ai-brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 0;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.ai-pane-btn:hover { background: var(--ai-brand-dark); }
.ai-pane-btn:disabled { background: var(--ai-border); color: var(--ai-text-muted); cursor: not-allowed; }

@media (max-width: 900px) {
  #aiPanel {
    left: 12px;
    right: 12px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    height: min(72dvh, 640px);
    max-height: calc(100dvh - 112px);
  }

  #aiPanel.jarvis-command-center {
    left: var(--ai-command-gap-mobile);
    right: var(--ai-command-gap-mobile);
    bottom: calc(var(--ai-command-gap-mobile) + env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - (var(--ai-command-gap-mobile) * 2) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - (var(--ai-command-gap-mobile) * 2) - env(safe-area-inset-bottom, 0px));
    border-radius: var(--ai-command-radius-mobile);
  }

  #aiFloatingBtn {
    right: var(--ai-fab-right-mobile);
    bottom: calc(var(--ai-fab-bottom-mobile) + env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
  }

  #aiHeaderActions {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 124px;
  }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 440px) {
  #aiVoiceBtn,
  #aiSendBtn,
  .ai-header-btn {
    min-width: 42px;
    min-height: 42px;
  }

  #aiPanel {
    right: 8px;
    bottom: 92px;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: calc(100dvh - 110px);
    max-height: calc(100dvh - 110px);
    border-radius: 14px;
  }
  #aiFloatingBtn {
    right: 16px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  #aiPanel.jarvis-command-center {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - 16px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 16px - env(safe-area-inset-bottom, 0px));
    border-radius: 14px;
  }

  #aiHeaderActions {
    max-width: 98px;
  }

  .ai-header-btn.mobile-only {
    display: inline-flex;
  }
}
