/**
 * BGFIBANK Chatbot - Modern Clean Design
 * Palette : Bleu BGFI var(--primary-dark), Vert sauge var(--gold)
 * Version : 5.0 — Phase 27
 */

:root {
  /* === COULEURS PRIMAIRES BGFI === */
  --primary-darkest: #002244;
  --primary-dark: #003868;
  --primary: #0a5a8a;
  --primary-light: #2a7ab8;
  --primary-lighter: #4a94cc;

  /* === COULEURS SECONDAIRES (Vert sauge) === */
  --secondary-dark: #5d7367;
  --secondary: #7a9182;
  --secondary-light: #c7d4a9;
  --secondary-lighter: #d8e2c4;
  --secondary-lightest: #edf2e4;

  /* === ACCENT VERT BGFI === */
  --gold: #C4D1A6;
  --gold-light: #d4e1b6;
  --gold-dark: #8a9a6e;
  --gold-glow: rgba(196, 209, 166, 0.3);

  /* === COULEURS DE FOND === */
  --bg-body: #f5f7f6;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-muted: #eef1f0;
  --bg-subtle: #f8faf9;

  /* === COULEURS DE TEXTE === */
  --text-primary: #2d3748;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --text-light: #a0aec0;
  --text-inverse: #ffffff;

  /* === BORDURES === */
  --border-light: #e2e8f0;
  --border-default: #cbd5e0;
  --border-dark: #a0aec0;

  /* === ETATS === */
  --success: #48815c;
  --success-light: #68a67d;
  --success-bg: #e6f4ea;
  --warning: #b8860b;
  --warning-light: #d4a017;
  --warning-bg: #fef8e7;
  --error: #9b4444;
  --error-light: #c25858;
  --error-bg: #fce8e8;
  --info: #0a5a8a;
  --info-light: #2a7ab8;
  --info-bg: #e8f0f8;

  /* === OMBRES === */
  --shadow-xs: 0 1px 2px rgba(0, 56, 104, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 56, 104, 0.06), 0 1px 2px rgba(0, 56, 104, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 56, 104, 0.05), 0 2px 4px rgba(0, 56, 104, 0.04);
  --shadow-lg: 0 10px 15px rgba(0, 56, 104, 0.05), 0 4px 6px rgba(0, 56, 104, 0.03);
  --shadow-xl: 0 20px 25px rgba(0, 56, 104, 0.06), 0 8px 10px rgba(0, 56, 104, 0.04);

  /* === GRADIENTS === */
  --gradient-primary: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);

  /* === RAYONS === */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-2xl: 18px;
  --radius-full: 50%;

  /* === TRANSITIONS === */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* === ESPACEMENTS === */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* === GLASS VARIABLES === */
  --glass-bg: rgba(255, 255, 255, 0.12);
  --glass-bg-light: rgba(255, 255, 255, 0.18);
  --glass-border: rgba(255, 255, 255, 0.2);

  /* === CHATBOT SPECIFIQUE === */
  --msg-bot-bg: rgba(255, 255, 255, 0.75);
  --msg-bot-border: rgba(0, 56, 104, 0.12);
  --msg-user-bg: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  --msg-user-text: var(--text-inverse);

  /* Reactions */
  --reaction-like: rgba(72, 129, 92, 0.1);
  --reaction-like-border: rgba(72, 129, 92, 0.3);
  --reaction-dislike: rgba(155, 68, 68, 0.1);
  --reaction-dislike-border: rgba(155, 68, 68, 0.3);
}

/* Scrollbar sobre */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-muted); }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-dark); }

/* Reset et base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(160deg, var(--primary-darkest) 0%, var(--primary-dark) 50%, var(--primary) 100%);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1.6;
  font-weight: 400;
  overflow: hidden;
  padding: 0;
  margin: 0;
  position: relative;
}

/* Container principal */
.chat-container {
  width: 100%;
  max-width: 900px;
  height: 100vh;
  height: 100dvh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
  margin: 0;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.15);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

/* ================================================================
   HEADER — Design premium BGFI
   ================================================================ */
