/* Assistant Devis IA — widget. Thème surchargé à l'exécution depuis le parcours JSON (clé "theme"). */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/poppins-400.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/poppins-500.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/poppins-600.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/poppins-700.woff2) format('woff2'); }
@font-face { font-family: 'Poppins Fallback'; src: local('Arial'), local('ArialMT'), local('Liberation Sans'), local('Helvetica'); size-adjust: 112.16%; ascent-override: 93.62%; descent-override: 31.21%; line-gap-override: 8.92%; }
:root {
  --aida-bg: #0B1320;
  --aida-surface: #1F2937;
  --aida-border: #374151;
  --aida-text: #FFFFFF;
  --aida-muted: #E5E7EB;
  --aida-accent: #0D6EFD;
  --aida-accent-text: #6EA8FE; /* accent éclairci pour du texte sur fond sombre (contraste 7,7:1) */
  --aida-error: #FCA5A5;
  --aida-font: 'Poppins', 'Poppins Fallback', system-ui, sans-serif;
  --aida-radius: 16px;
}

/* ---------- Bouton flottant ---------- */
.aida-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 999;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 14px 12px 18px; border-radius: 999px;
  background: var(--aida-accent); color: #fff !important; text-decoration: none;
  font: 600 15px/1 var(--aida-font);
  box-shadow: 0 10px 30px rgba(11, 19, 32, .28);
  transition: transform .18s ease, box-shadow .18s ease;
}
.aida-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(11, 19, 32, .34); color: #fff; }
.aida-launcher:focus-visible { outline: 3px solid var(--aida-bg); outline-offset: 3px; box-shadow: 0 0 0 6px var(--aida-accent-text); }
.aida-launcher-badge {
  padding: 4px 7px; border-radius: 6px; background: #fff; color: var(--aida-accent);
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
}
.aida-is-open .aida-launcher { display: none; }

/* ---------- Conteneur ---------- */
.aida-root {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-end; justify-content: flex-end;
  background: rgba(11, 19, 32, .35);
  opacity: 0; transition: opacity .18s ease;
  font-family: var(--aida-font);
}
.aida-root[hidden] { display: none; }
.aida-root.is-visible { opacity: 1; }

.aida-panel {
  position: relative; display: flex; flex-direction: column;
  width: 400px; height: min(680px, calc(100vh - 48px)); margin: 24px;
  background: var(--aida-bg); color: var(--aida-text);
  border: 1px solid var(--aida-border); border-radius: var(--aida-radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  overflow: hidden;
  transform: translateY(12px); transition: transform .18s ease;
}
.aida-root.is-visible .aida-panel { transform: none; }
.aida-panel *, .aida-panel *::before, .aida-panel *::after { box-sizing: border-box; }
.aida-panel button, .aida-panel input, .aida-panel textarea { font-family: inherit; }
.aida-panel :focus-visible { outline: 2px solid var(--aida-accent-text); outline-offset: 2px; }

/* ---------- En-tête ---------- */
.aida-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px 14px 16px; border-bottom: 1px solid var(--aida-border);
}
.aida-avatar {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: rgba(13, 110, 253, .16); color: var(--aida-accent-text);
}
.aida-head-text { flex: 1; min-width: 0; }
.aida-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--aida-text); letter-spacing: 0; font-family: inherit; }
.aida-subtitle { margin: 2px 0 0; font-size: 12px; color: var(--aida-muted); }
.aida-badge {
  flex: none; padding: 4px 8px; border-radius: 6px;
  background: var(--aida-accent); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .06em;
}
.aida-close {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--aida-border); border-radius: 12px; background: transparent; color: var(--aida-text); cursor: pointer;
}
.aida-close:hover { background: var(--aida-surface); }

/* ---------- Conversation ---------- */
.aida-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
}
.aida-msg {
  max-width: 88%; padding: 10px 14px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.5; animation: aida-in .18s ease both;
}
.aida-msg p { margin: 0; white-space: pre-line; }
.aida-msg-bot { align-self: flex-start; background: var(--aida-surface); border-bottom-left-radius: 4px; }
.aida-msg-user { align-self: flex-end; background: var(--aida-accent); color: #fff; border-bottom-right-radius: 4px; }
@keyframes aida-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.aida-typing { display: flex; gap: 10px; align-items: center; padding: 12px 16px; }
.aida-dots { display: inline-flex; gap: 5px; }
.aida-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--aida-muted); opacity: .5; animation: aida-dot 1s infinite ease-in-out; }
.aida-dots span:nth-child(2) { animation-delay: .15s; }
.aida-dots span:nth-child(3) { animation-delay: .3s; }
.aida-typing-label { font-size: 13px; color: var(--aida-muted); }
@keyframes aida-dot { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ---------- Estimation indicative ---------- */
.aida-msg-card { max-width: 100%; width: 100%; padding: 0; background: none; }
.aida-estimate { padding: 14px 16px; border: 1px solid var(--aida-accent); border-radius: 14px; background: rgba(13, 110, 253, .12); }
.aida-estimate p { margin: 0; }
.aida-estimate-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--aida-accent-text); }
.aida-estimate-amount { margin-top: 6px !important; font-size: 18px; font-weight: 600; line-height: 1.35; color: var(--aida-text); }
.aida-estimate-detail { margin-top: 4px !important; font-size: 14px; color: var(--aida-muted); }
.aida-estimate-mention { margin-top: 8px !important; font-size: 12px; color: var(--aida-muted); opacity: .85; }

