/* ══════════════════════════════════════════════════════════
   BIG-FRONT AI  —  STYLE.CSS v4.0
   Ultra Modern Chat Interface — Groq Edition
   BEN CHARIF Ben Amir Abdou | Bangoi Hambou 🇰🇲
══════════════════════════════════════════════════════════ */

/* ─── RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:       #07080f;
  --bg-card:       #0e1120;
  --bg-card2:      #131729;
  --bg-sidebar:    #0a0c18;
  --accent1:       #7c6ffb;
  --accent2:       #ff6ad2;
  --accent3:       #00e5ff;
  --accent-grad:   linear-gradient(135deg,#7c6ffb 0%,#ff6ad2 60%,#ff9248 100%);
  --user-bubble:   linear-gradient(135deg,#7c6ffb 0%,#a855f7 100%);
  --ai-bubble:     #141828;
  --text-main:     #f0f2ff;
  --text-sub:      #8b8fa8;
  --text-hint:     #555975;
  --border:        rgba(124,111,251,.18);
  --border-light:  rgba(255,255,255,.06);
  --glow-purple:   0 0 40px rgba(124,111,251,.35);
  --glow-pink:     0 0 40px rgba(255,106,210,.3);
  --radius-xl:     20px;
  --radius-lg:     16px;
  --radius-md:     12px;
  --radius-sm:     8px;
  --transition:    .22s cubic-bezier(.4,0,.2,1);
  --sidebar-w:     300px;
}

[data-theme="light"] {
  --bg-deep:      #f0f2ff;
  --bg-card:      #fff;
  --bg-card2:     #f7f8ff;
  --bg-sidebar:   #fff;
  --ai-bubble:    #f0f2ff;
  --text-main:    #1a1d30;
  --text-sub:     #555975;
  --text-hint:    #9a9db8;
  --border:       rgba(124,111,251,.15);
  --border-light: rgba(0,0,0,.06);
}

html, body { height: 100%; font-family: 'Inter', -apple-system, sans-serif; background: var(--bg-deep); color: var(--text-main); overflow: hidden; }

/* ─── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,111,251,.4); border-radius: 99px; }

/* ─── PARTICLES ──────────────────────────────────────────── */
.bg-particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-particles .particle { position: absolute; border-radius: 50%; opacity: 0; animation: floatParticle linear infinite; }
@keyframes floatParticle {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: .6; }
  90%  { opacity: .3; }
  100% { transform: translateY(-10vh) scale(1.2); opacity: 0; }
}

