:root {
  --bg-color: #090d17;
  --surface: #121a2a;
  --text-primary: #ecf1ff;
  --text-muted: #98a4bd;
  --accent: #f1b737;
  --border: rgba(255, 255, 255, 0.1);
  --bubble-user: #1f3259;
  --bubble-bot: #171f31;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body, html {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  /* Empêche le pull-to-refresh chiant sur mobile */
  overscroll-behavior-y: none; 
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  background: radial-gradient(circle at top, #1b2b4d 0%, var(--bg-color) 100%);
}

/* --- HEADER --- */
.glass-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(18, 26, 42, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.header-titles h1 { font-size: 20px; font-weight: 700; }
.header-titles p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* --- CHAT AREA --- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.msg.user { align-self: flex-end; background: var(--bubble-user); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.bot-image { width: 100%; border-radius: 12px; margin-top: 10px; border: 1px solid var(--border); }
.meta { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* --- COMPOSER (Zone de texte) --- */
.glass-composer {
  padding: 16px;
  background: rgba(9, 13, 23, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-top: 1px solid var(--border);
}

.input-group { display: flex; gap: 10px; align-items: flex-end; }
textarea {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  height: 48px;
  max-height: 120px;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* --- BOUTONS --- */
.btn {
  border: none; border-radius: 12px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.btn-send { background: var(--accent); color: #000; padding: 0 20px; height: 48px; }
.btn-send:active { transform: scale(0.95); }
.btn-attach { background: var(--surface); border: 1px solid var(--border); color: white; width: 48px; height: 48px; font-size: 20px; }
.btn-text { background: transparent; color: var(--text-muted); font-size: 13px; }

.toolbar-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
select { background: transparent; color: var(--text-muted); border: none; outline: none; }

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 600px) {
  .msg { max-width: 95%; }
  .hidden-mobile { display: none; } /* Cache la zone drag&drop sur tel */
  .btn-send { padding: 0 16px; }
}
/* --- ANIMATION DE CHARGEMENT --- */
.thinking {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
}
.spin-row {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 13px; margin-bottom: 8px;
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status { color: var(--text-muted); font-size: 13px; }
/* --- SÉLECTEURS MODÈLE ET QUALITÉ --- */
.options-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.select-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
}

.select-wrap select {
  background: transparent;
  color: var(--text-muted);
  border: none;
  outline: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  /* Masque la flèche native moche sur certains navigateurs mobiles */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Ajustement mobile pour prendre toute la largeur */
@media (max-width: 600px) {
  .toolbar-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .options-wrap {
    width: 100%;
    flex-direction: column;
  }
  .select-wrap {
    width: 100%;
  }
  .select-wrap select {
    width: 100%;
  }
  #clearImagesBtn {
    align-self: flex-end;
  }
}