/* ═══════════════════════════════════════════════════════
   ANVEN FORMATION — Anna, agent d'accueil (widget flottant)
   BEM strict .anven-welcome*
   Palette ambre/or (≠ violet d'Evan) pour différenciation visuelle.
   ═══════════════════════════════════════════════════════ */

:root {
  --anv-welcome-or: #F59E0B;
  --anv-welcome-or-dark: #D97706;
  --anv-welcome-or-soft: rgba(245, 158, 11, 0.10);
  --anv-welcome-or-border: rgba(245, 158, 11, 0.22);
  --anv-welcome-gradient: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  --anv-welcome-text: #1E1B2E;
  --anv-welcome-gris: #64748B;
  --anv-welcome-blanc: #FAFAF8;
  --anv-welcome-radius: 12px;
  --anv-welcome-radius-sm: 8px;
}

/* ─── FAB (bouton flottant ambre, avec label "Anna") ───────── */
.anven-welcome-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  height: 60px;
  min-width: 60px;
  padding: 0 22px 0 14px;
  border-radius: 32px;
  border: none;
  background: var(--anv-welcome-gradient);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(217, 119, 6, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  z-index: 9998;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  font-family: var(--syn-font, "Inter", system-ui, sans-serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.anven-welcome-fab > * {
  pointer-events: none;
}
.anven-welcome-fab:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 32px rgba(217, 119, 6, 0.45), 0 2px 8px rgba(0, 0, 0, 0.14);
}
.anven-welcome-fab:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}
.anven-welcome-fab:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.45);
  outline-offset: 3px;
}
.anven-welcome-fab__label {
  position: relative;
  z-index: 1;
  white-space: nowrap;
}
.anven-welcome-fab__icon { position: relative; z-index: 1; }
.anven-welcome-fab__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid rgba(255, 255, 255, 0.55);
}
.anven-welcome-fab__pulse {
  position: absolute;
  inset: -4px;
  border-radius: 32px;
  background: rgba(245, 158, 11, 0.35);
  opacity: 0;
  animation: anven-welcome-fab-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes anven-welcome-fab-pulse {
  0% { transform: scale(0.94); opacity: 0.55; }
  70% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1.15); opacity: 0; }
}
.anven-welcome-fab--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

/* ─── Panel ─────────────────────────────────────────────────── */
.anven-welcome-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 100px);
  background: var(--anv-welcome-blanc);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(20, 16, 40, 0.28), 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: var(--syn-font, "Inter", system-ui, sans-serif);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, width 0.28s ease, height 0.28s ease;
  border: 1px solid var(--anv-welcome-or-border);
}
.anven-welcome-widget[hidden] { display: none !important; }
.anven-welcome-widget--open {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.anven-welcome-widget--expanded {
  width: 720px;
  height: 85vh;
  max-height: calc(100vh - 60px);
}

.anven-welcome-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--anv-welcome-gradient);
  color: #fff;
  flex-shrink: 0;
}
.anven-welcome-widget__header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.anven-welcome-widget__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.anven-welcome-widget__header-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.anven-welcome-widget__title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.anven-welcome-widget__subtitle {
  font-size: 0.72rem;
  opacity: 0.92;
  margin-top: 1px;
}

.anven-welcome-widget__header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.anven-welcome-widget__expand,
.anven-welcome-widget__close {
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}
.anven-welcome-widget__expand:hover,
.anven-welcome-widget__close:hover {
  background: rgba(255, 255, 255, 0.28);
}
.anven-welcome-widget__close:hover { transform: rotate(90deg); }
.anven-welcome-widget__expand:focus-visible,
.anven-welcome-widget__close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.75);
  outline-offset: 2px;
}
.anven-welcome-widget__icon-shrink { display: none; }
.anven-welcome-widget--expanded .anven-welcome-widget__icon-expand { display: none; }
.anven-welcome-widget--expanded .anven-welcome-widget__icon-shrink { display: block; }