.chat-header {
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0, 56, 104, 0.2);
}

/* Barre subtile dorée en bas du header */
.chat-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-light));
  opacity: 0.8;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex: 1;
}

.bot-avatar-container {
  position: relative;
  flex-shrink: 0;
}

.bot-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: all var(--transition-base);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.bot-avatar:hover {
  border-color: var(--gold-light);
  transform: scale(1.05);
}

.status-indicator {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  border: 2.5px solid var(--primary-dark);
}

.status-indicator.online {
  background: #C4D1A6;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.bot-info {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.bot-info h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.bot-info p {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}

.text-green {
  color: #C4D1A6;
  font-size: 0.45rem;
  filter: drop-shadow(0 0 3px rgba(34, 197, 94, 0.6));
}

.user-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.user-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.logout-button,
.share-button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: var(--space-2);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-base);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.logout-button:hover,
.share-button:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
  transform: translateY(-1px);
}

.share-button {
  background: rgba(255, 255, 255, 0.12);
}

/* Bouton Connexion / Espace client dans le header */
.client-auth-btn {
  width: auto !important;
  height: auto !important;
  padding: 7px 14px !important;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  letter-spacing: 0.01em;
}

.client-auth-btn:hover {
  background: rgba(255, 255, 255, 0.25) !important;
  border-color: var(--gold-light) !important;
  color: #ffffff;
}

.client-auth-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Zone des messages */
.chat-messages {
  flex: 1;
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  overflow-x: hidden;
  background: #f7f8fa;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 56, 104, 0.2);
  border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 56, 104, 0.35);
}

/* Message de bienvenue */
.welcome-message {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-8);
  padding: 0 var(--space-2);
}

.welcome-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(0, 56, 104, 0.1);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  text-align: center;
  box-shadow: var(--glass-shadow);
  width: 100%;
  max-width: 400px;
}

.welcome-card i {
  font-size: 2rem;
  color: var(--primary-dark);
  margin-bottom: var(--space-4);
}

.welcome-card h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Messages */
.message {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  animation: messageSlideIn 0.4s ease-out;
  max-width: 100%;
}

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

.message.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.message-content {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message.user .message-content {
  align-items: flex-end;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.55;
  max-width: 100%;
  overflow-wrap: break-word;
  font-size: 0.938rem;
}

/* Bot message - Clean white with subtle gradient */
.message.bot .message-bubble {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 4px 18px 18px 18px;
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 56, 104, 0.03);
}

/* User message - BGFI gradient */
.message.user .message-bubble {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 8px rgba(0, 56, 104, 0.2);
}

/* === FORMATAGE STRUCTURÉ DES MESSAGES === */

/* Paragraphes */
.message-bubble .chat-paragraph {
  margin: 0 0 0.3rem 0;
  line-height: 1.5;
}

.message-bubble .chat-paragraph:last-child {
  margin-bottom: 0;
}

/* Espace entre blocs */
.message-bubble .chat-spacer {
  height: 0.1rem;
}

/* Texte en gras */
.message-bubble strong {
  font-weight: 600;
  color: var(--primary-dark);
}

.message.user .message-bubble strong {
  color: inherit;
}

/* Texte en italique */
.message-bubble em {
  font-style: italic;
  color: var(--text-secondary);
}

.message.user .message-bubble em {
  color: rgba(255, 255, 255, 0.85);
}

/* === LISTES COMPACTES === */
.message-bubble .chat-list {
  margin: 0.25rem 0;
  padding-left: 0;
  list-style: none;
}

.message-bubble .chat-list:last-child {
  margin-bottom: 0;
}

.message-bubble ul.chat-list li {
  position: relative;
  padding: 0.1rem 0 0.1rem 1.2rem;
  line-height: 1.4;
  font-size: 0.92em;
}

.message-bubble ul.chat-list li::before {
  content: '';
  position: absolute;
  left: 0.15rem;
  top: 0.55rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.7;
}

.message-bubble ol.chat-list {
  counter-reset: chat-counter;
}

