/* Elie — guide de bord Surge Studio */

.elie-root {
  --elie-width: 460px;
  --elie-height: 680px;
  position: fixed;
  z-index: 9999;
  bottom: 28px;
  right: 28px;
  font-family: var(--font);
  pointer-events: none;
}

.elie-root * {
  box-sizing: border-box;
}

.elie-root.is-open {
  pointer-events: auto;
}

/* ── Lanceur (bouton + invitation) ── */

.elie-launcher {
  position: absolute;
  bottom: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.elie-root.is-open .elie-launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.92);
}

/* Bulle d'invitation */

.elie-teaser {
  position: relative;
  max-width: 280px;
  padding: 12px 36px 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(42, 101, 184, 0.22) 0%, rgba(0, 0, 0, 0.88) 100%);
  border: 1px solid rgba(42, 101, 184, 0.45);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 28px rgba(42, 101, 184, 0.2);
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.elie-teaser.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: elie-teaser-float 3s ease-in-out infinite;
}

.elie-teaser::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 28px;
  width: 14px;
  height: 14px;
  background: rgba(0, 0, 0, 0.88);
  border-right: 1px solid rgba(42, 101, 184, 0.45);
  border-bottom: 1px solid rgba(42, 101, 184, 0.45);
  transform: rotate(45deg);
}

.elie-teaser p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
}

.elie-teaser strong {
  color: var(--primary-light);
  font-weight: 600;
}

.elie-teaser-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.elie-teaser-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

@keyframes elie-teaser-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Bouton pill Elie */

.elie-fab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 22px 8px 8px;
  border: 1px solid rgba(42, 101, 184, 0.55);
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(42, 101, 184, 0.18) 0%, rgba(0, 0, 0, 0.92) 100%);
  box-shadow:
    0 8px 36px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(42, 101, 184, 0.15),
    0 0 40px rgba(42, 101, 184, 0.35);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  animation: elie-fab-glow 2.8s ease-in-out infinite;
}

.elie-fab-ring {
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 2px solid rgba(122, 162, 227, 0.5);
  animation: elie-ring-pulse 2.8s ease-in-out infinite;
  pointer-events: none;
}

.elie-fab-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(122, 162, 227, 0.6);
  box-shadow: 0 0 20px rgba(42, 101, 184, 0.45);
}

.elie-fab-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.elie-fab-online {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3dd68c;
  border: 2px solid var(--bg-dark);
  box-shadow: 0 0 8px rgba(61, 214, 140, 0.6);
}

.elie-fab-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  min-width: 0;
}

.elie-fab-text strong {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.elie-fab-text span {
  font-size: 0.78rem;
  color: var(--primary-light);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
}

.elie-fab:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(122, 162, 227, 0.75);
  box-shadow:
    0 12px 44px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(42, 101, 184, 0.25),
    0 0 56px rgba(42, 101, 184, 0.5);
}

.elie-fab:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 4px;
}

@keyframes elie-fab-glow {
  0%, 100% {
    box-shadow:
      0 8px 36px rgba(0, 0, 0, 0.65),
      0 0 0 1px rgba(42, 101, 184, 0.15),
      0 0 32px rgba(42, 101, 184, 0.28);
  }
  50% {
    box-shadow:
      0 8px 36px rgba(0, 0, 0, 0.65),
      0 0 0 1px rgba(42, 101, 184, 0.3),
      0 0 52px rgba(42, 101, 184, 0.48);
  }
}

@keyframes elie-ring-pulse {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.04); }
}

@keyframes elie-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.75; }
}

/* ── Panneau chat ── */

.elie-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: var(--elie-width);
  max-width: calc(100vw - 32px);
  height: var(--elie-height);
  max-height: calc(100dvh - 72px);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 0 60px rgba(42, 101, 184, 0.12);
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.elie-root.is-open .elie-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── En-tête ── */