.anven-welcome-widget__body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative; /* ancrage des modales inline (.anven-welcome__confirm) */
}
.anven-welcome-widget__inner {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── Le composant chat interne ─────────────────────────────── */
.anven-welcome {
  margin: 0;
  padding: 14px 16px;
  background: var(--anv-welcome-blanc);
  border: none;
  border-radius: 0;
  box-shadow: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.anven-welcome__history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 12px;
  background: rgba(0, 0, 0, 0.015);
  border-radius: var(--anv-welcome-radius-sm);
  margin-bottom: 12px;
}

.anven-welcome__message {
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.92rem;
  max-width: 92%;
  word-wrap: break-word;
}
.anven-welcome__message--user {
  background: var(--anv-welcome-or-soft);
  color: var(--anv-welcome-text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.anven-welcome__message--assistant {
  background: #fff;
  color: var(--anv-welcome-text);
  align-self: flex-start;
  border-left: 3px solid var(--anv-welcome-or);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.anven-welcome__message-meta {
  font-size: 0.72rem;
  color: rgba(0, 0, 0, 0.5);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.anven-welcome__message-content { white-space: pre-wrap; }
.anven-welcome__message-content a {
  color: var(--anv-welcome-or-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.anven-welcome__message-content a:hover {
  text-decoration-thickness: 2px;
}
.anven-welcome__message-content strong { font-weight: 700; }
.anven-welcome__message-content em { font-style: italic; }
.anven-welcome__message-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  background: var(--anv-welcome-or-soft);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: var(--anv-welcome-or-dark);
}
.anven-welcome__message-content ul,
.anven-welcome__message-content ol {
  margin: 0.4em 0;
  padding-left: 1.4em;
}
.anven-welcome__message-content li {
  margin: 0.25em 0;
  line-height: 1.5;
}
.anven-welcome__message-content li::marker {
  color: var(--anv-welcome-or-dark);
}
.anven-welcome__message-content h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0.7em 0 0.3em;
  color: #1E1B2E;
  line-height: 1.3;
}
.anven-welcome__message-content h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0.6em 0 0.25em;
  color: #1E1B2E;
  line-height: 1.3;
}
.anven-welcome__message-content table {
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 13px;
  width: 100%;
  background: #FFFFFF;
  border-radius: 6px;
  overflow: hidden;
}
.anven-welcome__message-content th,
.anven-welcome__message-content td {
  border: 1px solid #E5E7EB;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
}
.anven-welcome__message-content th {
  background: rgba(245, 158, 11, 0.08);
  font-weight: 600;
  color: var(--anv-welcome-or-dark);
}

/* Disclaimer permanent — pattern ChatGPT/Claude/Gemini */
.anven-welcome__disclaimer {
  margin: 0;
  padding: 6px 14px 8px;
  font-size: 11px;
  line-height: 1.4;
  color: #94a3b8;
  text-align: center;
  font-style: italic;
}

.anven-welcome__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 12px;
  border-left: 3px solid var(--anv-welcome-or);
  align-self: flex-start;
  max-width: 92%;
}
.anven-welcome__typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--anv-welcome-or);
  animation: anven-welcome-bounce 1.2s infinite ease-in-out;
}
.anven-welcome__typing-dot:nth-child(2) { animation-delay: 0.15s; }
.anven-welcome__typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes anven-welcome-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* État vide */
.anven-welcome__empty {
  padding: 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.anven-welcome__empty-intro {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--anv-welcome-text);
}
.anven-welcome__suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.anven-welcome__suggestion {
  background: #fff;
  border: 1px solid var(--anv-welcome-or-border);
  border-radius: var(--anv-welcome-radius-sm);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--anv-welcome-text);
}
.anven-welcome__suggestion:hover {
  border-color: var(--anv-welcome-or);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.12);
}

/* ─── Form ──────────────────────────────────────────────────── */
.anven-welcome__form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.anven-welcome__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--anv-welcome-or-border);
  border-radius: var(--anv-welcome-radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 60px;
  max-height: 120px;
  background: #fff;
  color: var(--anv-welcome-text);
  transition: border-color 0.15s ease;
}
.anven-welcome__input:focus {
  outline: none;
  border-color: var(--anv-welcome-or);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}
.anven-welcome__input:disabled { opacity: 0.5; cursor: not-allowed; }
.anven-welcome__submit {
  width: 100%;
  background: var(--anv-welcome-gradient);
  color: #fff;
  border: none;
  border-radius: var(--anv-welcome-radius-sm);
  padding: 0.7rem 1.2rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.9rem;
}
.anven-welcome__submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.28);
}
.anven-welcome__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--anv-welcome-gris);
}