.message-bubble ol.chat-list li {
  position: relative;
  padding: 0.1rem 0 0.1rem 1.6rem;
  line-height: 1.4;
  counter-increment: chat-counter;
  font-size: 0.92em;
}

.message-bubble ol.chat-list li::before {
  content: counter(chat-counter);
  position: absolute;
  left: 0;
  top: 0.15rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.message.user .message-bubble ul.chat-list li::before {
  background: rgba(255, 255, 255, 0.8);
}

.message.user .message-bubble ol.chat-list li::before {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Fallback pour les anciennes listes (retro-compat) */
.message-bubble ul:not(.chat-list),
.message-bubble ol:not(.chat-list) {
  margin: 0.2rem 0;
  padding-left: 1.2rem;
}

.message-bubble li {
  margin-bottom: 0.05rem;
  line-height: 1.4;
}

/* Numéros de téléphone cliquables */
.message-bubble .chat-phone {
  font-weight: 500;
  color: var(--primary-dark);
  white-space: nowrap;
}

.message.user .message-bubble .chat-phone {
  color: inherit;
}

/* === TITRES DANS LES REPONSES === */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5 {
  color: var(--primary-dark);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 0.6rem;
  margin-bottom: 0.3rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid rgba(0, 56, 104, 0.15);
}

.message-bubble h1:first-child,
.message-bubble h2:first-child,
.message-bubble h3:first-child,
.message-bubble h4:first-child,
.message-bubble h5:first-child {
  margin-top: 0;
}

.message-bubble h1 {
  font-size: 1.25rem;
  border-bottom-width: 3px;
  border-bottom-color: rgba(0, 56, 104, 0.25);
}

.message-bubble h2 {
  font-size: 1.15rem;
}

.message-bubble h3 {
  font-size: 1.05rem;
}

.message-bubble h4 {
  font-size: 1rem;
  border-bottom: none;
}

.message-bubble h5 {
  font-size: 0.95rem;
  border-bottom: none;
  color: var(--primary);
}

.message.user .message-bubble h1,
.message.user .message-bubble h2,
.message.user .message-bubble h3,
.message.user .message-bubble h4,
.message.user .message-bubble h5 {
  color: inherit;
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

/* === MONTANTS FINANCIERS & POURCENTAGES === */
.message-bubble .chat-amount {
  font-weight: 700;
  color: var(--primary-dark);
  background: linear-gradient(135deg, rgba(0, 56, 104, 0.06), rgba(20, 101, 163, 0.08));
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.message.user .message-bubble .chat-amount {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.message-bubble .chat-percent {
  font-weight: 600;
  color: var(--success);
}

.message.user .message-bubble .chat-percent {
  color: inherit;
}

/* === PAIRES CLÉ-VALEUR COMPACTES (simulations, résumés) === */
.message-bubble .chat-kv-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0;
  padding: 2px 0;
  line-height: 1.4;
  font-size: 0.93em;
}

.message-bubble .chat-kv-label {
  flex-shrink: 0;
}

.message-bubble .chat-kv-sep {
  margin: 0 2px 0 0;
  color: var(--text-secondary);
}

.message-bubble .chat-kv-value {
  flex: 1;
}

/* === LIGNES DE RÉSULTAT (➜ ✅ 💰 📊) === */
.message-bubble .chat-result-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  margin: 3px 0;
  background: linear-gradient(135deg, rgba(0, 56, 104, 0.04), rgba(178, 194, 150, 0.08));
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  font-size: 0.93em;
  line-height: 1.4;
}

.message-bubble .chat-result-line .result-icon {
  flex-shrink: 0;
  font-size: 1em;
}

.message-bubble .chat-result-line .result-text {
  flex: 1;
  min-width: 0;
}

/* === TABLEAUX DANS LES MESSAGES === */
.message-bubble .chat-table-wrapper {
  overflow-x: auto;
  margin: 8px 0;
  border-radius: 8px;
  border: 1px solid rgba(0, 56, 104, 0.12);
}

.message-bubble .chat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
  white-space: nowrap;
}

.message-bubble .chat-table th {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  font-weight: 600;
  padding: 8px 12px;
  text-align: left;
  font-size: 0.9em;
  letter-spacing: 0.02em;
}

.message-bubble .chat-table td {
  padding: 6px 12px;
  border-bottom: 1px solid rgba(0, 56, 104, 0.06);
  color: var(--text-primary);
}

.message-bubble .chat-table tbody tr:nth-child(even) {
  background: rgba(0, 56, 104, 0.02);
}

.message-bubble .chat-table tbody tr:hover {
  background: rgba(0, 56, 104, 0.05);
}

.message.user .message-bubble .chat-table th {
  background: rgba(255, 255, 255, 0.2);
}

.message.user .message-bubble .chat-table td {
  color: inherit;
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* === Styles pour le contenu formate des messages === */

.message-bubble .chat-paragraph {
  margin: 0;
  line-height: 1.6;
}

.message-bubble .list-item {
  display: flex;
  align-items: flex-start;
  margin: 0.4rem 0;
  padding-left: 0.25rem;
  line-height: 1.5;
}

.message-bubble .list-item.numbered .list-number {
  font-weight: 600;
  color: var(--primary-dark);
  min-width: 1.5rem;
  flex-shrink: 0;
}

.message-bubble .list-item.bullet .bullet-point {
  color: #48815c;
  min-width: 1rem;
  flex-shrink: 0;
  font-size: 1.1em;
}

.message.user .message-bubble .list-item.numbered .list-number,
.message.user .message-bubble .list-item.bullet .bullet-point {
  color: inherit;
}

/* Liens */
.message-bubble .chat-link {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: rgba(20, 101, 163, 0.4);
  transition: all 0.2s ease;
}

.message-bubble .chat-link:hover {
  color: var(--primary-dark);
  text-decoration-color: var(--primary-dark);
}

.message.user .message-bubble .chat-link {
  color: rgba(255, 255, 255, 0.95);
  text-decoration-color: rgba(255, 255, 255, 0.5);
}

/* Code inline */
.message-bubble .inline-code {
  background: rgba(0, 56, 104, 0.08);
  color: var(--primary-dark);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.88em;
  border: 1px solid rgba(0, 56, 104, 0.12);
}

.message.user .message-bubble .inline-code {
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
  border-color: rgba(255, 255, 255, 0.3);
}

/* Blocs de code */
.message-bubble .code-block {
  background: var(--primary-darkest);
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.85em;
  overflow-x: auto;
  margin: 0.75rem 0;
  border-left: 4px solid var(--gold);
}

.message-bubble .code-block code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
}

/* Citations */
.message-bubble .chat-quote {
  border-left: 4px solid var(--gold);
  padding: 0.5rem 1rem;
  margin: 0.75rem 0;
  background: rgba(178, 194, 150, 0.06);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-secondary);
}

.message.user .message-bubble .chat-quote {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: rgba(255, 255, 255, 0.5);
  color: inherit;
}

/* Separateurs */
.message-bubble hr {
  border: none;
  border-top: 1px solid rgba(0, 56, 104, 0.15);
  margin: 1rem 0;
}

/* Style pour les infos cles */
.message-bubble .key-info {
  background: linear-gradient(135deg, rgba(0, 56, 104, 0.06) 0%, rgba(178, 194, 150, 0.06) 100%);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0.75rem 0;
  border: 1px solid rgba(0, 56, 104, 0.1);
}

/* Animation pour les nouveaux elements */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
  animation: fadeInUp 0.3s ease-out;
}

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

