/* Assistant IA EBY : mascotte (bouton d'ouverture) + panneau de chat.
   Couleurs de la marque : orange EBY, surfaces creme / anthracite. */
.eby-assistant{
  --as-accent:#F59E0A; --as-accent-ink:#b45c00; --as-accent-soft:rgba(245,158,10,0.12);
  --as-bg:#fcfaf7; --as-surface:#f3eee8; --as-ink:#141414; --as-muted:#7a6d63; --as-line:rgba(20,20,20,0.09);
  --as-danger:#c94f4f; --as-shadow:0 24px 60px rgba(30,20,10,0.22), 0 2px 8px rgba(30,20,10,0.08);
  font-family:"Manrope","Inter Tight",system-ui,-apple-system,"Segoe UI",sans-serif;
  color:var(--as-ink);
}
html.dark .eby-assistant{
  --as-accent-ink:#fbbf5c; --as-accent-soft:rgba(245,158,10,0.16);
  --as-bg:#1c1c1c; --as-surface:#262626; --as-ink:#f1f5f9; --as-muted:#9ca3af; --as-line:rgba(255,255,255,0.1);
  --as-danger:#e07070; --as-shadow:0 24px 60px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);
}
.eby-assistant[hidden]{ display:none !important; }
.eby-assistant *, .eby-assistant *::before, .eby-assistant *::after{ box-sizing:border-box; }