/* ---------- Récapitulatif ---------- */
.aida-recap { max-width: 100%; }
.aida-recap > p { margin-bottom: 10px; }
.aida-recap dl { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.aida-recap-item { padding-top: 10px; border-top: 1px solid var(--aida-border); }
.aida-recap dt { font-size: 12px; color: var(--aida-muted); margin-bottom: 2px; }
.aida-recap dd { margin: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.aida-recap-value { white-space: pre-line; overflow-wrap: anywhere; }
.aida-recap-edit {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px; border: 0; background: none; color: var(--aida-accent-text);
  font-size: 13px; text-decoration: underline; cursor: pointer;
}

/* ---------- Zone de saisie ---------- */
.aida-input { padding: 12px 16px; border-top: 1px solid var(--aida-border); max-height: 55%; overflow-y: auto; }
.aida-input:empty { display: none; }
.aida-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.aida-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.aida-choice {
  padding: 9px 14px; border: 1px solid var(--aida-border); border-radius: 999px;
  background: transparent; color: var(--aida-text); font-size: 14px; line-height: 1.2; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.aida-choice:hover { border-color: var(--aida-accent-text); background: rgba(13, 110, 253, .14); }
.aida-choice.is-selected { background: var(--aida-accent); border-color: var(--aida-accent); }
.aida-choice-other { border-style: dashed; }

.aida-row { display: flex; gap: 8px; align-items: flex-end; }
.aida-field {
  flex: 1; width: 100%; min-width: 0; padding: 11px 14px;
  border: 1px solid var(--aida-border); border-radius: 12px;
  background: var(--aida-surface); color: var(--aida-text);
  font-size: 16px; /* 16px : évite le zoom automatique d'iOS */
  line-height: 1.4; resize: vertical;
}
.aida-field::placeholder { color: #9CA3AF; }
.aida-field:focus { border-color: var(--aida-accent-text); }
.aida-field[aria-invalid="true"] { border-color: var(--aida-error); }
textarea.aida-field { min-height: 96px; max-height: 220px; }
.aida-send {
  flex: none; display: grid; place-items: center; width: 46px; height: 46px;
  border: 0; border-radius: 12px; background: var(--aida-accent); color: #fff; cursor: pointer;
}
.aida-labelled label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--aida-muted); }
.aida-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; color: var(--aida-muted); cursor: pointer; }
.aida-consent input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--aida-accent); }
.aida-consent a, .aida-links a { color: var(--aida-accent-text); }

.aida-primary, .aida-secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 13px 16px; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.aida-primary { border: 0; background: var(--aida-accent); color: #fff; }
.aida-primary:hover { filter: brightness(1.08); }
.aida-primary:disabled { opacity: .6; cursor: default; }
.aida-secondary { margin-top: 8px; border: 1px solid var(--aida-border); background: transparent; color: var(--aida-text) !important; }
.aida-secondary:first-child { margin-top: 0; }
.aida-link-btn { align-self: flex-start; padding: 2px 0; border: 0; background: none; color: var(--aida-accent-text); font-size: 13px; text-decoration: underline; cursor: pointer; }
.aida-hint { margin: 0; font-size: 12px; color: var(--aida-muted); opacity: .8; }
.aida-error { margin: 0; font-size: 13px; color: var(--aida-error); }

/* ---------- Questions libres ---------- */
.aida-composer { margin: 0; padding: 10px 16px 8px; border-top: 1px solid var(--aida-border); }
.aida-composer[hidden] { display: none; }
.aida-composer-meta { margin: 4px 0 0; display: flex; justify-content: space-between; align-items: center; min-height: 0; }
.aida-composer-meta:has(.aida-composer-back[hidden]):has(.aida-counter:empty) { display: none; }
.aida-counter { margin-left: auto; font-size: 12px; color: var(--aida-muted); }
.aida-input + .aida-composer { border-top: 0; padding-top: 0; }
.aida-input[hidden] + .aida-composer { border-top: 1px solid var(--aida-border); padding-top: 10px; }
.aida-input[hidden] { display: none; }
.aida-form-extras { margin: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; }
.aida-ask { display: inline-flex; align-items: center; gap: 6px; }
.aida-choice svg { vertical-align: -3px; margin-right: 6px; }
.aida-send:disabled, .aida-field:disabled { opacity: .6; cursor: default; }

/* ---------- Mode démo (captures du carrousel) ---------- */
.aida-demo-banner { margin: 0; padding: 6px 12px; background: #FACC15; color: #111827; font-size: 12px; font-weight: 600; text-align: center; }
/* ?frame=1080 : panneau centré et agrandi, net en 1080 × 1350 */
.aida-frame { align-items: center; justify-content: center; }
.aida-frame .aida-panel { width: 560px; height: 900px; margin: 0; zoom: 1.35; }

/* ---------- Pied : mentions ---------- */
.aida-foot { padding: 8px 16px 12px; border-top: 1px solid var(--aida-border); }
.aida-disclaimer { margin: 0; font-size: 12px; color: var(--aida-muted); }
.aida-links { margin: 4px 0 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12.5px; }
.aida-restart { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--aida-muted); font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.aida-restart[hidden] { display: none; }

.aida-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.aida-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Mobile : plein écran ---------- */
@media (max-width: 600px) {
  .aida-launcher { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); padding: 11px 12px 11px 16px; font-size: 14px; }
  .aida-root { background: var(--aida-bg); }
  .aida-panel { width: 100%; height: 100%; height: 100dvh; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .aida-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  html.aida-is-open, html.aida-is-open body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .aida-launcher, .aida-root, .aida-panel, .aida-msg, .aida-typing span { transition: none !important; animation: none !important; }
}