/* ─── APP WRAPPER ────────────────────────────────────────── */
.app-wrapper { position: relative; display: flex; height: 100vh; z-index: 1; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w); height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 0; flex-shrink: 0;
  transition: transform var(--transition); z-index: 100;
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 0 20px 24px; border-bottom: 1px solid var(--border-light); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--accent-grad); display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff; box-shadow: var(--glow-purple); }
.logo-text { font-size: 20px; font-weight: 800; background: var(--accent-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.logo-text span { font-weight: 400; }
.sidebar-close { display: none; background: none; border: none; color: var(--text-sub); font-size: 18px; cursor: pointer; padding: 6px; }

.user-card { margin: 20px 16px; background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: flex; align-items: center; gap: 12px; }
.user-avatar-wrap { position: relative; flex-shrink: 0; }
.user-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-grad); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: #fff; }
.user-flag { position: absolute; bottom: -2px; right: -4px; font-size: 14px; }
.user-name { font-size: 12px; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-village { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.user-village i { color: var(--accent1); margin-right: 3px; }

.sidebar-nav { padding: 8px 12px 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-md); color: var(--text-sub); text-decoration: none; font-size: 14px; font-weight: 500; transition: var(--transition); cursor: pointer; margin-bottom: 2px; }
.nav-item:hover { background: var(--border-light); color: var(--text-main); }
.nav-item.active { background: rgba(124,111,251,.15); color: var(--accent1); }
.nav-item i { width: 18px; font-size: 15px; }

/* ── HISTORIQUE CONVERSATIONS ────────────────────────────── */
.conv-history-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}
.conv-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.conv-history-header i { color: var(--accent1); margin-right: 5px; }
.conv-clear-all {
  background: none; border: none;
  color: var(--text-hint);
  font-size: 13px; cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: var(--transition);
}
.conv-clear-all:hover { color: #ef4444; background: rgba(239,68,68,.1); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}
.conv-empty {
  font-size: 12px;
  color: var(--text-hint);
  text-align: center;
  padding: 20px 0;
  font-style: italic;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-md);
  padding: 0 4px 0 0;
  margin-bottom: 2px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}
.conv-item:hover { background: var(--border-light); }
.conv-item.active { background: rgba(124,111,251,.12); }
.conv-item.active .conv-title { color: var(--accent1); }

.conv-item-body {
  flex: 1;
  min-width: 0;
  padding: 8px 4px 8px 10px;
  cursor: pointer;
}
.conv-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
}
.conv-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.conv-date {
  font-size: 10px;
  color: var(--text-hint);
  white-space: nowrap;
  flex-shrink: 0;
}
.conv-preview {
  font-size: 11px;
  color: var(--text-hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 195px;
}

.conv-item-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}
.conv-item:hover .conv-item-actions { display: flex; }
.conv-action-btn {
  width: 26px; height: 26px;
  background: none; border: none;
  color: var(--text-hint);
  font-size: 11px;
  cursor: pointer;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.conv-action-btn:hover { background: rgba(239,68,68,.15); color: #ef4444; }

.model-selector { padding: 16px 16px 0; }
.selector-label { font-size: 11px; color: var(--text-hint); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 5px; }
.model-select { width: 100%; background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-main); padding: 10px 12px; font-size: 13px; font-family: inherit; cursor: pointer; outline: none; appearance: none; transition: var(--transition); }
.model-select:hover { border-color: var(--accent1); }

.sidebar-footer { padding: 12px 16px 0; }
.version-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(124,111,251,.15); border: 1px solid var(--accent1); color: var(--accent1); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 99px; margin-bottom: 8px; }
.footer-note { font-size: 11px; color: var(--text-hint); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }

/* ══════════════════════════════════════════════════════════
   MAIN CHAT
══════════════════════════════════════════════════════════ */
.chat-main { flex: 1; display: flex; flex-direction: column; height: 100%; min-width: 0; position: relative; }

