/* AMA — page /ask en mode chat fullscreen */
body.ama-page { padding-left: 0 !important; min-height: 100vh; display: block; }
body.ama-page .sidebar,
body.ama-page .nav-toggle,
body.ama-page .sidebar-backdrop,
body.ama-page .site-footer { display: none !important; }

.ama-shell { display: flex; height: 100vh; width: 100vw; overflow: hidden; background: var(--black); color: var(--white); }

/* Sidebar gauche : historique */
.ama-side { width: 280px; flex-shrink: 0; background: var(--deep); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: transform var(--transition); }
.ama-side__head { padding: 1.2rem 1.1rem 0.8rem; border-bottom: 1px solid var(--border); }
.ama-side__brand { display: flex; align-items: center; gap: 0.7rem; color: var(--white); text-decoration: none; margin-bottom: 0.9rem; }
.ama-side__brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.ama-side__brand span { font-family: var(--serif); font-size: 0.95rem; line-height: 1.15; }
.ama-side__newchat { display: flex; align-items: center; justify-content: center; width: 100%; padding: 0.7rem 0.9rem; font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.06em; color: var(--white); background: rgba(195,60,84,0.12); border: 1px solid var(--accent); border-radius: var(--radius); cursor: pointer; transition: background var(--transition); }
.ama-side__newchat:hover { background: rgba(195,60,84,0.22); }
.ama-side__history { flex: 1; overflow-y: auto; padding: 1rem 0.6rem; }
.ama-side__history-label { font-family: var(--sans); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 0 0.5rem 0.5rem; }
.ama-history-list { list-style: none; padding: 0; margin: 0; }
.ama-history-list li { font-size: 0.82rem; line-height: 1.35; padding: 0.6rem 0.7rem; border-radius: var(--radius); cursor: pointer; color: var(--white); opacity: 0.78; transition: all 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.15rem; }
.ama-history-list li:hover { background: rgba(255,255,255,0.05); opacity: 1; }
.ama-history-list li.is-current { background: rgba(195,60,84,0.15); opacity: 1; }
.ama-history-empty { padding: 0.5rem 0.8rem; font-size: 0.78rem; font-style: italic; opacity: 0.5; }
.ama-history-list:not(:empty) + .ama-history-empty { display: none; }
.ama-side__foot { padding: 0.9rem 1.1rem; border-top: 1px solid var(--border); }
.ama-side__foot nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.ama-side__foot a { font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.05em; color: var(--muted); transition: color var(--transition); }
.ama-side__foot a:hover { color: var(--accent); }

/* Colonne centrale */
.ama-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.ama-main__head { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--black); }
.ama-main__head h1 { font-family: var(--serif); font-size: 1.3rem; font-weight: 400; margin: 0; }
.ama-side__toggle { display: none; background: none; border: none; color: var(--white); font-size: 1.3rem; cursor: pointer; padding: 0.3rem 0.5rem; }

.ama-thread { flex: 1; overflow-y: auto; padding: 2rem 0; scroll-behavior: smooth; }

.ama-empty { max-width: 800px; margin: 4rem auto; padding: 0 1.5rem; text-align: center; }
.ama-empty__eyebrow { font-family: var(--sans); font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.5rem; }
.ama-empty__h { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 300; margin: 0 0 0.85rem; line-height: 1.2; }
.ama-empty__sub { font-size: 1rem; opacity: 0.65; max-width: 540px; margin: 0 auto 2.5rem; line-height: 1.6; }
.ama-suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.7rem; max-width: 760px; margin: 0 auto; }
.ama-suggestion { font-family: var(--sans); font-size: 0.85rem; padding: 0.8rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--white); cursor: pointer; text-align: left; transition: all var(--transition); }
.ama-suggestion:hover { background: var(--surface2); border-color: var(--accent); color: var(--accent-light); }

