:root {
  --bg: #f1f0ed;
  --surface: #ffffff;
  --border: #e2e0da;
  --brand: #e67561;
  --brand-dim: #e675611a;
  --brand-dim-strong: #e6756126;
  --gold: #d4a017;
  --gold-dim: #d4a0171a;
  --success: #4a9b72;
  --success-dim: #4a9b721a;
  --danger: #c1503a;
  --danger-dim: #c1503a14;
  --text: #242320;
  --text-muted: #6b6a62;
  --serif: var(--sans);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --round: "Fredoka", "Inter", sans-serif;
}

.brand-word {
  font-family: var(--round);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Icônes SVG dans les boutons : alignement propre avec le texte */
.ghost-btn, .primary-btn, .secondary-btn, .tab-btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ghost-btn svg, .primary-btn svg, .secondary-btn svg, .tab-btn svg {
  flex-shrink: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
}

/* --- En-tête --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.app-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-header-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
}

.app-title {
  margin: 0;
  font-family: var(--round);
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.app-subtitle {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nom du sujet de conversation (UI #28) : mis en avant, au-dessus de la
   date de mise à jour du référentiel. */
.app-team-name {
  margin: 1px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.new-conversation-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--brand);
  background: var(--brand-dim);
  border: none;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.new-conversation-btn:hover {
  background: var(--brand);
  color: #ffffff;
}

.new-conversation-btn:active {
  background: #b85d47;
}

.app-header-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.logout-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.logout-btn:active {
  background: var(--bg);
}

/* Sur petit écran, ne garder que l'icône pour ne pas écraser le titre */
@media (max-width: 420px) {
  .new-conversation-btn .btn-label,
  .logout-btn .btn-label {
    display: none;
  }
  .new-conversation-btn,
  .logout-btn {
    padding: 8px 10px;
  }
}

/* --- Zone de chat --- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 85%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  flex-shrink: 0;
}

.msg-bot {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
  color: var(--text);
}

.msg-user {
  background: var(--brand);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.msg-user-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: flex-end;
  max-width: 85%;
  gap: 3px;
  flex-shrink: 0;
}

.msg-user-wrap .msg-user {
  max-width: 100%;
}

.msg-user-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 3px;
}

.msg-time {
  font-size: 11px;
  color: var(--text-muted);
}

.edit-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.edit-icon-btn:hover {
  opacity: 1;
}

.msg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-radius: 12px;
  max-width: 92%;
  width: 100%;
  overflow: hidden;
  padding: 0;
  white-space: normal;
  flex-shrink: 0;
}

.msg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--brand-dim);
  border-bottom: 1px solid var(--border);
}

.msg-card-body {
  padding: 14px 16px 4px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text);
}

/* --- Carte de profil médecin --- */
.profile-card {
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--border);
}

.profile-card:last-child {
  border-bottom: none;
}

.profile-card-header {
  margin-bottom: 14px;
}

.profile-card-name {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  white-space: normal;
}

.profile-card-meta {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--sans);
  white-space: normal;
}

.profile-card-section {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.profile-card-header + .profile-card-section {
  padding-top: 0;
  border-top: none;
  margin-top: 0;
}

/* --- Lignes d'information sobres "label : valeur" (corrige #187 — la
   fiche affichait auparavant des curseurs/badges de percentile qui ne
   généralisaient pas à tous les fichiers, voir #179, et masquaient les
   colonnes catégorielles non reconnues comme indicateur). --- */
.profile-info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 13.5px;
}

.profile-info-row:not(:last-child) {
  border-bottom: 1px dashed var(--border);
}

.profile-info-label {
  color: var(--text-muted);
}

.profile-info-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.extra-note {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  white-space: pre-wrap;
}

.chip {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.chip-nominative {
  color: var(--success);
}

.chip-analytique {
  color: var(--gold);
}

.msg-loading {
  font-size: 13.5px;
  color: var(--text-muted);
  font-style: italic;
  background: transparent;
  border: none;
  padding: 4px 2px;
}

/* --- Barre de saisie --- */
.input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.attach-btn {
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
}

#messageInput {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 14.5px;
  font-family: var(--sans);
  color: var(--text);
  outline: none;
}

#messageInput:focus {
  border-color: var(--brand);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #ffffff;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:disabled {
  background: #c9c6bd;
  cursor: not-allowed;
}

/* --- Responsive : écrans larges (tablette / desktop) --- */
@media (min-width: 720px) {
  body {
    padding: 24px 0;
  }
  .app {
    height: calc(100vh - 48px);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 16px rgba(35, 36, 32, 0.06);
  }
}

/* --- Suggestions de noms cliquables (ex: faute d'orthographe) --- */
.suggestions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 14px;
}

.suggestion-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-family: var(--sans);
  font-weight: 500;
  background: var(--surface);
  border: 1.5px solid var(--brand);
  border-radius: 20px;
  color: var(--brand);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.suggestion-btn:hover:not(:disabled) {
  background: var(--brand);
  color: #ffffff;
}

.suggestion-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* --- Icônes d'action (copier / signaler un bug / préciser une donnée) --- */
.msg-card-actions {
  display: flex;
  gap: 2px;
  padding: 2px 12px 12px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14.5px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

/* Icônes éditer / bug / préciser / copier légèrement agrandies (demande
   client), 15px -> 18px. */
.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn-success {
  color: var(--success);
}

.icon-btn:hover {
  background: var(--brand-dim);
  color: var(--brand);
}

.feedback-form {
  margin: 0 16px 14px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.feedback-form p {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.feedback-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: var(--sans);
  resize: vertical;
  box-sizing: border-box;
}

.feedback-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.feedback-form-actions button {
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--sans);
  border-radius: 6px;
  cursor: pointer;
}

.feedback-form-actions button:first-child {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.feedback-form-actions button:last-child {
  background: var(--brand);
  color: #ffffff;
  border: none;
}

/* ============================================================
   ÉCRAN DE CONNEXION (01/10) — email + mot de passe, remplace
   l'accès par simple lien.
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.login-logo {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
}

.login-title {
  font-family: var(--round);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 24px;
}

/* Liens absolus vers un autre domaine (ex. "Connectez-vous" -> app.dokle.io
   depuis signup.html à la racine) : sans règle explicite, le navigateur
   retombe sur le bleu/violet par défaut des liens au lieu de la couleur
   de marque utilisée partout ailleurs. */
.login-subtitle a,
.login-subtitle a:visited {
  color: var(--brand);
}

.login-subtitle a:hover {
  color: #b85d47;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.login-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 8px;
}

.login-form input {
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

.login-form input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.login-form button[type="submit"] {
  margin-top: 16px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

.login-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-error {
  font-size: 13px;
  color: var(--danger);
  margin: 4px 0 0;
  min-height: 1em;
}

.team-choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.team-choice p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.team-choice button {
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.team-choice button:hover {
  background: var(--brand-dim);
  border-color: var(--brand);
}