/* En mode agrandi : zone d'écriture plus haute */
.anven-welcome-widget--expanded .anven-welcome__input {
  min-height: 110px;
  max-height: 240px;
  font-size: 0.95rem;
}

/* ─── Footer ────────────────────────────────────────────────── */
.anven-welcome__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--anv-welcome-or-border);
  font-size: 0.72rem;
  color: var(--anv-welcome-gris);
}
.anven-welcome__verbosity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.anven-welcome__verbosity-label { font-weight: 500; }
.anven-welcome__verbosity-select {
  background: #fff;
  border: 1px solid var(--anv-welcome-or-border);
  border-radius: var(--anv-welcome-radius-sm);
  color: var(--anv-welcome-text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3em 1.8em 0.3em 0.6em;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23D97706' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.5em center;
  transition: border-color 0.15s ease;
}
.anven-welcome__verbosity-select:hover { border-color: var(--anv-welcome-or); }
.anven-welcome__verbosity-select:focus-visible {
  outline: none;
  border-color: var(--anv-welcome-or);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}
.anven-welcome__reset {
  background: transparent;
  border: 1px solid var(--anv-welcome-or-border);
  color: var(--anv-welcome-gris);
  padding: 0.35em 0.8em;
  border-radius: var(--anv-welcome-radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  transition: all 0.15s ease;
}
.anven-welcome__reset:hover {
  border-color: var(--anv-welcome-or);
  color: var(--anv-welcome-or-dark);
}

/* ─── Modale de confirmation inline (Nouvelle discussion) ──── */
.anven-welcome__confirm {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 40, 0.42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: anven-welcome-fade-in 0.18s ease-out;
}
.anven-welcome__confirm[hidden] { display: none; }
@keyframes anven-welcome-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.anven-welcome__confirm-box {
  background: var(--anv-welcome-blanc);
  border-radius: 14px;
  padding: 20px 22px;
  margin: 0 18px;
  max-width: 320px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.anven-welcome__confirm-text {
  margin: 0 0 16px 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--anv-welcome-text);
}
.anven-welcome__confirm-sub {
  font-size: 0.82rem;
  color: var(--anv-welcome-gris);
  font-weight: 400;
}
.anven-welcome__confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.anven-welcome__confirm-cancel,
.anven-welcome__confirm-ok {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55em 1.1em;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.anven-welcome__confirm-cancel {
  background: transparent;
  border: 1px solid var(--anv-welcome-or-border);
  color: var(--anv-welcome-gris);
}
.anven-welcome__confirm-cancel:hover {
  border-color: var(--anv-welcome-gris);
  color: var(--anv-welcome-text);
}
.anven-welcome__confirm-ok {
  background: var(--anv-welcome-gradient);
  border: none;
  color: var(--anv-welcome-blanc);
}
.anven-welcome__confirm-ok:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.28);
}

/* ─── Notices ───────────────────────────────────────────────── */
.anven-welcome__notice {
  padding: 10px 12px;
  border-radius: var(--anv-welcome-radius-sm);
  margin: 6px 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.anven-welcome__notice--warn {
  background: var(--anv-welcome-or-soft);
  border-left: 3px solid var(--anv-welcome-or);
  color: #92400E;
}
.anven-welcome__notice--error {
  background: rgba(239, 68, 68, 0.06);
  border-left: 3px solid #DC2626;
  color: #991B1B;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .anven-welcome-widget--expanded {
    width: calc(100vw - 32px);
    height: 85vh;
  }
}

@media (max-width: 640px) {
  .anven-welcome-fab {
    bottom: 16px;
    right: 16px;
    height: 56px;
    padding: 0 18px 0 12px;
    font-size: 0.9rem;
  }
  .anven-welcome-widget,
  .anven-welcome-widget--expanded {
    width: calc(100vw - 16px);
    height: calc(100vh - 80px);
    max-height: calc(100vh - 80px);
    bottom: 8px;
    right: 8px;
    left: 8px;
    border-radius: 14px;
  }
  .anven-welcome-widget__expand { display: none; }
  .anven-welcome-widget__title { font-size: 0.9rem; }
  .anven-welcome-widget__subtitle { font-size: 0.68rem; }
}
