/* ══════════════════════════════════════════════════════
   AI Tutor — Anglais Pratique Online
   Thème : CLAIR (compatible avec le nouveau design)
   ══════════════════════════════════════════════════════ */

/* ── Page background ───────────────────────────────── */
body { background: #f7f7f7; }

/* ── Header de la page ─────────────────────────────── */
.tutor-page-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
}
.tutor-page-header h1 {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: .4rem;
}
.tutor-page-header h1 span { color: #58CC02; }
.tutor-page-header > p {
  color: #666;
  font-size: .92rem;
  margin-bottom: 1rem;
}

/* Feature chips */
.feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  margin-top: .75rem;
}
.feature-chip {
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: .3rem .85rem;
  font-size: .78rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.feature-chip span { color: #333; font-weight: 600; }

/* ── Wrapper principal ─────────────────────────────── */
.tutor-wrapper {
  max-width: 860px;
  margin: 1.5rem auto 4rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Carte chat ────────────────────────────────────── */
.tutor-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

/* ── Toolbar (modes + niveau) ─────────────────────── */
.tutor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  padding: .9rem 1.2rem;
  background: #fafafa;
  border-bottom: 1px solid #ededed;
}
.tutor-toolbar-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #aaa;
}
.mode-btn {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .75rem;
  border-radius: 20px;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #666;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.mode-btn:hover { background: #f0f0f0; color: #333; }
.mode-btn.active {
  background: #1a1a2e;
  border-color: #1a1a2e;
  color: #fff;
}
.mode-btn.active[data-mode="grammar"]       { background: #58CC02; border-color: #46A302; }
.mode-btn.active[data-mode="pronunciation"] { background: #FF9600; border-color: #E08600; }
.mode-btn.active[data-mode="quiz"]          { background: #1CB0F6; border-color: #0A91D1; }
.mode-btn.active[data-mode="lesson"]        { background: #9C27B0; border-color: #7B1FA2; }

.tutor-toolbar-sep {
  width: 1px;
  height: 22px;
  background: #e5e5e5;
  margin: 0 .25rem;
}

.level-select {
  padding: .35rem .65rem;
  border-radius: 20px;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #444;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.level-select:focus { border-color: #1CB0F6; }

/* ── Suggestions rapides ───────────────────────────── */
.quick-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .65rem 1.2rem;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}
.quick-btn {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  color: #555;
  font-size: .76rem;
  padding: .28rem .7rem;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-family: inherit;
}
.quick-btn:hover { background: #f0f8ff; border-color: #1CB0F6; color: #0A91D1; }

/* ── Fenêtre de chat ───────────────────────────────── */
.chat-window {
  height: 440px;
  overflow-y: auto;
  padding: 1.2rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  background: #fff;
  scroll-behavior: smooth;
}
.chat-window::-webkit-scrollbar { width: 4px; }
.chat-window::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* ── Messages ──────────────────────────────────────── */
.msg {
  display: flex;
  gap: .6rem;
  max-width: 88%;
  animation: msgIn .25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.bot  { align-self: flex-start; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg.bot  .msg-avatar { background: #1a1a2e; }
.msg.user .msg-avatar { background: #58CC02; }

.msg-body {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.msg-bubble {
  padding: .75rem 1rem;
  border-radius: 14px;
  font-size: .88rem;
  line-height: 1.65;
  max-width: 100%;
  word-break: break-word;
}
.msg.bot .msg-bubble {
  background: #f7f7f7;
  border: 1px solid #e8e8e8;
  border-radius: 4px 14px 14px 14px;
  color: #333;
}
.msg.user .msg-bubble {
  background: #1a1a2e;
  border-radius: 14px 4px 14px 14px;
  color: #fff;
  text-align: left;
}

/* Markdown dans bulles bot */
.msg.bot .msg-bubble strong { color: #1a1a2e; }
.msg.bot .msg-bubble em     { color: #666; font-style: italic; }
.msg.bot .msg-bubble code   { background: #e8e8e8; padding: .1rem .35rem; border-radius: 4px; font-size: .83rem; font-family: monospace; color: #d63031; }
.msg.bot .msg-bubble h3     { font-size: .92rem; font-weight: 700; margin: .6rem 0 .3rem; color: #1a1a2e; }
.msg.bot .msg-bubble ul     { margin: .4rem 0 .4rem 1.2rem; }
.msg.bot .msg-bubble li     { margin-bottom: .2rem; color: #444; }
.msg.bot .msg-bubble p      { margin-bottom: .4rem; }
.msg.bot .msg-bubble hr     { border: none; border-top: 1px solid #e8e8e8; margin: .6rem 0; }

/* Bouton audio */
.msg-audio-btn {
  align-self: flex-start;
  background: none;
  border: 1px solid #e0e0e0;
  color: #888;
  border-radius: 20px;
  padding: .18rem .6rem;
  font-size: .72rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .3rem;
  transition: all .15s;
  font-family: inherit;
}
.msg-audio-btn:hover { background: #f0f0f0; color: #555; border-color: #bbb; }
.msg-audio-btn:disabled { opacity: .4; cursor: default; }

/* Indicateur de frappe */
.typing-indicator {
  display: flex;
  gap: .3rem;
  align-items: center;
  padding: .7rem 1rem;
  background: #f7f7f7;
  border: 1px solid #e8e8e8;
  border-radius: 4px 14px 14px 14px;
  width: fit-content;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #aaa;
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

/* ── Zone de saisie ────────────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .8rem 1rem;
  background: #fff;
  border-top: 1px solid #ededed;
}
.chat-textarea {
  flex: 1;
  background: #f7f7f7;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  color: #333;
  font-size: .9rem;
  font-family: inherit;
  padding: .65rem .9rem;
  resize: none;
  max-height: 140px;
  overflow-y: auto;
  outline: none;
  transition: border-color .15s;
  line-height: 1.5;
}
.chat-textarea::placeholder { color: #aaa; }
.chat-textarea:focus { border-color: #1CB0F6; background: #fff; }

.input-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all .15s;
  flex-shrink: 0;
}
.mic-btn {
  background: #fff3e0;
  color: #FF9600;
  border: 1px solid #FFE0B2;
}
.mic-btn:hover  { background: #ffe0b2; }
.mic-btn.active { background: #FF9600; color: #fff; animation: micPulse 1s infinite; }
@keyframes micPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,150,0,.4); }
  50%     { box-shadow: 0 0 0 8px rgba(255,150,0,.0); }
}
.send-btn {
  background: #58CC02;
  color: #fff;
  border-bottom: 3px solid #46A302;
}
.send-btn:hover   { background: #64d800; transform: translateY(-1px); }
.send-btn:active  { transform: translateY(1px); border-bottom-width: 1px; }
.send-btn:disabled { opacity: .4; cursor: default; transform: none !important; }

/* ── Status bar ────────────────────────────────────── */
.tutor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45rem 1rem;
  background: #fafafa;
  border-top: 1px solid #ededed;
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .72rem;
  color: #888;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #58CC02;
  animation: statusPulse 2s infinite;
}
@keyframes statusPulse {
  0%,100% { opacity: 1; }
  50%     { opacity: .4; }
}
.clear-btn {
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  color: #aaa;
  font-size: .72rem;
  padding: .2rem .6rem;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.clear-btn:hover { border-color: #FF4B4B; color: #FF4B4B; background: #fff5f5; }

/* ── Notice configuration ──────────────────────────── */
.config-notice {
  background: #fff8e1;
  border: 1px solid #FFE082;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  font-size: .82rem;
  color: #555;
}
.config-notice strong { color: #E65100; }
.config-notice code {
  background: #f0f0f0;
  padding: .1rem .4rem;
  border-radius: 4px;
  font-size: .8rem;
  color: #d63031;
}
.config-notice a { color: #1CB0F6; font-weight: 600; }

/* Curseur clignotant pendant le streaming */
@keyframes cursorBlink { 0%,100%{opacity:1;} 50%{opacity:0;} }
.cursor-blink { animation: cursorBlink .6s infinite; font-size: .8em; color: #aaa; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 600px) {
  .chat-window { height: 360px; }
  .tutor-toolbar { gap: .3rem; }
  .mode-btn { font-size: .72rem; padding: .28rem .55rem; }
  .msg { max-width: 96%; }
  .tutor-toolbar-sep { display: none; }
}
