/* ── Design tokens ── */
:root {
  --primary:       #5b3fd4;
  --primary-dark:  #4730b0;
  --primary-light: #ede9ff;
  --accent:        #7c5cd8;
  --accent-text:   #6947d6;
  --bg:            #eef0f7;
  --bg-hero:       linear-gradient(145deg, #e8eaf6 0%, #f0f4ff 50%, #e4eaf8 100%);
  --panel:         #f7f8fa;
  --bubble-bot:    #edf0f7;
  --bubble-user:   #5b3fd4;
  --text:          #141827;
  --muted:         #5a6177;
  --card:          #ffffff;
  --border:        #e2e5ef;
  --shadow-sm:     0 2px 8px rgba(60,50,120,.07);
  --shadow-lg:     0 20px 48px rgba(60,50,120,.16);
  --radius:        18px;
  --radius-sm:     12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ════════════════════════════════
   HERO
════════════════════════════════ */
.hero {
  min-height: 100vh;
  background: var(--bg-hero);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 48px;
  padding: 80px 72px;
}

/* left column */
.hero__content { max-width: 520px; }

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 28px;
}
.hero__eyebrow svg { flex-shrink: 0; }

.hero__heading {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 24px;
}
.hero__heading--accent {
  color: var(--accent-text);
}

.hero__sub {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 420px;
  margin-bottom: 36px;
}

.hero__demo-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,.25);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.25); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,.1); }
}

/* right column */
.hero__card-wrap {
  display: flex;
  justify-content: center;
}

/* ════════════════════════════════
   CONNECT CARD
════════════════════════════════ */
.connect-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.7);
  padding: 28px 28px 20px;
  width: 100%;
  max-width: 380px;
}

.connect-card__header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.connect-card__icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.connect-card__icon svg { width: 22px; height: 22px; }

.connect-card__title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}
.connect-card__sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.connect-card__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.connect-card__input-wrap {
  position: relative;
  margin-bottom: 14px;
}
.connect-card__input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.connect-card__input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px 11px 36px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--panel);
  outline: none;
  transition: border-color .18s;
}
.connect-card__input:focus { border-color: var(--primary); }

.connect-card__btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 13px 20px;
  cursor: pointer;
  transition: opacity .18s, transform .12s;
  margin-bottom: 16px;
}
.connect-card__btn svg { width: 16px; height: 16px; }
.connect-card__btn:hover { opacity: .92; transform: translateY(-1px); }
.connect-card__btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.connect-card__btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ── Site status ── */
.site-status {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 14px 10px;
  margin-bottom: 14px;
}

.site-status__top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #16a34a;
  margin-bottom: 12px;
}
.site-status__top svg { width: 16px; height: 16px; stroke: #16a34a; }

.site-status__site {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.site-status__avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.site-status__name {
  font-size: 0.9rem;
  font-weight: 700;
}
.site-status__url {
  font-size: 0.75rem;
  color: var(--muted);
}
.site-status__badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: #16a34a;
  white-space: nowrap;
}

.site-status__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.site-status__stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.site-status__stat strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 2px;
}
.site-status__stat span {
  font-size: 0.7rem;
  color: var(--muted);
}

.site-status__note {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
}

.connect-card__footer {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.connect-card__footer svg {
  width: 14px;
  height: 14px;
  color: var(--accent-text);
  flex-shrink: 0;
}

/* ── Loader spinner inside button ── */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════
   CHAT WIDGET (floating)
════════════════════════════════ */
.chat-widget {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 9999;
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 88px;
  width: 380px;
  max-height: 640px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(0,0,0,.04);
  overflow: hidden;
  display: none;
  flex-direction: column;
  /* Mobile keyboard fix */
  max-height: min(640px, calc(100dvh - 120px));
}
.chat-panel.open { display: flex; }

/* ── Header ── */
.chat-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 18px;
  flex-shrink: 0;
}

.chat-header__title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-header__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}
.chat-header__name {
  font-size: 0.98rem;
  font-weight: 700;
}
.chat-header__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  opacity: .85;
  margin-top: 2px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7ef0a6;
  box-shadow: 0 0 0 2px rgba(126,240,166,.3);
}
.chat-header__close {
  border: none;
  background: rgba(255,255,255,.15);
  color: white;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.chat-header__close:hover { background: rgba(255,255,255,.25); }
.chat-header__close:focus-visible {
  outline: 2px solid rgba(255,255,255,.6);
  outline-offset: 2px;
}
.chat-header__close svg { width: 16px; height: 16px; }

/* ── Body ── */
.chat-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 14px 10px;
  background: var(--bg);
  scroll-behavior: smooth;
}

/* ── Messages ── */
.message {
  margin-bottom: 16px;
  max-width: 94%;
  display: flex;
  flex-direction: column;
}
.message.user  { margin-left: auto;  align-items: flex-end; }
.message.bot   {
  margin-right: auto;
  align-items: flex-start;
  flex-direction: row;
  gap: 10px;
}

/* Bot avatar on the left */
.message.bot .bot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(109, 40, 217, 0.22);
}
.message.bot .bot-avatar svg { width: 18px; height: 18px; }

.message.bot .bot-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.bubble {
  border-radius: 18px;
  padding: 12px 15px;
  font-size: 0.92rem;
  line-height: 1.6;
  word-break: break-word;
}
.message.user .bubble {
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.message.bot .bubble {
  background: #ffffff;
  color: #1E293B; /* slate-800 */
  border: 1px solid #E5E7EB;
  border-top-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.message.system .bubble {
  background: #e8e2fd;
  color: #3b2a70;
  font-size: 0.82rem;
  text-align: center;
  margin: 0 auto 10px;
  max-width: 92%;
}

/* Markdown-style content inside bot bubbles */
.bubble strong { font-weight: 700; color: #0F172A; }
.bubble a { color: var(--primary-dark); font-weight: 600; text-decoration: underline; }
.bubble ul, .bubble ol { margin: 8px 0 0 18px; }
.bubble li { margin: 5px 0; }
.bubble p + p { margin-top: 8px; }

/* ── Action cards (options / formations) ── */
.action-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #E5E7EB;
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  transition: border-color .18s, box-shadow .18s, transform .1s;
}
.action-card:hover {
  border-color: #A78BFA; /* violet-400 */
  box-shadow: 0 6px 16px rgba(109, 40, 217, 0.08);
  transform: translateY(-1px);
}
.action-card:focus-visible {
  outline: 2px solid #6D28D9;
  outline-offset: 2px;
}

.action-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #EDE9FE; /* violet-100 */
  color: #6D28D9; /* violet-700 */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.action-card__icon svg { width: 22px; height: 22px; }

.action-card__body {
  flex: 1;
  min-width: 0;
}
.action-card__title {
  font-weight: 600;
  font-size: 0.93rem;
  color: #0F172A; /* slate-900 */
  line-height: 1.3;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.action-card__meta {
  font-size: 0.74rem;
  color: #64748B; /* slate-500 */
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.action-card__chevron {
  color: #CBD5E1; /* slate-300 */
  flex-shrink: 0;
  transition: color .18s, transform .18s;
  display: flex;
}
.action-card__chevron svg { width: 20px; height: 20px; }
.action-card:hover .action-card__chevron {
  color: #6D28D9;
  transform: translateX(2px);
}

.action-card__badge {
  position: absolute;
  top: -8px;
  right: 14px;
  background: #EDE9FE;
  color: #6D28D9; /* violet-700 */
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.cards-footer {
  text-align: center;
  font-size: 0.75rem;
  color: #94A3B8; /* slate-400 */
  padding: 2px 0;
}

/* ── Typing indicator ── */
.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  background: var(--bubble-bot);
}
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8892aa;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .16s; }
.typing span:nth-child(3) { animation-delay: .32s; }
@keyframes bounce {
  0%,80%,100% { transform: translateY(0); opacity: .5; }
  40%          { transform: translateY(-5px); opacity: 1; }
}

/* ── Chips ── */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 14px 10px;
  flex-shrink: 0;
  background: var(--bg);
}
.chip {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 13px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Input bar ── */
.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input__field {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 0.9rem;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
}
.chat-input__field:focus { border-color: var(--primary); }

.chat-input__button {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s, transform .1s;
}
.chat-input__button:hover { opacity: .9; transform: scale(1.04); }
.chat-input__button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.chat-input__button svg { width: 17px; height: 17px; }

/* ── Error message inside chat ── */
.message.error .bubble {
  background: #fde8e8;
  color: #991b1b;
}

/* ── Toggle button ── */
.chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-top: 8px;
  float: right;
  transition: transform .15s, box-shadow .15s;
  position: relative;
}
.chat-toggle:hover  { transform: scale(1.06); }
.chat-toggle:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
.chat-toggle__icon { width: 26px; height: 26px; position: absolute; transition: opacity .2s, transform .2s; }
.chat-toggle__icon--open  { opacity: 1; transform: scale(1); }
.chat-toggle__icon--close { opacity: 0; transform: scale(.6); }

.chat-toggle.is-open .chat-toggle__icon--open  { opacity: 0; transform: scale(.6); }
.chat-toggle.is-open .chat-toggle__icon--close { opacity: 1; transform: scale(1); }

/* Notification dot */
.chat-toggle::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: pulse 2s infinite;
}
.chat-toggle.is-open::after { display: none; }

/* ── Input error flash ── */
.connect-card__input.input-error {
  border-color: #e53e3e;
  animation: shake .3s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* ════════════════════════════════
   RESPONSIVE
════════════════════════════════ */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 60px 32px 80px;
    text-align: left;
    gap: 48px;
  }
  .hero__card-wrap { justify-content: flex-start; }
  .connect-card { max-width: 100%; }
}

@media (max-width: 540px) {
  .hero { padding: 48px 20px 100px; }
  .hero__heading { font-size: 2.2rem; }
  .chat-panel {
    width: min(92vw, 360px);
    right: 0;
  }
  .chat-widget { right: 16px; bottom: 16px; }
}

/* ── Analyse : progression / erreur ── */
.connect-card__progress {
  margin-top: 10px;
  font-size: .82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.connect-card__error {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fde8e8;
  color: #991b1b;
  font-size: .82rem;
  line-height: 1.45;
}

/* ── Sources sous les réponses du bot ── */
.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  max-width: 100%;
}
.sources a {
  font-size: .72rem;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 3px 9px;
  text-decoration: none;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sources a:hover { text-decoration: underline; }
