/* Écran de conversation avec l'agent. */

.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--surface);
}

.chat-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ------------------------------------------------------- Colonne sessions */

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  background: var(--surface-alt);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.sidebar__head {
  padding: 16px 16px 12px;
}

.sidebar__new {
  width: 100%;
}

.sidebar__label {
  padding: 8px 16px 4px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-muted);
}

.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
  margin: 0;
  list-style: none;
}

.sidebar__empty {
  padding: 8px 8px 16px;
  font-size: var(--fs-13);
  color: var(--ink-muted);
}

.session {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px 0 0;
  border-left: 2px solid transparent;
  border-radius: 0 var(--r-control) var(--r-control) 0;
}

.session:hover { background: var(--surface); }

.session[aria-current="true"] {
  background: var(--surface);
  border-left-color: var(--samsung-blue);
}

.session__link {
  flex: 1;
  min-width: 0;
  padding: 8px 8px 8px 10px;
  color: var(--ink);
  font-size: var(--fs-13);
}

.session__link:hover { text-decoration: none; }

.session__name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session__date {
  display: block;
  font-size: var(--fs-12);
  color: var(--ink-muted);
}

/* Les actions n'apparaissent qu'au survol ou au focus clavier. */
.session__actions {
  display: flex;
  gap: 0;
  opacity: 0;
}

.session:hover .session__actions,
.session:focus-within .session__actions { opacity: 1; }

.session__rename {
  flex: 1;
  margin: 4px 4px 4px 10px;
  font-size: var(--fs-13);
}

.session__confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  font-size: var(--fs-12);
  color: var(--ink);
}

.session__confirm button {
  min-height: 24px;
  padding: 0 8px;
  font-size: var(--fs-12);
}

/* ------------------------------------------------------------------- Fil */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
}

.thread__inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Utilisateur : aligné à droite, fond --surface-alt, rayon 8px. */
.msg--user {
  align-self: flex-end;
  max-width: 78%;
  padding: 10px 14px;
  background: var(--surface-alt);
  border-radius: var(--r-panel);
}

/* Agent : pas de bulle, pleine largeur — c'est là qu'il y a du contenu long. */
.msg--agent {
  align-self: stretch;
}

.msg__text {
  font-size: var(--fs-14);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.msg__text > *:first-child { margin-top: 0; }
.msg__text > *:last-child { margin-bottom: 0; }

.msg__text p { margin: 0 0 12px; }
.msg__text h1,
.msg__text h2,
.msg__text h3 {
  font-size: var(--fs-16);
  margin: 20px 0 8px;
}

.msg__text ul,
.msg__text ol {
  margin: 0 0 12px;
  padding-left: 20px;
}

.msg__text li { margin-bottom: 4px; }

.msg__text code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: var(--fs-13);
  background: var(--surface-alt);
  padding: 1px 4px;
  border-radius: 3px;
}

.msg__text pre {
  margin: 0 0 12px;
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  overflow-x: auto;
}

.msg__text pre code {
  background: none;
  padding: 0;
}

.msg__text blockquote {
  margin: 0 0 12px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
  color: var(--ink-muted);
}

.msg__text table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: var(--fs-13);
}

.msg__text th {
  text-align: left;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-muted);
  padding: var(--cell-pad);
  border-bottom: 1px solid var(--line);
}

.msg__text td {
  padding: var(--cell-pad);
  border-bottom: 1px solid var(--line);
}

.msg__images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.msg__images img {
  max-width: 240px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
}

/* ------------------------------------------------------- Carte d'action */

.action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--samsung-blue);
  border-radius: var(--r-control);
  font-size: var(--fs-13);
}

.action-card__text { flex: 1; }

.action-card__field { font-weight: 500; }

.action-card__link {
  font-size: var(--fs-13);
  white-space: nowrap;
}

/* ------------------------------------------------ Indicateur de frappe */

.wait {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wait__hint {
  font-size: var(--fs-13);
  color: var(--ink-muted);
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}

.typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: typing 1s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.25; }
  30% { opacity: 1; }
}

/* --------------------------------------------------- État vide + erreur */

.thread-empty {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.thread-empty__title {
  font-size: var(--fs-20);
}

.thread-empty__sub {
  font-size: var(--fs-14);
  color: var(--ink-muted);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  font-family: var(--font-body);
  font-size: var(--fs-13);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.suggestion:hover {
  border-color: var(--samsung-blue);
  color: var(--samsung-blue);
}

.msg-error {
  padding: 10px 12px;
  border-left: 3px solid var(--state-review);
  background: var(--state-review-bg);
  font-size: var(--fs-13);
}

.msg-error__retry {
  margin-left: 8px;
  font-size: var(--fs-13);
  background: none;
  border: 0;
  padding: 0;
  color: var(--samsung-blue);
  text-decoration: underline;
  cursor: pointer;
  font-family: var(--font-body);
}

/* ------------------------------------------------------------- Composer */

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 16px 24px 20px;
  background: var(--surface);
}

.composer__inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
}

.composer__inner:focus-within {
  border-color: var(--samsung-blue);
}

.composer__input {
  flex: 1;
  border: 0;
  padding: 6px 4px;
  max-height: 200px;
  overflow-y: auto;
  background: none;
}

.composer__input:focus {
  outline: none;
}

.composer__send {
  width: 32px;
  height: 32px;
  border-radius: var(--r-control);
  background: var(--samsung-blue);
  color: var(--surface);
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.composer__send:hover:not(:disabled) { background: var(--samsung-blue-dk); }

.composer__send:disabled {
  background: var(--line);
  color: var(--ink-muted);
  cursor: not-allowed;
}

.composer__send svg { width: 16px; height: 16px; }

.composer__hint {
  max-width: 760px;
  margin: 8px auto 0;
  font-size: var(--fs-12);
  color: var(--ink-muted);
}

/* ------------------------------------------------------------ Responsive */

.sidebar-toggle { display: none; }

@media (max-width: 900px) {
  .sidebar-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform var(--dur-panel) var(--ease-out);
    box-shadow: var(--shadow-panel);
  }

  .sidebar[data-open="true"] { transform: translateX(0); }

  .thread { padding: 24px 16px; }
  .composer { padding: 12px 16px 16px; }
  .msg--user { max-width: 90%; }
}