/* ----- Mascotte : bouton d'ouverture ----- */
.eby-as-launcher{
  position:fixed; right:18px; bottom:14px; z-index:45;
  width:84px; height:84px; padding:0; border:none; background:none; cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.eby-as-launcher:focus-visible{ outline:3px solid var(--as-accent); outline-offset:2px; border-radius:20px; }
.eby-as-launcher-fallback{
  position:absolute; inset:14px; border-radius:16px;
  background:linear-gradient(160deg,#FF5C00,#FACD08);
}
.eby-as-teaser{
  position:fixed; right:108px; bottom:44px; z-index:45;
  display:flex; align-items:center; gap:8px; max-width:240px;
  padding:9px 10px 9px 14px; border-radius:14px 14px 4px 14px;
  background:var(--as-bg); color:var(--as-ink); box-shadow:var(--as-shadow);
  font-size:13px; font-weight:650; line-height:1.35; cursor:pointer;
  animation:eby-as-pop .35s ease both;
}
.eby-as-teaser[hidden]{ display:none; }
.eby-as-teaser-close{
  flex:0 0 auto; width:22px; height:22px; border:none; border-radius:50%; cursor:pointer;
  background:transparent; color:var(--as-muted); font-size:15px; line-height:1;
}
.eby-as-teaser-close:hover{ background:var(--as-surface); color:var(--as-ink); }

/* ----- Panneau ----- */
.eby-as-panel{
  position:fixed; right:18px; bottom:104px; z-index:46;
  width:380px; height:min(600px, calc(100vh - 128px));
  display:flex; flex-direction:column; overflow:hidden;
  background:var(--as-bg); border:1px solid var(--as-line); border-radius:18px; box-shadow:var(--as-shadow);
  animation:eby-as-pop .22s ease both; transform-origin:bottom right;
}
.eby-as-panel[hidden]{ display:none; }
@keyframes eby-as-pop{ from{ opacity:0; transform:translateY(8px) scale(.98); } to{ opacity:1; transform:none; } }

.eby-as-head{
  flex:0 0 auto; display:flex; align-items:center; gap:10px;
  padding:12px 10px 12px 16px; border-bottom:1px solid var(--as-line);
}
.eby-as-head-text{ flex:1 1 auto; min-width:0; }
.eby-as-name{ font-size:15px; font-weight:800; letter-spacing:-0.01em; }
.eby-as-status{ display:flex; align-items:center; gap:6px; font-size:11.5px; font-weight:650; color:var(--as-muted); }
.eby-as-status::before{ content:""; width:7px; height:7px; border-radius:50%; background:#009460; }
.eby-as-panel.is-busy .eby-as-status::before{ background:var(--as-accent); animation:eby-as-blink 1s ease-in-out infinite; }
@keyframes eby-as-blink{ 50%{ opacity:.3; } }
.eby-as-icon{
  flex:0 0 auto; width:32px; height:32px; display:inline-flex; align-items:center; justify-content:center;
  border:none; border-radius:9px; background:transparent; color:var(--as-muted); cursor:pointer; font-size:16px;
}
.eby-as-icon:hover{ background:var(--as-surface); color:var(--as-ink); }
.eby-as-icon:focus-visible, .eby-as-chip:focus-visible, .eby-as-btn:focus-visible, .eby-as-send:focus-visible{ outline:2px solid var(--as-accent); outline-offset:1px; }
.eby-as-icon svg{ width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

.eby-as-body{
  flex:1 1 auto; overflow-y:auto; overscroll-behavior:contain;
  display:flex; flex-direction:column; gap:10px; padding:16px 14px 10px;
}
.eby-as-msg{
  max-width:88%; padding:9px 13px; font-size:13.5px; line-height:1.5; word-wrap:break-word; overflow-wrap:anywhere;
}
.eby-as-msg.is-user{
  align-self:flex-end; border-radius:16px 16px 4px 16px;
  background:var(--as-accent); color:#fff; font-weight:600; white-space:pre-wrap;
}
.eby-as-msg.is-bot{
  align-self:flex-start; border-radius:16px 16px 16px 4px;
  background:var(--as-surface); color:var(--as-ink);
}
.eby-as-msg.is-error{ background:rgba(201,79,79,0.12); color:var(--as-danger); font-weight:650; }
.eby-as-msg p{ margin:0 0 .55em; }
.eby-as-msg p:last-child, .eby-as-msg ul:last-child, .eby-as-msg ol:last-child{ margin-bottom:0; }
.eby-as-msg ul, .eby-as-msg ol{ margin:0 0 .55em; padding-left:1.2em; }
.eby-as-msg li{ margin:.15em 0; }
.eby-as-msg strong{ font-weight:800; }
.eby-as-msg a{ color:var(--as-accent-ink); font-weight:700; text-decoration:underline; text-underline-offset:2px; }
.eby-as-msg code{ padding:1px 5px; border-radius:5px; background:rgba(20,20,20,0.07); font-family:ui-monospace,Menlo,Consolas,monospace; font-size:.92em; }
html.dark .eby-as-msg code{ background:rgba(255,255,255,0.08); }
.eby-as-cursor::after{ content:"▍"; margin-left:1px; color:var(--as-accent); animation:eby-as-blink .9s steps(2) infinite; }

.eby-as-tool{
  align-self:flex-start; display:flex; align-items:center; gap:8px;
  font-size:12px; font-weight:650; color:var(--as-muted);
}
.eby-as-dots{ display:inline-flex; gap:3px; }
.eby-as-dots i{ width:5px; height:5px; border-radius:50%; background:var(--as-accent); animation:eby-as-bounce 1.1s ease-in-out infinite; }
.eby-as-dots i:nth-child(2){ animation-delay:.15s; }
.eby-as-dots i:nth-child(3){ animation-delay:.3s; }
@keyframes eby-as-bounce{ 0%,80%,100%{ transform:translateY(0); opacity:.45; } 40%{ transform:translateY(-4px); opacity:1; } }

.eby-as-chips{ display:flex; flex-wrap:wrap; gap:6px; margin-top:2px; }
.eby-as-chip{
  padding:7px 11px; border:1px solid var(--as-line); border-radius:999px; cursor:pointer;
  background:var(--as-bg); color:var(--as-ink); font:inherit; font-size:12.5px; font-weight:650; text-align:left;
}
.eby-as-chip:hover{ border-color:var(--as-accent); background:var(--as-accent-soft); }

.eby-as-card{
  align-self:stretch; padding:12px 14px; border-radius:14px;
  border:1px solid rgba(245,158,10,0.45); background:var(--as-accent-soft);
}
.eby-as-card.is-danger{ border-color:rgba(201,79,79,0.45); background:rgba(201,79,79,0.08); }
.eby-as-card-title{ font-size:13.5px; font-weight:800; margin-bottom:6px; }
.eby-as-card ul{ margin:0 0 10px; padding-left:1.1em; font-size:13px; line-height:1.5; }
.eby-as-card-actions{ display:flex; gap:8px; }
.eby-as-card.is-done .eby-as-card-actions{ display:none; }
.eby-as-card-note{ font-size:12.5px; font-weight:700; color:var(--as-muted); }
.eby-as-btn{
  flex:1 1 0; height:34px; border-radius:10px; cursor:pointer; font:inherit; font-size:13px; font-weight:750;
  border:1px solid var(--as-line); background:var(--as-bg); color:var(--as-ink);
}
.eby-as-btn.is-primary{ border-color:transparent; background:var(--as-accent); color:#fff; }
.eby-as-card.is-danger .eby-as-btn.is-primary{ background:var(--as-danger); }
.eby-as-btn:disabled{ opacity:.55; cursor:progress; }

.eby-as-foot{ flex:0 0 auto; padding:10px 12px 10px; border-top:1px solid var(--as-line); }
.eby-as-form{ display:flex; align-items:flex-end; gap:8px; }
.eby-as-input{
  flex:1 1 auto; min-height:40px; max-height:120px; resize:none; overflow-y:auto;
  padding:10px 12px; border:1px solid var(--as-line); border-radius:12px;
  background:var(--as-surface); color:var(--as-ink); font:inherit; font-size:13.5px; line-height:1.4;
}
.eby-as-input:focus{ outline:none; border-color:var(--as-accent); box-shadow:0 0 0 3px var(--as-accent-soft); }
.eby-as-input::placeholder{ color:var(--as-muted); }
.eby-as-send{
  flex:0 0 auto; width:40px; height:40px; border:none; border-radius:12px; cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center;
  background:var(--as-accent); color:#fff;
}
.eby-as-send:disabled{ opacity:.45; cursor:default; }
.eby-as-send svg{ width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.eby-as-meta{ display:flex; justify-content:space-between; gap:10px; margin-top:7px; font-size:11px; font-weight:600; color:var(--as-muted); }
.eby-as-meta span:last-child{ text-align:right; }

/* ----- Ancre dans une colonne de la page (/analyse) : memes surfaces,
   filets et typographie que les panneaux du graphique ----- */
.eby-as-avatar{ display:none; }
.eby-assistant.is-docked{
  --as-bg:transparent; --as-surface:rgba(20,20,20,0.05); --as-line:rgba(20,20,20,0.08); --as-field:#f7f4f1; --as-hover:rgba(20,20,20,0.07);
  flex:1 1 auto; min-width:0; min-height:0; display:flex; flex-direction:column;
}
html.dark .eby-assistant.is-docked{
  --as-surface:rgba(255,255,255,0.06); --as-line:rgba(255,255,255,0.09); --as-field:#1a1a1a; --as-hover:rgba(255,255,255,0.1);
}
.eby-assistant.is-docked .eby-as-launcher,
.eby-assistant.is-docked .eby-as-teaser{ display:none !important; }
.eby-assistant.is-docked .eby-as-panel{
  position:static; z-index:auto; width:auto; height:auto; flex:1 1 auto; min-height:0;
  border:none; border-radius:0; box-shadow:none; background:transparent; animation:none;
}
.eby-assistant.is-docked .eby-as-head{ gap:10px; min-height:58px; padding:8px 8px 8px 12px; }
.eby-assistant.is-docked .eby-as-avatar{ display:block; flex:0 0 38px; width:38px; height:38px; }
.eby-assistant.is-docked .eby-as-name{ font-family:"Inter Tight",system-ui,sans-serif; font-size:14px; font-weight:750; letter-spacing:0; }
.eby-assistant.is-docked .eby-as-status{ font-size:11px; font-weight:700; }
.eby-assistant.is-docked .eby-as-icon{ width:28px; height:28px; border-radius:8px; }
.eby-assistant.is-docked .eby-as-icon:hover{ background:var(--as-hover); }
.eby-assistant.is-docked .eby-as-icon svg{ width:15px; height:15px; }
.eby-assistant.is-docked .eby-as-body{ gap:12px; padding:14px 14px 10px; scrollbar-width:thin; }
.eby-assistant.is-docked .eby-as-msg{ font-size:13px; line-height:1.55; }
/* Reponses en pleine largeur (colonne etroite), questions en bulle orange. */
.eby-assistant.is-docked .eby-as-msg.is-bot{ align-self:stretch; max-width:none; padding:0; border-radius:0; background:none; }
.eby-assistant.is-docked .eby-as-msg.is-error{ padding:9px 12px; border-radius:10px; background:rgba(201,79,79,0.1); }
.eby-assistant.is-docked .eby-as-msg.is-user{ max-width:92%; padding:8px 12px; border-radius:12px 12px 4px 12px; }
.eby-assistant.is-docked .eby-as-card{ border-radius:10px; }
.eby-assistant.is-docked .eby-as-chips{ flex-direction:column; gap:3px; margin-top:0; }
.eby-assistant.is-docked .eby-as-chip{
  display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%;
  padding:8px 10px; border:none; border-radius:8px; background:transparent; font-size:12.5px; font-weight:650;
}
.eby-assistant.is-docked .eby-as-chip::after{ content:"→"; flex:none; color:var(--as-muted); font-weight:700; }
.eby-assistant.is-docked .eby-as-chip:hover{ background:var(--as-hover); }
.eby-assistant.is-docked .eby-as-chip:hover::after{ color:var(--as-accent-ink); }
.eby-assistant.is-docked .eby-as-foot{ padding:10px 12px 12px; }
.eby-assistant.is-docked .eby-as-input{ border-radius:10px; background:var(--as-field); font-size:13px; }
.eby-assistant.is-docked .eby-as-send{ border-radius:10px; }
.eby-assistant.is-docked .eby-as-meta{ flex-direction:column; gap:2px; font-size:10.5px; }
.eby-assistant.is-docked .eby-as-meta span:last-child{ text-align:left; }

/* Accueil de la colonne : lancer l'analyse en un clic. */
.eby-as-hero{ display:flex; flex-direction:column; padding:4px 2px 0; }
.eby-as-hero-title{
  font-family:"Inter Tight",system-ui,sans-serif; font-size:17px; font-weight:780; letter-spacing:-0.012em;
  line-height:1.25; text-wrap:balance;
}
.eby-as-hero p{ margin:6px 0 14px; color:var(--as-muted); font-size:12.5px; font-weight:600; line-height:1.5; }
.eby-as-hero-cta{
  flex:none; display:inline-flex; align-items:center; justify-content:center; gap:8px;
  width:100%; height:38px; border-radius:10px;
}
.eby-as-hero-cta svg{ width:16px; height:16px; fill:currentColor; stroke:none; }
.eby-as-hero-cta:hover{ background:#e08e05; }
.eby-as-hero-label{
  margin:18px 0 0; padding-top:14px; border-top:1px solid var(--as-line);
  font-size:10.5px; font-weight:800; letter-spacing:.07em; text-transform:uppercase; color:#9a8f86;
}
html.dark .eby-as-hero-label{ color:#7d828b; }

/* Telephone : chat plein ecran. L'application elle-meme est reservee aux
   ecrans de 768 px et plus : sur ses pages, le widget suit la meme regle. */
@media (max-width:640px){
  .eby-as-panel{ inset:0; width:auto; height:auto; border-radius:0; border:none; }
  .eby-assistant.is-open .eby-as-launcher, .eby-assistant.is-open .eby-as-teaser{ display:none; }
  .eby-as-teaser{ right:100px; bottom:36px; max-width:180px; }
}
@media (max-width:767px){
  .eby-assistant[data-context="app"]{ display:none !important; }
}
@media (prefers-reduced-motion:reduce){
  .eby-as-panel, .eby-as-teaser{ animation:none; }
  .eby-as-dots i, .eby-as-cursor::after, .eby-as-panel.is-busy .eby-as-status::before{ animation:none; }
}
@media print{ .eby-assistant{ display:none !important; } }