/* Reactions */
.message-reactions {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-1);
  justify-content: flex-start;
  flex-wrap: wrap;
}

.message.user .message-reactions {
  justify-content: flex-end;
}

.reaction-btn {
  background: #f2f3f5;
  border: none;
  border-radius: 16px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-height: 28px;
  color: var(--text-secondary);
}

.reaction-btn:hover {
  background: #e4e6ea;
  transform: scale(1.05);
}

.reaction-btn.liked {
  background: var(--reaction-like);
  border-color: var(--reaction-like-border);
  color: var(--success);
}

.reaction-btn.disliked {
  background: var(--reaction-dislike);
  border-color: var(--reaction-dislike-border);
  color: var(--error);
}

/* Timestamp */
.message-time {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: var(--space-1);
  white-space: nowrap;
}

/* ================================================================
   FOOTER — Zone de saisie redesignée
   ================================================================ */
.chat-footer {
  padding: var(--space-3) var(--space-5);
  padding-bottom: env(safe-area-inset-bottom, var(--space-3));
  margin-bottom: 8px;
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  max-width: 800px;
  margin: 0 auto;
}

.textarea-wrapper {
  flex: 1;
  position: relative;
  background: var(--bg-subtle);
  border: 2px solid var(--border-light);
  border-radius: 24px;
  transition: all var(--transition-base);
  min-width: 0;
}