/* ─── TOPBAR ─────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: rgba(14,17,32,.9); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border); flex-shrink: 0; z-index: 10; }
.menu-btn { background: none; border: none; color: var(--text-sub); font-size: 20px; cursor: pointer; padding: 6px 8px; border-radius: 8px; transition: var(--transition); display: none; }
.menu-btn:hover { background: var(--border-light); color: var(--text-main); }
.topbar-center { flex: 1; display: flex; align-items: center; gap: 12px; }
.ai-avatar-wrap { position: relative; flex-shrink: 0; }
.ai-avatar-img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent1); box-shadow: var(--glow-purple); transition: transform .3s; }
.ai-avatar-img:hover { transform: scale(1.08); }
.online-dot { position: absolute; bottom: 1px; right: 1px; width: 10px; height: 10px; background: #22c55e; border-radius: 50%; border: 2px solid var(--bg-deep); animation: pulseDot 2s infinite; }
@keyframes pulseDot { 0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.5); } 50% { box-shadow: 0 0 0 5px rgba(34,197,94,0); } }
.ai-name { font-size: 17px; font-weight: 800; background: var(--accent-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.ai-badge { font-size: 10px; font-weight: 700; background: var(--accent-grad); -webkit-text-fill-color: #fff; padding: 2px 6px; border-radius: 4px; vertical-align: middle; }
.ai-status { font-size: 12px; color: #22c55e; display: flex; align-items: center; gap: 6px; }
.pulse-dot { display: inline-block; width: 6px; height: 6px; background: #22c55e; border-radius: 50%; animation: pulseDot 1.5s infinite; }
.topbar-actions { display: flex; gap: 8px; }
.action-btn { width: 36px; height: 36px; background: var(--border-light); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-sub); font-size: 14px; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.action-btn:hover { background: rgba(124,111,251,.2); color: var(--accent1); }

/* ─── DOC BANNER ──────────────────────────────────────────── */
.doc-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  background: rgba(124,111,251,.1);
  border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--accent1);
  flex-shrink: 0;
  animation: slideDown .3s ease;
}
.doc-banner.hidden { display: none; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.doc-banner-icon { font-size: 16px; }
#docName { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#docRemove { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3); color: #ef4444; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 5px; font-family: inherit; }
#docRemove:hover { background: rgba(239,68,68,.25); }

/* ─── CHAT CONTAINER ─────────────────────────────────────── */
.chat-container { flex: 1; overflow-y: auto; padding: 24px 20px 16px; display: flex; flex-direction: column; position: relative; }

/* ─── WELCOME SCREEN ──────────────────────────────────────── */
.welcome-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 16px; animation: fadeInUp .6s ease; }
.welcome-avatar-wrap { position: relative; margin-bottom: 28px; }
.welcome-avatar { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent1); box-shadow: var(--glow-purple), 0 0 60px rgba(255,106,210,.3); animation: floatAvatar 4s ease-in-out infinite; }
.welcome-glow { position: absolute; inset: -8px; border-radius: 50%; background: var(--accent-grad); opacity: .2; filter: blur(16px); animation: glowPulse 3s ease-in-out infinite; }
@keyframes floatAvatar { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes glowPulse { 0%,100% { opacity: .2; transform: scale(1); } 50% { opacity: .4; transform: scale(1.1); } }
.welcome-title { font-size: clamp(22px,4vw,30px); font-weight: 800; margin-bottom: 10px; }
.welcome-title span { background: var(--accent-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.welcome-sub { color: var(--text-sub); font-size: 15px; margin-bottom: 18px; }
.user-welcome-tag { background: rgba(124,111,251,.1); border: 1px solid var(--border); border-radius: 99px; padding: 8px 20px; font-size: 13px; color: var(--text-sub); margin-bottom: 32px; }
.user-welcome-tag strong { color: var(--accent1); }
.user-welcome-tag em { color: var(--accent2); }
.suggestions-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 600px; }
.suggestion-chip { background: var(--bg-card); border: 1px solid var(--border); border-radius: 99px; padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text-sub); cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 7px; font-family: inherit; }
.suggestion-chip i { color: var(--accent1); }
.suggestion-chip:hover { background: rgba(124,111,251,.12); border-color: var(--accent1); color: var(--text-main); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(124,111,251,.2); }

/* ─── MESSAGES LIST ──────────────────────────────────────── */
.messages-list { display: flex; flex-direction: column; gap: 20px; }
.messages-list:empty { display: none; }

/* ─── MESSAGE ROWS ───────────────────────────────────────── */
.msg-row { display: flex; align-items: flex-end; gap: 10px; animation: fadeInUp .35s ease; max-width: 780px; }
.msg-row.user { flex-direction: row-reverse; align-self: flex-end; }
.msg-row.ai   { align-self: flex-start; }
.msg-row.system { align-self: center; width: 100%; max-width: 100%; }

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

/* Avatar */
.msg-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; overflow: hidden; border: 2px solid var(--border); }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-avatar.user-av { background: var(--accent-grad); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; }
.ai-av-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 18px; background: var(--bg-card2); }

/* Bubble container */
.msg-content { max-width: calc(100% - 50px); display: flex; flex-direction: column; gap: 4px; }
.msg-row.user .msg-content { align-items: flex-end; }
.msg-row.ai   .msg-content { align-items: flex-start; }

/* Bubble */
.msg-bubble { padding: 12px 16px; border-radius: 18px; font-size: 14.5px; line-height: 1.65; max-width: 100%; word-break: break-word; position: relative; }
.msg-row.user .msg-bubble { background: var(--user-bubble); color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 4px 20px rgba(124,111,251,.35); }
.msg-row.ai   .msg-bubble { background: var(--ai-bubble); color: var(--text-main); border: 1px solid var(--border); border-bottom-left-radius: 4px; box-shadow: 0 4px 20px rgba(0,0,0,.2); }