.ama-msg { max-width: 800px; margin: 0 auto 1.6rem; padding: 0 1.5rem; }
.ama-msg__role { font-family: var(--sans); font-size: 0.65rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.6rem; }
.ama-msg--user .ama-msg__role { color: var(--accent); }
.ama-msg--user .ama-msg__body { background: rgba(195,60,84,0.08); padding: 1rem 1.25rem; border-radius: var(--radius); border-left: 3px solid var(--accent); font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; }
.ama-msg--assistant .ama-msg__body { font-family: var(--serif); font-size: 1.1rem; line-height: 1.75; }
.ama-msg--assistant .ama-msg__body p { margin: 0 0 0.85rem; }
.ama-msg--assistant .ama-msg__body p:last-child { margin-bottom: 0; }
.ama-msg--assistant .ama-msg__body a { color: var(--accent-light); border-bottom: 1px dashed var(--border); }
.ama-msg--assistant .ama-msg__body a:hover { border-bottom-color: var(--accent); }
.ama-msg--assistant .ama-msg__body em { color: var(--accent-light); }
.ama-msg--assistant .ama-msg__body.is-streaming::after { content: '▍'; display: inline-block; color: var(--accent); animation: ama-blink 1s infinite; margin-left: 2px; }
@keyframes ama-blink { 0%,49% {opacity:1;} 50%,100% {opacity:0;} }
.ama-msg__sources { margin-top: 0.85rem; padding-top: 0.75rem; border-top: 1px solid var(--border); font-size: 0.82rem; }
.ama-msg__sources strong { font-family: var(--sans); font-size: 0.65rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 500; display: block; margin-bottom: 0.4rem; }
.ama-msg__sources a { display: inline-block; margin-right: 0.85rem; color: var(--white); opacity: 0.85; border-bottom: 1px dashed var(--border); }
.ama-msg__sources a:hover { color: var(--accent); }
.ama-msg--status .ama-msg__body { background: rgba(195,60,84,0.06); border-left: 3px solid var(--accent); padding: 0.85rem 1rem; font-family: var(--sans); font-size: 0.9rem; line-height: 1.5; }

.ama-composer { max-width: 800px; width: calc(100% - 3rem); margin: 0 auto; padding: 0.6rem 0.6rem 0.6rem 1.1rem; display: flex; align-items: end; gap: 0.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; margin-bottom: 0.6rem; transition: border-color var(--transition); }
/* /ask : codes d'application de chat — la page ne scrolle pas, seul le fil défile en interne */
body { overflow: hidden; }
.site-footer { display: none; }
.ama-composer:focus-within { border-color: var(--accent); }
.ama-composer__input { flex: 1; background: transparent; border: 0; outline: 0; font: inherit; font-size: 1rem; line-height: 1.5; color: var(--white); resize: none; max-height: 220px; padding: 0.5rem 0; min-height: 24px; }
.ama-composer__submit { flex-shrink: 0; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: var(--accent); color: var(--black); border: 0; border-radius: 50%; cursor: pointer; transition: all var(--transition); }
.ama-composer__submit:hover { background: var(--accent-light); }
.ama-composer__submit:disabled { opacity: 0.4; cursor: not-allowed; }
.ama-disclaim { max-width: 800px; margin: 0 auto 1.2rem; padding: 0 1.5rem; font-size: 0.75rem; opacity: 0.5; text-align: center; }
.ama-disclaim a { color: var(--accent); }

@media (max-width: 800px) {
  .ama-side { position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; transform: translateX(-100%); box-shadow: 8px 0 30px rgba(0,0,0,0.4); }
  .ama-side.is-open { transform: translateX(0); }
  .ama-side__toggle { display: inline-flex; }
}

