/* ============================================================
   Let Me Prompt It For You — styles
   ============================================================ */
:root {
  --brand: #10a37f;
  --brand-soft: rgba(16, 163, 127, .12);
  --bg-1: #0f1117;
  --bg-2: #171a23;
  --ink: #e9ecf1;
  --ink-dim: #9aa3b2;
  --line: rgba(255, 255, 255, .08);
  --card: rgba(255, 255, 255, .035);
  --radius: 18px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, .7);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* L'attribut [hidden] doit toujours l'emporter sur les display: des classes */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--brand) 26%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  transition: background .5s ease;
}

/* ============ CONSTRUCTEUR ============ */
.builder {
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(24px, 6vw, 64px) 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.builder__head { text-align: center; }

.logo {
  font-size: clamp(26px, 5.5vw, 40px);
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0 0 8px;
  line-height: 1.1;
}
.logo__spark { color: var(--brand); transition: color .4s ease; }

.tagline {
  margin: 0;
  color: var(--ink-dim);
  font-size: clamp(14px, 2.5vw, 17px);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.field { display: flex; flex-direction: column; gap: 10px; border: 0; padding: 0; margin: 0; }
.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
}

textarea#prompt {
  width: 100%;
  resize: vertical;
  min-height: 80px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .25);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  transition: border-color .2s, box-shadow .2s;
}
textarea#prompt:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Grille de choix d'IA */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.ai-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, .02);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-align: left;
  transition: border-color .18s, background .18s, transform .12s;
}
.ai-chip:hover { transform: translateY(-1px); background: rgba(255, 255, 255, .05); }
.ai-chip[aria-checked="true"] {
  border-color: var(--chip);
  background: color-mix(in srgb, var(--chip) 14%, transparent);
}
.ai-chip__avatar {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
  color: #fff;
  background: var(--chip);
  flex: none;
}

/* Boutons */
.btn {
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  padding: 13px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s, background .2s, border-color .2s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { filter: brightness(1.07); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn--soft { background: var(--brand-soft); color: var(--brand); }
.btn--soft:hover { filter: brightness(1.1); }
.btn--text { background: transparent; color: var(--ink-dim); padding: 13px 8px; }
.btn--text:hover { color: var(--ink); }

/* Résultat */
.result { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.result__row { display: flex; gap: 8px; }
.result__link {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .3);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.result__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.builder__foot {
  text-align: center;
  color: var(--ink-dim);
  font-size: 12.5px;
  opacity: .8;
}

/* ============ LECTEUR / ANIMATION ============ */
.player {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.chat {
  width: min(560px, 94vw);
  height: min(620px, 82dvh);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.chat__avatar {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
}
.chat__name { font-weight: 700; }

.chat__body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
.chat__hint {
  margin: auto;
  color: var(--ink-dim);
  font-size: 14px;
  opacity: .55;
}

/* Bulle utilisateur (apparaît à l'envoi) */
.bubble {
  align-self: flex-end;
  max-width: 80%;
  padding: 12px 15px;
  border-radius: 16px 16px 4px 16px;
  background: var(--brand);
  color: #fff;
  line-height: 1.45;
  font-size: 15px;
  animation: pop .25s ease both;
  word-wrap: break-word;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.96); } }

/* Composer */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}
.composer__field {
  position: relative;
  flex: 1;
  min-height: 48px;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .25);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
}
.composer__placeholder {
  position: absolute;
  left: 16px; top: 13px;
  color: var(--ink-dim);
  pointer-events: none;
  transition: opacity .15s;
}
.composer__text { white-space: pre-wrap; }
.caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--brand);
  margin-left: 1px;
  vertical-align: text-bottom;
  opacity: 0;
}
.caret.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } 0%, 49% { opacity: 1; } }

.composer__send {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 12px;
  border: 0;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .12s, filter .2s, opacity .2s;
  opacity: .5;
}
.composer__send.ready { opacity: 1; }
.composer__send.press { transform: scale(.82); filter: brightness(1.2); }

.player__skip {
  position: fixed;
  bottom: 18px;
  left: 0; right: 0;
  text-align: center;
  color: var(--ink-dim);
  font-size: 13px;
  opacity: .6;
}

/* Curseur animé */
.cursor {
  position: fixed;
  top: 0; left: 0;
  z-index: 50;
  pointer-events: none;
  transform: translate(-100px, 120vh);
  transition: transform .7s cubic-bezier(.55, .1, .25, 1);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35));
  will-change: transform;
}

/* ============ OVERLAY ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  animation: rise .25s ease both;
}
.overlay__box {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(420px, 92vw);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.overlay__title { margin: 0 0 4px; font-size: 17px; line-height: 1.4; }
.overlay__title strong { color: var(--brand); }

@media (prefers-reduced-motion: reduce) {
  .cursor { transition-duration: .25s; }
}

/* ============================================================
   AJOUTS : logos, langue, projet de code, partage
   ============================================================ */

/* Logos dans les pastilles */
.ai-chip__avatar svg, .chat__avatar svg { width: 62%; height: 62%; fill: #fff; }

/* Sélecteur de langue */
.lang {
  align-self: flex-end;
  margin-bottom: -8px;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, .25);
}
.lang button {
  font: inherit;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .03em;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.lang button.is-on { background: var(--brand); color: #fff; }

/* Interrupteur « projet de code » */
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  width: 42px; height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  position: relative; flex: none;
  transition: background .2s;
}
.switch__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--brand-soft); }
.switch__label { font-weight: 600; font-size: 15px; }

/* Options du projet de code */
.code-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; animation: rise .25s ease both; }
.seg {
  display: inline-flex; gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: max-content;
}
.seg__btn {
  font: inherit; font-weight: 600; font-size: 14px;
  color: var(--ink-dim);
  background: transparent; border: 0;
  padding: 8px 14px; border-radius: 9px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg__btn.is-on { background: var(--brand); color: #fff; }
.code-path {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .25);
  color: var(--ink);
  font: inherit; font-size: 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.code-path:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* Boutons de partage */
.share { display: flex; flex-direction: column; gap: 10px; }
.share__row { display: flex; gap: 10px; }
.share__btn {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--ink);
  cursor: pointer;
  transition: transform .12s, border-color .2s, color .2s, background .2s;
}
.share__btn:hover { transform: translateY(-1px); border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* Bouton « joindre » dans le composer */
.composer__attach {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .12s, color .2s, border-color .2s;
}
.composer__attach.press { transform: scale(.82); color: var(--brand); border-color: var(--brand); }

/* Pièces jointes (contexte du projet) */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 11px;
  padding: 8px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  animation: pop .25s ease both;
  max-width: 100%;
}
.chip__icon { font-size: 18px; line-height: 1; flex: none; }
.chip__main { display: flex; flex-direction: column; min-width: 0; }
.chip__name {
  font-weight: 700; font-size: 13.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip__sub { font-size: 11.5px; color: var(--ink-dim); }
.chip__status { margin-left: 2px; font-weight: 800; color: var(--brand); display: grid; place-items: center; width: 16px; }
.spinner {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-top-color: var(--brand);
  animation: spin .7s linear infinite;
  display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }
