/* =========================================================================
   Assistant SWIFT — SKAIZen · thème "fintech dark premium"
   Accent : dégradé cyan -> violet électrique. Tout est piloté par variables.
   ========================================================================= */
:root {
  --bg:        #070a14;
  --bg-2:      #0b1020;
  --panel:     rgba(20, 27, 48, 0.55);
  --panel-2:   rgba(28, 37, 64, 0.6);
  --stroke:    rgba(120, 160, 255, 0.14);
  --stroke-2:  rgba(120, 160, 255, 0.28);
  --txt:       #e8edff;
  --txt-dim:   #9aa6c7;
  --txt-faint: #647092;

  --cyan:   #22d3ee;
  --violet: #8b5cf6;
  --accent-grad: linear-gradient(115deg, var(--cyan) 0%, #6ea8ff 45%, var(--violet) 100%);
  --glow-cyan:   rgba(34, 211, 238, 0.35);
  --glow-violet: rgba(139, 92, 246, 0.35);

  --radius:    18px;
  --radius-sm: 12px;
  --maxw:      900px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, #101936 0%, var(--bg) 60%);
  color: var(--txt);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
}

/* ---------- décor de fond ---------- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(120,160,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,160,255,.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(900px 600px at 50% 0%, #000 0%, transparent 75%);
}
.bg-glow {
  position: fixed; z-index: 0; pointer-events: none;
  width: 60vw; height: 60vw; border-radius: 50%;
  filter: blur(120px); opacity: .5;
  animation: float 18s ease-in-out infinite alternate;
}
.bg-glow--a { top: -25vw; left: -15vw; background: radial-gradient(circle, var(--glow-cyan), transparent 70%); }
.bg-glow--b { bottom: -30vw; right: -15vw; background: radial-gradient(circle, var(--glow-violet), transparent 70%); animation-delay: -9s; }
@keyframes float { from { transform: translate(0,0) scale(1); } to { transform: translate(40px, 30px) scale(1.1); } }

/* ---------- layout ---------- */
.app {
  position: relative; z-index: 1;
  height: 100vh; display: flex; flex-direction: column;
  max-width: 1100px; margin: 0 auto; padding: 0 20px;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 16px 20px; margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04);
}
.brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
/* logo SKAIZen Group : fond blanc -> posé sur une tuile blanche arrondie
   (le blanc du PNG se fond dans la tuile, aucune couture visible).
   On le fige à sa HAUTEUR NATIVE exacte (60px) et on empêche tout parent
   flex de le rétrécir -> aucun redimensionnement, texte net et lisible. */
.brand__logo {
  height: 60px; width: auto; display: block; flex: 0 0 auto;  /* natif 300x60, jamais scalé */
  background: #fff; padding: 8px 16px; border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.6);
}
.brand__logo--missing { display: none; }
/* séparateur vertical entre le logo (marque) et le titre (produit) */
.brand__txt { display: flex; flex-direction: column; min-width: 0; gap: 3px;
  padding-left: 18px; border-left: 1px solid var(--stroke); }
.brand__title { font-size: 24px; font-weight: 700; letter-spacing: .2px; line-height: 1.2; }
.brand__sub { font-size: 14px; color: var(--txt-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grad {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 15px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--stroke);
  font-size: 14px; color: var(--txt-dim); white-space: nowrap;
}
.status__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #f59e0b; box-shadow: 0 0 10px #f59e0b;
}
.status.ready  .status__dot { background: #34d399; box-shadow: 0 0 12px #34d399; animation: pulse 2.4s infinite; }
.status.error  .status__dot { background: #ef4444; box-shadow: 0 0 12px #ef4444; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ---------- chat ---------- */
.chat {
  flex: 1; overflow-y: auto; padding: 26px 6px 10px;
  scroll-behavior: smooth;
}
.chat::-webkit-scrollbar { width: 10px; }
.chat::-webkit-scrollbar-thumb { background: rgba(120,160,255,.18); border-radius: 99px; }
.chat::-webkit-scrollbar-track { background: transparent; }

/* écran d'accueil */
.welcome {
  max-width: var(--maxw); margin: clamp(20px, 9vh, 90px) auto 0;
  text-align: center; padding: 20px;
  animation: rise .6s cubic-bezier(.2,.8,.2,1);
}
.welcome__badge {
  display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 1.5px;
  color: var(--cyan); padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--stroke-2); background: rgba(34,211,238,.06);
  margin-bottom: 22px;
}
.welcome h1 { font-size: clamp(28px, 4vw, 42px); font-weight: 800; margin: 0 0 12px; letter-spacing: -.5px; }
.welcome p { font-size: 17px; color: var(--txt-dim); margin: 0 auto 30px; max-width: 560px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.chip {
  font: inherit; font-size: 14px; color: var(--txt);
  padding: 11px 18px; border-radius: 14px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--stroke);
  backdrop-filter: blur(10px); transition: all .2s ease;
}
.chip:hover {
  border-color: var(--stroke-2); transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(34,211,238,.12);
  color: #fff;
}

/* messages — affichage sobre (style Claude) */
.msg { max-width: var(--maxw); margin: 0 auto 28px; animation: rise .45s cubic-bezier(.2,.8,.2,1); }

/* question utilisateur : bulle discrète, contenue, alignée à droite */
.msg--user { display: flex; justify-content: flex-end; }
.msg--user .bubble {
  max-width: 80%; padding: 12px 17px;
  border-radius: 16px 16px 4px 16px;
  background: var(--panel-2); border: 1px solid var(--stroke);
  font-size: 15.5px; line-height: 1.55; color: var(--txt);
  backdrop-filter: blur(10px);
}

/* réponse de l'assistant : pleine largeur, sans cadre ni fond */
.msg--bot .bubble {
  padding: 2px 2px 2px 0; font-size: 16px; line-height: 1.7;
}

/* rendu markdown dans la bulle */
.bubble :where(p, ul, ol) { margin: 0 0 .7em; }
.bubble :where(p, ul, ol):last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { padding-left: 1.4em; }
.bubble li { margin: .25em 0; }
.bubble h1, .bubble h2, .bubble h3 { margin: .3em 0 .5em; line-height: 1.3; }
.bubble h2 { font-size: 1.25em; } .bubble h3 { font-size: 1.1em; }
.bubble code {
  font-family: "JetBrains Mono", monospace; font-size: .88em;
  background: rgba(120,160,255,.12); padding: 2px 6px; border-radius: 6px;
}
.bubble pre {
  background: var(--bg-2); border: 1px solid var(--stroke);
  padding: 14px; border-radius: 10px; overflow-x: auto;
}
.bubble pre code { background: none; padding: 0; }
.bubble strong { color: #fff; }
.bubble a { color: var(--cyan); text-decoration: none; border-bottom: 1px solid rgba(34,211,238,.3); }
.bubble a:hover { border-color: var(--cyan); }

/* curseur de streaming */
.cursor {
  display: inline-block; width: 9px; height: 1.05em; vertical-align: text-bottom;
  margin-left: 2px; border-radius: 2px; background: var(--cyan);
  box-shadow: 0 0 10px var(--glow-cyan); animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* indicateur "recherche en cours" */
.thinking { display: flex; align-items: center; gap: 6px; color: var(--txt-dim); font-size: 14px; }
.thinking .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); animation: bounce 1.2s infinite; }
.thinking .dot:nth-child(2) { animation-delay: .15s; }
.thinking .dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-6px); opacity: 1; } }

/* ---------- chip "intention détectée" (routeur) ---------- */
.plan-chip {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 5px 11px; border-radius: 9px;
  font-size: 12px; color: var(--txt-dim);
  background: linear-gradient(135deg, rgba(34,211,238,.07), rgba(139,92,246,.07));
  border: 1px solid var(--stroke-2);
  animation: rise .3s;
}
.plan-chip__ico { filter: drop-shadow(0 0 6px var(--glow-cyan)); }
.plan-chip__label b { color: var(--txt); font-weight: 600; }
.plan-chip__types {
  font-family: "JetBrains Mono", monospace; font-size: 11.5px; font-weight: 600;
  color: var(--cyan); padding: 1px 8px; border-radius: 6px;
  background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.2);
}

/* ---------- sources ---------- */
.sources { margin-top: 14px; }
.sources__toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--txt-dim);
  padding: 7px 13px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--stroke);
  transition: all .2s; user-select: none;
}
.sources__toggle:hover { color: #fff; border-color: var(--stroke-2); }
.sources__toggle .count { color: var(--cyan); }
.sources__toggle .chev { transition: transform .25s; }
.sources.open .sources__toggle .chev { transform: rotate(90deg); }
.sources__list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 11px; margin-top: 12px;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .35s ease, opacity .3s ease;
}
.sources.open .sources__list { max-height: 1200px; opacity: 1; }
.src-card {
  padding: 13px 14px; border-radius: 13px;
  background: var(--panel); border: 1px solid var(--stroke);
  transition: all .2s; animation: rise .4s backwards;
}
.src-card:hover { border-color: var(--stroke-2); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.src-card__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.src-card__tag {
  font-family: "JetBrains Mono", monospace; font-size: 12px; font-weight: 600;
  color: var(--cyan); padding: 2px 8px; border-radius: 7px;
  background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.2);
}
.src-card__score { margin-left: auto; font-size: 11px; color: var(--txt-faint); font-family: "JetBrains Mono", monospace; }
.src-card__name { font-size: 13px; color: var(--txt-dim); margin-bottom: 9px; }
.src-card__foot { display: flex; align-items: center; gap: 8px; }
.src-card__link {
  font-size: 12.5px; color: var(--cyan); text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px;
}
.src-card__link:hover { color: #fff; }

/* ---------- composer ---------- */
.composer { padding: 8px 0 18px; }
.filters { margin: 0 auto 10px; max-width: var(--maxw); }
.filters > summary {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; color: var(--txt-dim); list-style: none;
  padding: 7px 13px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--stroke); width: max-content;
  transition: all .2s;
}
.filters > summary:hover { color: #fff; border-color: var(--stroke-2); }
.filters > summary::-webkit-details-marker { display: none; }
.filters__hint { color: var(--txt-faint); }
.filters__body {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end;
  margin-top: 11px; padding: 16px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--stroke);
  animation: rise .3s;
}
.filters__body label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--txt-dim); }
.filters__body input, .filters__body select {
  font: inherit; font-size: 14px; color: var(--txt);
  padding: 9px 12px; border-radius: 10px; min-width: 220px;
  background: var(--bg-2); border: 1px solid var(--stroke); outline: none;
}
.filters__body input:focus, .filters__body select:focus { border-color: var(--cyan); }
.filters__note { width: 100%; margin: 0; font-size: 12px; color: var(--txt-faint); }

.inputbar {
  display: flex; align-items: flex-end; gap: 10px;
  max-width: var(--maxw); margin: 0 auto;
  padding: 10px 10px 10px 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--stroke-2);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 40px rgba(0,0,0,.4), 0 0 0 0 var(--glow-cyan);
  transition: box-shadow .3s, border-color .3s;
}
.inputbar:focus-within {
  border-color: rgba(34,211,238,.5);
  box-shadow: 0 10px 40px rgba(0,0,0,.4), 0 0 30px -6px var(--glow-cyan);
}
.inputbar textarea {
  flex: 1; font: inherit; font-size: 16px; color: var(--txt);
  background: none; border: none; outline: none; resize: none;
  padding: 8px 0; max-height: 180px; line-height: 1.5;
}
.inputbar textarea::placeholder { color: var(--txt-faint); }
.send {
  flex: 0 0 44px; height: 44px; width: 44px; border-radius: 13px; border: none;
  display: grid; place-items: center; cursor: pointer; color: #04121a;
  background: var(--accent-grad);
  box-shadow: 0 4px 18px rgba(34,211,238,.35);
  transition: transform .15s, opacity .2s, box-shadow .2s;
}
.send:hover:not(:disabled) { transform: translateY(-2px) scale(1.04); box-shadow: 0 8px 26px rgba(34,211,238,.5); }
.send:active:not(:disabled) { transform: scale(.95); }
.send:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.send svg { transform: rotate(-0deg); }

.composer__foot {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--maxw); margin: 9px auto 0; padding: 0 4px;
}
.model-tag {
  font-size: 12px; color: var(--txt-faint); font-family: "JetBrains Mono", monospace;
  display: inline-flex; align-items: center; gap: 6px;
}
.ghost-btn {
  font: inherit; font-size: 12.5px; color: var(--txt-faint); cursor: pointer;
  background: none; border: none; padding: 4px 6px; border-radius: 8px; transition: color .2s;
}
.ghost-btn:hover { color: #ef6b6b; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* erreur */
.err { color: #ffb4b4; }
.err b { color: #ff8a8a; }

@media (max-width: 640px) {
  .app { padding: 0 12px; }
  .brand__sub { display: none; }
  .brand__logo { height: 44px; padding: 6px 12px; }   /* évite le débordement, desktop garde 60px natif */
  .brand__title { font-size: 19px; }
  .sources__list { grid-template-columns: 1fr; }
}