/* Light mode */
:root[data-theme="light"] .ama-shell { background: #f5f3ef; color: #2f2d2e; }
:root[data-theme="light"] .ama-side { background: #ebe8e2; border-right-color: rgba(0,0,0,0.1); }
:root[data-theme="light"] .ama-side__brand,
:root[data-theme="light"] .ama-history-list li,
:root[data-theme="light"] .ama-main__head h1 { color: #2f2d2e; }
:root[data-theme="light"] .ama-side__newchat { color: #2f2d2e; }
:root[data-theme="light"] .ama-suggestion { background: #ffffff; color: #2f2d2e; }
:root[data-theme="light"] .ama-suggestion:hover { background: #f9f7f3; }
:root[data-theme="light"] .ama-composer { background: #ffffff; border-color: rgba(0,0,0,0.15); }
:root[data-theme="light"] .ama-composer__input { color: #2f2d2e; }
:root[data-theme="light"] .ama-msg--assistant .ama-msg__body { color: #2f2d2e; }
:root[data-theme="light"] .ama-history-list li:hover { background: rgba(0,0,0,0.04); }
:root[data-theme="light"] .ama-main__head { background: #f5f3ef; }

/* Widget AMA compact (autres pages — pas /ask) */
.ama-widget { margin-top: 3rem; padding: 1.5rem; background: rgba(195,60,84,0.04); border: 1px solid var(--border); border-radius: var(--radius); }
.ama-widget__form { display: flex; gap: 0.6rem; align-items: stretch; flex-wrap: wrap; }
.ama-widget__input { flex: 1; min-width: 240px; padding: 0.7rem 0.9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--white); font: inherit; font-size: 0.95rem; }
.ama-widget__input:focus { outline: none; border-color: var(--accent); }

/* ============================
   Layout 2 colonnes embedded (intégré au site)
   ============================ */
.ama-embed--cols {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.ama-history-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.85rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.ama-history-pane__label {
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1rem 0 0.5rem 0.3rem;
}
.ama-history-pane .ama-history-new {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--white);
  background: rgba(195,60,84,0.12);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.ama-history-pane .ama-history-new:hover { background: rgba(195,60,84,0.22); }
.ama-history-pane .ama-history-list { list-style: none; padding: 0; margin: 0; }
.ama-history-pane .ama-history-list li {
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--white);
  opacity: 0.78;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}
.ama-history-pane .ama-history-list li:hover { background: rgba(255,255,255,0.05); opacity: 1; }
.ama-history-pane .ama-history-list li.is-current { background: rgba(195,60,84,0.15); opacity: 1; }
.ama-history-pane .ama-history-empty { padding: 0.5rem 0.65rem; font-size: 0.78rem; font-style: italic; opacity: 0.5; }
.ama-history-pane .ama-history-list:not(:empty) + .ama-history-empty { display: none; }

/* Colonne chat */
.ama-chat-pane { display: flex; flex-direction: column; gap: 0; }
.ama-chat-pane .ama-thread { min-height: 360px; max-height: calc(100vh - 220px); overflow-y: auto; padding: 0; margin-bottom: 1rem; }
.ama-chat-pane .ama-empty { margin: 1rem auto 2.5rem; }
.ama-chat-pane .ama-empty__h { display: none; } /* on garde l'eyebrow + sub seulement, le h1 est dans le hero */

/* Mobile : historique en haut, repliable */
@media (max-width: 800px) {
  .ama-embed--cols { grid-template-columns: 1fr; }
  .ama-history-pane { position: static; max-height: 280px; }
}

/* Light overrides */
:root[data-theme="light"] .ama-history-pane { background: #ffffff; }
:root[data-theme="light"] .ama-history-pane .ama-history-new,
:root[data-theme="light"] .ama-history-pane .ama-history-list li { color: #2f2d2e; }
:root[data-theme="light"] .ama-history-pane .ama-history-list li:hover { background: rgba(0,0,0,0.04); }

/* Curseur du composer collé à gauche */
.ama-composer { padding-left: 0.6rem; }
.ama-composer__input { padding-left: 0.5rem; }

/* Séparateur léger entre historique et chat */
.ama-embed--cols { gap: 0; }
.ama-history-pane { 
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  border-top: none;
  border-bottom: none;
  border-left: none;
  padding-right: 1.25rem;
  margin-right: 1.5rem;
}
:root[data-theme="light"] .ama-history-pane { background: transparent; }

/* Gagner de l'espace sur /ask : hero plus compact + section plus serrée */
body:has(#amaForm) .page-hero--compact { padding: 2rem 0 1rem; }
body:has(#amaForm) .page-hero--compact h1 { margin-top: 0.2rem; font-size: clamp(1.6rem, 3vw, 2.2rem); }
body:has(#amaForm) .page-hero--compact .page-lead { margin-top: 0.4rem; font-size: 0.9rem; }
body:has(#amaForm) .section { padding-top: 1rem !important; padding-bottom: 1rem !important; }

/* Thread plus haut + composer plus serré */
.ama-chat-pane .ama-thread { min-height: 280px; padding-top: 0.5rem; }
.ama-chat-pane .ama-empty { margin: 0.5rem auto 1.5rem; }
.ama-empty__eyebrow { margin-bottom: 0.3rem; }
.ama-empty__sub { margin-bottom: 1.2rem; }
.ama-composer { margin-top: 0.5rem; }
.ama-disclaim { margin-bottom: 0.5rem; font-size: 0.7rem; }

/* Historique sticky plus haut */
.ama-history-pane { top: 0.5rem; }

/* /ask : exploite toute la largeur du conteneur (pas de max-width 800) */
.ama-chat-pane .ama-msg,
.ama-chat-pane .ama-composer,
.ama-chat-pane .ama-disclaim,
.ama-chat-pane .ama-empty { max-width: none; padding-left: 0; padding-right: 0; }
.ama-chat-pane .ama-composer { width: 100%; }
.ama-chat-pane .ama-suggestions { max-width: none; }

/* Le container du site peut être plus large pour /ask */
body:has(#amaForm) .container { max-width: 1500px; width: 96%; }

/* La barre verticale (historique) s'étend jusqu'en bas — pleine hauteur viewport */
.ama-history-pane {
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  padding-top: 1rem;
}
.ama-embed--cols { align-items: start; }

/* ============================
   Composer toujours en bas (style ChatGPT/Claude)
   .ama-chat-pane devient une colonne flex de hauteur viewport.
   Le thread scroll seul, le composer reste collé en bas.
   ============================ */
.ama-chat-pane {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 1rem);
  position: sticky;
  top: 0.5rem;
}
.ama-chat-pane .ama-thread {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}
.ama-chat-pane .ama-composer {
  flex-shrink: 0;
  margin-top: auto;
  margin-bottom: 0.3rem;
}
.ama-chat-pane .ama-disclaim {
  flex-shrink: 0;
  margin-bottom: 0.4rem;
}