.textarea-wrapper:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(20, 101, 163, 0.1);
}

#message-to-send {
  width: 100%;
  min-height: 46px;
  max-height: 120px;
  padding: 12px 20px;
  padding-right: 16px;
  padding-bottom: 26px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  color: var(--text-primary);
  overflow-y: auto;
}

#message-to-send::placeholder {
  color: var(--text-light);
  font-weight: 400;
}

.char-counter {
  position: absolute;
  bottom: 6px;
  right: var(--space-3);
  font-size: 0.6rem;
  color: var(--text-light);
  background: transparent;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: 1;
  opacity: 0.6;
}

/* Send button — gradient BGFI */
.send-btn {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 56, 104, 0.25);
}

.send-btn:not(:disabled):hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(0, 56, 104, 0.35);
}

.send-btn:not(:disabled):active {
  transform: scale(0.94);
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: var(--border-default);
  box-shadow: none;
}

.send-btn i {
  font-size: 0.95rem;
}

/* Typing indicator (see below for modern style) */

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--primary-dark);
  animation: typingPulse 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 36, 76, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: all var(--transition-slow);
  backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  background: #ffffff;
  border-radius: 20px;
  padding: var(--space-8);
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
  margin: var(--space-4);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 56, 104, 0.15);
  border-top: 4px solid var(--primary-dark);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-4);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Modal de partage - Full glassmorphism */
.share-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-slow);
  padding: var(--space-4);
}

.share-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.share-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 36, 76, 0.5);
  backdrop-filter: blur(4px);
}

.share-modal-content {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  position: relative;
  z-index: 1;
  animation: modalSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.share-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid #eef0f2;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.share-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.close-modal-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-inverse);
}

.close-modal-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.share-modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

.share-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.share-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1.5px solid transparent;
  background: #f7f8fa;
}

.share-option:hover {
  background: #eef0f4;
  transform: translateY(-1px);
  border-color: var(--primary);
}

.share-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.4rem;
}

.share-icon.whatsapp { background: var(--secondary); }
.share-icon.telegram { background: var(--primary); }
.share-icon.facebook { background: var(--primary-dark); }
.share-icon.twitter { background: var(--primary-light); }
.share-icon.linkedin { background: var(--primary-dark); }
.share-icon.email { background: var(--gold); }
.share-icon.copy { background: var(--text-secondary); }
.share-icon.sms { background: var(--success); }

.share-option span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
}

.share-preview {
  border: 1px solid rgba(0, 56, 104, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  background: rgba(248, 250, 252, 0.8);
  backdrop-filter: blur(4px);
}

.share-preview h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.share-preview-text {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 56, 104, 0.08);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.4;
}

.share-options-toggle {
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.toggle-option input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-sm);
  position: relative;
  transition: all var(--transition-base);
  background: var(--bg-surface);
}

.toggle-option input[type="checkbox"]:checked + .checkmark {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.toggle-option input[type="checkbox"]:checked + .checkmark::after {
  content: "\2713";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
}

/* === QUICK REPLIES === */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: var(--space-3) 0;
  padding-left: 40px;
}

.quick-reply-btn {
  background: #ffffff;
  border: 1.5px solid var(--primary);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  line-height: 1.3;
}

.quick-reply-btn:hover {
  background: var(--primary);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 56, 104, 0.2);
}

.quick-reply-btn:active {
  transform: scale(0.97);
}

/* Form Progress */
.form-progress {
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0, 56, 104, 0.08);
  margin-left: 40px;
}

.form-progress .progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.form-progress .progress-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.form-progress .progress-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.form-progress .progress-bar-container {
  height: 6px;
  background: rgba(0, 56, 104, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.form-progress .progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-dark) 0%, var(--gold) 100%);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* Ticket Card - Glass premium */
.ticket-card {
  margin: var(--space-4) 0;
  margin-left: 40px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(178, 194, 150, 0.2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 56, 104, 0.1);
  max-width: 400px;
}

.ticket-card-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ticket-card-header .ticket-icon {
  font-size: 1.5rem;
}

.ticket-card-header .ticket-title {
  color: white;
  font-weight: 600;
  font-size: 1rem;
}

.ticket-card-body {
  padding: var(--space-5);
}

.ticket-number {
  text-align: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px dashed rgba(0, 56, 104, 0.2);
}

.ticket-number .ticket-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.ticket-number .ticket-code {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
  font-family: 'SF Mono', Monaco, monospace;
  letter-spacing: 1px;
}

.ticket-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ticket-details .ticket-detail {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
  color: var(--text-primary);
}

.ticket-details .detail-icon {
  font-size: 1rem;
}

.ticket-card-footer {
  padding: var(--space-3) var(--space-4);
  background: rgba(248, 250, 252, 0.8);
  border-top: 1px solid rgba(0, 56, 104, 0.08);
}

.copy-ticket-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid var(--primary-dark);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  color: var(--primary-dark);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.copy-ticket-btn:hover {
  background: var(--primary-dark);
  color: white;
}

/* Warning message style */
.warning-message .message-bubble {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
  border: 1px solid #cbd5e1 !important;
  border-left: 4px solid #94a3b8 !important;
}

/* Error message style */
.error-message .message-bubble {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%) !important;
  border: 1px solid #fecaca !important;
  border-left: 4px solid #ef4444 !important;
}

/* ==============================
   SPLASH SCREEN
   ============================== */

.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--primary-darkest) 0%, var(--primary-dark) 50%, var(--primary) 100%);
  overflow: hidden;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

/* Floating orbs in splash */
.splash-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.splash-orb-1 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(20, 101, 163, 0.25) 0%, transparent 70%);
  top: -50px;
  right: -50px;
  animation: floatOrb1 18s ease-in-out infinite;
}

.splash-orb-2 {
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(20, 101, 163, 0.2) 0%, transparent 70%);
  bottom: -40px;
  left: -40px;
  animation: floatOrb2 22s ease-in-out infinite;
}

.splash-orb-3 {
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: floatOrb1 15s ease-in-out infinite reverse;
}

/* Splash content */
.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
  z-index: 1;
}

.splash-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: splashLogoEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0;
  transform: scale(0.6);
}

@keyframes splashLogoEnter {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.splash-title {
  text-align: center;
  animation: splashFadeIn 0.8s ease-out 0.4s forwards;
  opacity: 0;
}

.splash-title h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: white;
  margin: 0 0 6px;
  letter-spacing: 0.5px;
}

.splash-title p {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  font-weight: 400;
}

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

/* Divider line */
.splash-gold-line {
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  border-radius: 2px;
  animation: splashFadeIn 0.6s ease-out 0.7s forwards, lineShimmer 2s ease-in-out 1.3s infinite;
  opacity: 0;
}

@keyframes lineShimmer {
  0%, 100% { opacity: 1; width: 60px; }
  50% { opacity: 0.7; width: 80px; }
}

/* Splash loading dots */
.splash-loader {
  display: flex;
  gap: 8px;
  animation: splashFadeIn 0.6s ease-out 0.9s forwards;
  opacity: 0;
}

.splash-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation: splashDotPulse 1.4s ease-in-out infinite;
}