.elie-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light);
  background: rgba(42, 101, 184, 0.06);
  flex-shrink: 0;
}

.elie-header-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.elie-header-info {
  flex: 1;
  min-width: 0;
}

.elie-header-info strong {
  display: block;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.elie-header-info span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.elie-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.elie-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.elie-close svg {
  width: 18px;
  height: 18px;
}

/* ── Messages ── */

.elie-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(42, 101, 184, 0.4) transparent;
}

.elie-msg {
  display: flex;
  gap: 10px;
  max-width: 94%;
  animation: elie-msg-in 0.25s ease;
}

@keyframes elie-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.elie-msg--bot {
  align-self: flex-start;
}

.elie-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.elie-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}

.elie-msg-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
  letter-spacing: 0.01em;
}

.elie-msg-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.elie-msg-body p {
  margin: 0 0 12px;
}

.elie-msg-body p:last-child {
  margin-bottom: 0;
}

.elie-msg-body code {
  font-size: 0.78rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-light);
  color: var(--primary-light);
  word-break: break-word;
}

.elie-msg-body strong {
  font-weight: 600;
  color: #fff;
}

/* ── Apparition mot par mot ── */

.elie-word {
  opacity: 0;
  display: inline;
}

.elie-word.is-visible {
  opacity: 1;
  animation: elie-word-in 0.1s ease forwards;
}

@keyframes elie-word-in {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.elie-msg-extra--hidden {
  opacity: 0;
  visibility: hidden;
  max-height: 0;
  overflow: hidden;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
}

.elie-msg-extra--visible {
  opacity: 1;
  visibility: visible;
  max-height: none;
  overflow: visible;
  transition: opacity 0.35s ease;
}

.elie-msg-links.elie-msg-extra--visible {
  margin-top: 14px !important;
  padding-top: 14px !important;
  border-top: 1px solid var(--border-light) !important;
}

.elie-msg-feedback.elie-msg-extra--visible {
  margin-top: 14px !important;
  padding-top: 14px !important;
  border-top: 1px solid var(--border-light) !important;
}

/* ── Structure de réponse ── */

.elie-answer {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.elie-answer-intent {
  margin: 0 0 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.elie-answer-intent em {
  font-style: normal;
  color: var(--primary-light);
}

.elie-answer-direct {
  margin: 0;
  font-weight: 500;
  color: #fff;
  line-height: 1.55;
}

.elie-answer-hint {
  margin: 10px 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.elie-answer-note {
  margin: 10px 0 0;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.55;
  opacity: 0.9;
}

.elie-answer-list,
.elie-answer-steps {
  margin: 10px 0 0;
  padding-left: 1.35rem;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text);
}

.elie-answer-list li,
.elie-answer-steps li {
  margin-bottom: 8px;
}

.elie-answer-list li:last-child,
.elie-answer-steps li:last-child {
  margin-bottom: 0;
}

.elie-answer-steps {
  list-style: decimal;
}

.elie-answer-pre {
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-light);
  overflow-x: auto;
}

.elie-answer-pre code {
  display: block;
  padding: 0;
  background: none;
  border: none;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--primary-light);
  white-space: pre-wrap;
  word-break: break-word;
}

.elie-msg--bot .elie-msg-bubble {
  background: rgba(42, 101, 184, 0.12);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.elie-msg--user .elie-msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.elie-msg-bubble a {
  color: var(--primary-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.elie-msg--user .elie-msg-bubble a {
  color: #fff;
}

.elie-msg-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.elie-msg-links-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 2px;
  font-weight: 500;
}

.elie-msg-link {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(42, 101, 184, 0.18);
  border: 1px solid var(--border);
  color: var(--primary-light) !important;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none !important;
  transition: background var(--transition), border-color var(--transition);
}

.elie-msg-link-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.elie-msg-link-label {
  line-height: 1.35;
}

.elie-msg-link-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-dim);
  line-height: 1.3;
}

.elie-msg-link:hover {
  background: rgba(42, 101, 184, 0.28);
  border-color: rgba(42, 101, 184, 0.4);
}

.elie-msg-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Feedback oui / non ── */

.elie-msg-feedback {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.elie-feedback-label {
  margin: 0 0 12px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.elie-feedback-actions {
  display: flex;
  gap: 8px;
}

.elie-feedback-btn {
  padding: 8px 22px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.elie-feedback-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.elie-feedback-btn--yes:hover {
  background: rgba(46, 160, 67, 0.18);
  border-color: rgba(46, 160, 67, 0.45);
  color: #7dcea0;
}

.elie-feedback-btn--no:hover {
  background: rgba(192, 57, 43, 0.18);
  border-color: rgba(192, 57, 43, 0.45);
  color: #e8a09a;
}

/* ── Suggestions rapides ── */

.elie-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
  flex-shrink: 0;
}

.elie-suggestion {
  padding: 7px 13px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  font-family: inherit;
}

.elie-suggestion:hover {
  background: rgba(42, 101, 184, 0.12);
  color: var(--text);
  border-color: rgba(42, 101, 184, 0.35);
}

/* ── Zone de saisie ── */

.elie-input-area {
  display: flex;
  gap: 10px;
  padding: 16px 18px;
  border-top: 1px solid var(--border-light);
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.elie-input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition);
}

.elie-input::placeholder {
  color: var(--text-dim);
}

.elie-input:focus {
  border-color: rgba(42, 101, 184, 0.5);
}

.elie-send {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}

.elie-send:hover:not(:disabled) {
  background: var(--primary-light);
}

.elie-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.elie-send svg {
  width: 18px;
  height: 18px;
}

/* ── Indicateur de frappe ── */

.elie-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.elie-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: elie-dot 1.2s ease-in-out infinite;
}

.elie-typing span:nth-child(2) { animation-delay: 0.15s; }
.elie-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes elie-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Widget compact (sidebar wiki) ── */

.elie-sidebar-widget {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.elie-sidebar-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(42, 101, 184, 0.4);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(42, 101, 184, 0.14) 0%, rgba(42, 101, 184, 0.04) 100%);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  box-shadow: 0 0 20px rgba(42, 101, 184, 0.12);
  animation: elie-sidebar-glow 3s ease-in-out infinite;
}