/* Streaming bubble */
.msg-bubble.streaming { min-width: 60px; }
.cursor-blink { display: inline-block; width: 2px; height: 16px; background: var(--accent1); vertical-align: middle; margin-left: 2px; animation: cursorBlink .7s infinite; border-radius: 1px; }
@keyframes cursorBlink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Code blocks */
.msg-bubble pre { position: relative; background: rgba(0,0,0,.5); border: 1px solid var(--border); border-radius: 10px; padding: 36px 14px 14px; margin-top: 10px; overflow-x: auto; font-size: 13px; }
.msg-bubble code { font-family: 'Courier New', monospace; font-size: 13px; background: rgba(124,111,251,.15); padding: 2px 6px; border-radius: 4px; }
.msg-bubble pre code { background: none; padding: 0; color: #c9d1d9; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; opacity: .9; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 6px 0; }
.msg-bubble li { margin-bottom: 4px; }

.code-copy-btn { position: absolute; top: 8px; right: 8px; background: rgba(124,111,251,.2); border: 1px solid var(--border); border-radius: 6px; color: var(--text-sub); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); font-size: 12px; }
.code-copy-btn:hover { background: rgba(124,111,251,.4); color: #fff; }

/* Reactions */
.msg-reactions { display: flex; gap: 6px; margin-top: 3px; }
.reaction-btn { background: none; border: none; cursor: pointer; padding: 3px 8px; border-radius: 8px; font-size: 13px; color: var(--text-hint); transition: var(--transition); font-family: inherit; }
.reaction-btn:hover { background: var(--border-light); color: var(--accent1); }
.msg-time { font-size: 10px; color: var(--text-hint); }

/* ─── DOC LOADED CARD ─────────────────────────────────────── */
.doc-loaded-card {
  display: flex; align-items: center; gap: 14px;
  background: rgba(124,111,251,.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  max-width: 480px; width: 100%;
}
.doc-icon { font-size: 28px; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-info strong { display: block; font-size: 13px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-info span { font-size: 12px; color: var(--text-sub); }
.doc-ready { font-size: 12px; color: #22c55e; font-weight: 600; flex-shrink: 0; }
.doc-prompt-hint { font-size: 12px; color: var(--text-hint); margin-top: 8px; font-style: italic; }

/* ─── API ACTIVE CARD (paramètres) ───────────────────────── */
.api-active-card {
  display: flex; align-items: center; gap: 12px;
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 4px;
}
.api-active-dot {
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulseDot 2s infinite;
}
.api-active-label { font-size: 13px; font-weight: 700; color: #22c55e; }
.api-active-sub   { font-size: 11px; color: var(--text-hint); margin-top: 2px; }

.danger-btn {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.25);
  color: #ef4444;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; gap: 5px;
  transition: var(--transition);
}
.danger-btn:hover { background: rgba(239,68,68,.25); }

/* ─── API HINT BANNER ─────────────────────────────────────── */
.api-hint-banner {
  display: flex; align-items: center; gap: 12px;
  background: rgba(124,111,251,.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px; margin-bottom: 16px;
  font-size: 13px; color: var(--text-sub);
  animation: fadeInUp .4s ease;
}
.api-hint-banner i { color: var(--accent1); font-size: 16px; flex-shrink: 0; }
.api-hint-banner span { flex: 1; }
.api-hint-banner strong { color: var(--accent1); }
.api-hint-banner button { background: var(--accent1); border: none; color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; transition: var(--transition); white-space: nowrap; }
.api-hint-banner button:hover { opacity: .85; }
.api-hint-banner .close-hint { background: var(--border-light); color: var(--text-sub); }

/* ─── TYPING INDICATOR ────────────────────────────────────── */
.typing-indicator { display: flex; align-items: center; gap: 10px; padding: 0 20px 10px; animation: fadeInUp .3s ease; }
.typing-indicator.hidden { display: none; }
.typing-avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; border: 2px solid var(--border); flex-shrink: 0; }
.typing-avatar img { width: 100%; height: 100%; object-fit: cover; }
.typing-bubble { background: var(--ai-bubble); border: 1px solid var(--border); border-radius: 18px; border-bottom-left-radius: 4px; padding: 14px 18px; display: flex; gap: 5px; align-items: center; }
.typing-bubble span { width: 7px; height: 7px; background: var(--accent1); border-radius: 50%; animation: typingDot 1.2s infinite; }
.typing-bubble span:nth-child(2) { animation-delay: .2s; background: var(--accent2); }
.typing-bubble span:nth-child(3) { animation-delay: .4s; background: var(--accent3); }
@keyframes typingDot { 0%,80%,100% { transform: scale(.8); opacity: .4; } 40% { transform: scale(1.2); opacity: 1; } }

/* ─── INPUT BAR ───────────────────────────────────────────── */
.input-bar-wrap { padding: 10px 20px 16px; background: rgba(14,17,32,.9); backdrop-filter: blur(20px); border-top: 1px solid var(--border); flex-shrink: 0; }
.input-bar { display: flex; align-items: center; gap: 10px; background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 8px 10px; transition: var(--transition); }
.input-bar:focus-within { border-color: var(--accent1); box-shadow: 0 0 0 3px rgba(124,111,251,.12), var(--glow-purple); }
.input-action { width: 36px; height: 36px; background: none; border: none; color: var(--text-sub); font-size: 16px; cursor: pointer; border-radius: 10px; transition: var(--transition); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.input-action:hover { background: rgba(124,111,251,.12); color: var(--accent1); }
.input-action.active { color: var(--accent2); }
.input-action.recording { color: #ef4444; animation: rec .8s infinite alternate; }
@keyframes rec { from { opacity: 1; } to { opacity: .3; } }
.input-field-wrap { flex: 1; position: relative; }
textarea#userInput { width: 100%; background: none; border: none; outline: none; color: var(--text-main); font-size: 15px; font-family: inherit; line-height: 1.5; resize: none; max-height: 160px; overflow-y: auto; display: block; padding: 4px 0; }
textarea#userInput::placeholder { color: var(--text-hint); }
.char-counter { position: absolute; bottom: -18px; right: 0; font-size: 10px; color: var(--text-hint); }
.send-btn { width: 40px; height: 40px; background: var(--accent-grad); border: none; border-radius: 12px; color: #fff; font-size: 16px; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 15px rgba(124,111,251,.4); flex-shrink: 0; }
.send-btn:hover { transform: scale(1.08) translateY(-1px); box-shadow: 0 6px 24px rgba(124,111,251,.6); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.input-hint { text-align: center; font-size: 11px; color: var(--text-hint); margin-top: 10px; }

/* ══════════════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(10px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl); width: 460px; max-width: 100%; max-height: 85vh; overflow-y: auto; animation: fadeInUp .3s ease; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 0; margin-bottom: 20px; position: sticky; top: 0; background: var(--bg-card); z-index: 1; padding-top: 22px; }
.modal-header h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-header h3 i { color: var(--accent1); }
.modal-header button { background: none; border: none; color: var(--text-sub); font-size: 18px; cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; transition: var(--transition); }
.modal-header button:hover { background: var(--border-light); }
.modal-body { padding: 0 24px 24px; }

/* ─── SETTINGS ─────────────────────────────────────────────── */
.setting-section { margin-bottom: 24px; }
.setting-section:last-child { margin-bottom: 0; }
.setting-section-title { font-size: 12px; font-weight: 600; color: var(--text-hint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-light); font-size: 14px; color: var(--text-main); cursor: pointer; }
.setting-row:last-child { border-bottom: none; }

input[type="checkbox"] { width: 42px; height: 22px; appearance: none; background: var(--border); border-radius: 99px; position: relative; cursor: pointer; transition: var(--transition); flex-shrink: 0; }
input[type="checkbox"]:checked { background: var(--accent1); }
input[type="checkbox"]::after { content: ''; position: absolute; width: 18px; height: 18px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
input[type="checkbox"]:checked::after { left: 22px; }

/* API key group */
.api-status-wrap { margin-bottom: 12px; }
.api-status-badge { display: inline-block; padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; border: 1px solid; }
.api-status-badge.ok     { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.4); color: #22c55e; }
.api-status-badge.error  { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.4); color: #ef4444; }
.api-status-badge.pending{ background: rgba(234,179,8,.1); border-color: rgba(234,179,8,.4); color: #eab308; }
.api-key-group { display: flex; gap: 10px; margin-bottom: 10px; }
.api-key-input { flex: 1; background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-main); padding: 10px 14px; font-size: 13px; font-family: inherit; outline: none; transition: var(--transition); }
.api-key-input:focus { border-color: var(--accent1); box-shadow: 0 0 0 3px rgba(124,111,251,.12); }
.api-key-btn { background: var(--accent-grad); border: none; color: #fff; border-radius: var(--radius-md); padding: 10px 16px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: var(--transition); font-family: inherit; white-space: nowrap; }
.api-key-btn:hover { opacity: .85; transform: translateY(-1px); }
.api-key-hint { font-size: 12px; color: var(--text-hint); line-height: 1.5; }
.api-key-hint a { color: var(--accent1); text-decoration: none; }
.api-key-hint a:hover { text-decoration: underline; }

/* ─── ABOUT MODAL ──────────────────────────────────────────── */
.modal-about { width: 520px; }
.about-hero { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; padding: 20px; background: var(--bg-card2); border-radius: var(--radius-lg); border: 1px solid var(--border); }
.about-avatar-wrap { position: relative; flex-shrink: 0; }
.about-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent1); box-shadow: var(--glow-purple); }
.about-glow { position: absolute; inset: -6px; border-radius: 50%; background: var(--accent-grad); opacity: .15; filter: blur(12px); animation: glowPulse 3s ease-in-out infinite; }
.about-title { font-size: 24px; font-weight: 800; }
.about-title span { background: var(--accent-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.about-version-badge { display: inline-block; background: rgba(124,111,251,.15); border: 1px solid var(--accent1); color: var(--accent1); font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px; margin: 6px 0; }
.about-tagline { font-size: 13px; color: var(--text-sub); }

.about-card { background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; margin-bottom: 14px; }
.about-card h4 { font-size: 13px; font-weight: 700; color: var(--accent1); margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.about-card p { font-size: 13px; color: var(--text-sub); line-height: 1.6; }
.about-card strong { color: var(--text-main); }

.about-creator { display: flex; align-items: center; gap: 14px; }
.creator-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-grad); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: #fff; flex-shrink: 0; }
.creator-name { font-size: 14px; font-weight: 700; color: var(--text-main); }
.creator-village { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.creator-village i { color: var(--accent2); margin-right: 3px; }

.about-features { list-style: none; padding: 0; }
.about-features li { font-size: 13px; color: var(--text-sub); padding: 4px 0; display: flex; align-items: center; gap: 8px; }
.about-features li i { color: #22c55e; width: 14px; }

.tech-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.tech-badge { background: rgba(124,111,251,.1); border: 1px solid var(--border); color: var(--text-sub); font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 99px; }

.about-footer { text-align: center; padding-top: 8px; }
.about-footer p { font-size: 13px; color: var(--text-hint); margin-bottom: 14px; }
.about-cta { background: var(--accent-grad); border: none; color: #fff; padding: 12px 24px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: var(--transition); font-family: inherit; box-shadow: 0 4px 20px rgba(124,111,251,.4); }
.about-cta:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(124,111,251,.6); }

/* ─── TOAST ──────────────────────────────────────────────── */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--bg-card); border: 1px solid var(--border); border-radius: 99px; padding: 10px 22px; font-size: 13px; color: var(--text-main); box-shadow: 0 8px 30px rgba(0,0,0,.3); z-index: 300; white-space: nowrap; }
.toast.hidden { display: none; }
.toast.toast-error { border-color: rgba(239,68,68,.4); }
.toast.toast-success { border-color: rgba(34,197,94,.4); }

/* ── AI AVATAR TALKING ─────────────────────────────────────── */
.ai-avatar-img.talking { animation: talking .15s infinite alternate; }
@keyframes talking { from { border-color: var(--accent1); } to { border-color: var(--accent2); box-shadow: var(--glow-pink); } }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE MOBILE
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay.open { display: block; }
  .menu-btn { display: flex; }
  .welcome-avatar { width: 80px; height: 80px; }
  .welcome-title { font-size: 22px; }
  .chat-container { padding: 14px 12px; }
  .input-bar-wrap { padding: 8px 12px 12px; }
  .modal-box { margin: 0; max-height: 90vh; border-radius: var(--radius-lg); }
  .about-hero { flex-direction: column; text-align: center; }
  .topbar-actions .action-btn:first-child { display: none; } /* Masquer upload btn topbar sur mobile */
}