.splash-dot:nth-child(1) { animation-delay: 0s; }
.splash-dot:nth-child(2) { animation-delay: 0.2s; }
.splash-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes splashDotPulse {
  0%, 60%, 100% {
    transform: scale(1);
    background: rgba(255, 255, 255, 0.4);
  }
  30% {
    transform: scale(1.3);
    background: rgba(255, 255, 255, 0.9);
  }
}

/* Splash CTA button */
.splash-cta {
  padding: 14px 36px;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  border-radius: 28px;
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: splashFadeIn 0.6s ease-out 1.2s forwards;
  opacity: 0;
  letter-spacing: 0.3px;
}

.splash-cta:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
}

.splash-cta:active {
  transform: scale(0.97);
}

/* === SPLASH BUTTONS (Nouvelle / Continuer) === */
.splash-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
  max-width: 300px;
}

.splash-cta-secondary {
  background: transparent !important;
  border: 1.5px solid rgba(255, 255, 255, 0.3) !important;
  font-weight: 500;
  font-size: 0.88rem;
  opacity: 0;
  animation: splashFadeIn 0.6s ease-out 1.5s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.splash-cta-secondary:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
}

.splash-cta-secondary i {
  font-size: 0.85rem;
}

/* === RESTORED MESSAGES (no entrance animation) === */
.message.restored {
  animation: none;
}

/* === MESSAGE COUNT INDICATOR === */
.message-count-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  margin: 8px auto;
  font-size: 0.75rem;
  color: #64748b;
  background: rgba(241, 245, 249, 0.9);
  border-radius: 12px;
  width: fit-content;
  gap: 6px;
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.message-count-indicator.warning {
  color: #d97706;
  background: #fffbeb;
  border-color: #fcd34d;
}

.message-count-indicator.limit {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}

/* === CONVERSATION SEPARATOR === */
.conversation-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  padding: 0 8px;
}