.elie-sidebar-card:hover {
  background: rgba(42, 101, 184, 0.18);
  border-color: rgba(42, 101, 184, 0.55);
  box-shadow: 0 0 28px rgba(42, 101, 184, 0.25);
}

@keyframes elie-sidebar-glow {
  0%, 100% { box-shadow: 0 0 16px rgba(42, 101, 184, 0.1); }
  50% { box-shadow: 0 0 24px rgba(42, 101, 184, 0.22); }
}

.elie-sidebar-card img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.elie-sidebar-card-text strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 600;
}

.elie-sidebar-card-text span {
  display: block;
  font-size: 0.7rem;
  color: var(--primary-light);
  margin-top: 1px;
  font-weight: 500;
}

/* ── Responsive ── */

@media (max-width: 520px) {
  .elie-root {
    bottom: 16px;
    right: 16px;
    --elie-width: calc(100vw - 32px);
    --elie-height: calc(100dvh - 80px);
  }

  .elie-teaser {
    max-width: calc(100vw - 48px);
    font-size: 0.8rem;
  }

  .elie-fab {
    padding: 6px 14px 6px 6px;
    gap: 10px;
  }

  .elie-fab-avatar-wrap {
    width: 46px;
    height: 46px;
  }

  .elie-fab-text span {
    font-size: 0.72rem;
  }
}

@media (max-width: 380px) {
  .elie-fab-text span {
    display: none;
  }
}

@media (min-width: 1200px) {
  .elie-root {
    --elie-width: 480px;
    --elie-height: 720px;
  }
}