.conversation-separator .separator-line {
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.conversation-separator .separator-text {
  font-size: 0.72rem;
  color: #94a3b8;
  white-space: nowrap;
  padding: 2px 10px;
  background: #f7f8fa;
  border-radius: 10px;
}

/* === CONVERSATION LIMIT WARNING === */
.conversation-limit-warning {
  margin: 16px 0;
  padding: 16px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.conversation-limit-warning p {
  font-size: 0.9rem;
  color: #92400e;
  margin-bottom: 12px;
  line-height: 1.5;
}

.conversation-limit-warning .new-conversation-btn {
  padding: 10px 24px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.conversation-limit-warning .new-conversation-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 56, 104, 0.3);
}

/* ================================================================
   RESPONSIVE — Breakpoints optimisés
   ================================================================ */

/* Tablet landscape (1024px and below) */
@media screen and (max-width: 1024px) {
  .chat-container {
    max-width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .share-modal-content {
    max-width: 90vw;
  }
}

/* Tablet portrait (768px and below) */
@media screen and (max-width: 768px) {
  .chat-container {
    box-shadow: none;
  }

  .chat-header {
    padding: var(--space-3) var(--space-4);
  }

  .bot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .bot-info h2 {
    font-size: 1rem;
  }

  .bot-info p {
    font-size: 0.75rem;
  }

  .user-name {
    display: none;
  }

  .chat-messages {
    padding: var(--space-3) var(--space-3);
  }

  .message-content {
    max-width: 88%;
  }

  .message-bubble {
    padding: 10px 14px;
    font-size: 0.92rem;
  }

  .chat-footer {
    padding: var(--space-3) var(--space-3);
  }

  #message-to-send {
    font-size: 0.95rem;
    padding: 10px 16px;
    padding-bottom: 24px;
  }

  .send-btn {
    width: 44px;
    height: 44px;
  }

  .quick-replies {
    padding-left: 0;
  }

  .quick-reply-btn {
    font-size: 0.82rem;
    padding: 6px 12px;
  }

  .ticket-card {
    margin-left: 0;
    max-width: 100%;
  }

  .form-progress {
    margin-left: 0;
  }

  .splash-logo {
    width: 80px;
    height: 80px;
  }

  .splash-title h1 {
    font-size: 1.3rem;
  }

  .splash-buttons {
    max-width: 100%;
    padding: 0 20px;
  }

  .splash-cta,
  .splash-cta-secondary {
    width: 100%;
  }

  .share-modal-content {
    max-width: 95vw;
    max-height: 85vh;
    border-radius: var(--radius-xl);
  }

  .share-options {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
  }

  .share-modal-body {
    padding: var(--space-4);
  }
}

/* Mobile (480px and below) */
@media screen and (max-width: 480px) {
  .chat-header {
    padding: var(--space-3) var(--space-3);
  }

  .header-left {
    gap: var(--space-2);
  }

  .bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .bot-info h2 {
    font-size: 0.95rem;
  }

  .bot-info p {
    font-size: 0.7rem;
  }

  .client-auth-btn {
    padding: 6px 10px !important;
    max-width: 110px;
    font-size: 0.7rem;
  }

  .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.7rem;
    border-radius: 10px;
  }

  .logout-button,
  .share-button {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .message-content {
    max-width: 92%;
  }

  .message-bubble {
    font-size: 0.9rem;
    padding: 8px 12px;
  }

  .message-avatar {
    width: 26px;
    height: 26px;
  }

  .welcome-card {
    padding: var(--space-5);
  }

  .welcome-card h3 {
    font-size: 1.05rem;
  }

  .welcome-card p {
    font-size: 0.88rem;
  }

  .share-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .share-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .splash-logo {
    width: 70px;
    height: 70px;
  }

  .splash-title h1 {
    font-size: 1.15rem;
  }

  .splash-title p {
    font-size: 0.85rem;
  }

  .splash-cta {
    padding: 12px 32px;
    font-size: 0.9rem;
  }

  /* Footer compact sur mobile */
  .chat-footer {
    padding: var(--space-2) var(--space-3);
  }

  .input-container {
    gap: var(--space-2);
  }

  .textarea-wrapper {
    border-radius: 20px;
  }

  .send-btn {
    width: 42px;
    height: 42px;
  }

  .send-btn i {
    font-size: 0.9rem;
  }

  #message-to-send {
    min-height: 42px;
    padding: 10px 14px;
    padding-bottom: 22px;
    font-size: 0.93rem;
  }

  .char-counter {
    font-size: 0.55rem;
    bottom: 4px;
  }

  .ticket-number .ticket-code {
    font-size: 1.2rem;
  }

  .ticket-card-body {
    padding: var(--space-4);
  }
}

/* Very small screens (360px and below) */
@media screen and (max-width: 360px) {
  .chat-header {
    padding: var(--space-2) var(--space-3);
  }

  .header-left {
    gap: var(--space-1);
  }

  .bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .bot-info h2 {
    font-size: 0.85rem;
  }

  .bot-info p {
    font-size: 0.65rem;
  }

  .status-indicator {
    width: 8px;
    height: 8px;
  }

  /* Client auth button: icon only on very small screens */
  .client-auth-btn span {
    display: none;
  }
  .client-auth-btn {
    padding: 6px !important;
    width: 32px !important;
    height: 32px !important;
    max-width: none;
  }

  .user-controls {
    gap: 3px;
  }

  .user-avatar {
    width: 26px;
    height: 26px;
    font-size: 0.6rem;
  }

  .logout-button,
  .share-button {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .message-bubble {
    font-size: 0.88rem;
    padding: var(--space-2);
  }

  .quick-reply-btn {
    font-size: 0.78rem;
    padding: 4px 10px;
  }

  .send-btn {
    width: 38px;
    height: 38px;
  }

  #message-to-send {
    min-height: 38px;
    font-size: 0.9rem;
  }
}

/* Support pour les appareils avec encoche (iPhone X+) */
@supports (padding: max(0px)) {
  .chat-footer {
    padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
  }
}

/* Typing indicator modern */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 10px 16px;
  background: #ffffff;
  border: 1px solid #e8edf2;
  border-radius: 4px 18px 18px 18px;
  margin-bottom: var(--space-4);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Animations */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
