/* Reset */
* { margin:0; padding:0; box-sizing:border-box; }

:root{
  --bg:#343541;
  --bg-2:#202123;
  --panel:#40414f;
  --panel-2:#2b2b35;
  --fg:#ECECF1;
  --muted:#9CA3AF;
  --btn:#565869;
  --btn-hover:#6d6f78;
  --user:#2f2f3a;
  --bot:#3b3b45;
  --accent:#8E8EFE;
}

/* Layout grille (desktop) */
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr 220px; /* ← sidebar desktop 260px */
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Backdrop mobile */
.backdrop{
  position:fixed; inset:0;
  background:rgba(0,0,0,.45);
  opacity:0; visibility:hidden;
  transition: opacity .25s ease, visibility .25s ease;
  z-index: 900;
}
.backdrop.active{
  opacity:1; visibility:visible;
}

/* Sidebar */
.sidebar-left {
  background: var(--bg-2);
  display:flex;
  flex-direction:column;
  padding:20px 12px;
  position: fixed;
  left:0; top:0; height:100%;
  width:260px;                 /* ← plus large */
  transition: transform 0.3s ease;
  z-index: 1000;
}
.sidebar-left.collapsed { transform: translateX(-100%); } /* desktop collapse */

.sidebar-header { display:flex; align-items:center; justify-content:center; margin-bottom:20px; }
.logo { width:40px; height:40px; }

/* Boutons sidebar */
.btn-primary,
.btn-secondary {
  width:100%;
  padding:12px 14px;
  background:transparent;
  border:1px solid var(--btn);
  color:var(--fg);
  cursor:pointer;
  font-weight:600;
  font-size: 15px;
  line-height: 1.2;
  border-radius:10px;
  margin-bottom:12px;
  text-align:left;
  white-space: normal;
  word-wrap: break-word;
  transition: all 0.2s;
}
.btn-primary:hover,
.btn-secondary:hover { background:var(--btn-hover); }
.btn-primary:focus,
.btn-secondary:focus { outline:2px solid var(--accent); outline-offset:2px; }

/* Footer sidebar */
.sidebar-footer {
  margin-top:auto;
  text-align:center;
  font-weight:700;
  color:var(--fg);
  opacity:.9;
}

/* Toggle sidebar button */
.toggle-btn {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1100;
  background: var(--panel);
  border: none;
  color: white;
  font-size: 20px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.toggle-btn:hover { background: var(--btn-hover); }
.toggle-btn:focus{ outline:2px solid var(--accent); outline-offset:2px; }

/* Colonne centrale */
.main {
  grid-column:2;
  position:relative;
  height:100%;
  background:var(--bg);
  display:flex;
  justify-content:center;
  align-items:flex-start;
  transition: margin-left 0.3s ease;
}

/* Conteneur chat */
.chat-container {
  width:100%;
  max-width:750px;
  display:flex;
  flex-direction:column;
  background:var(--bg);
  border-radius:10px;
  padding:20px;
}

/* Chat-box scrollable */
.chat-box {
  overflow-y:auto;
  flex-grow:1;
  display:flex;
  flex-direction:column;
  gap:12px;
  max-height: calc(100vh - 180px);
  padding-bottom: 90px;
  padding-right: 12px;
  scroll-behavior: smooth;
}

/* Scrollbar */
.chat-box::-webkit-scrollbar { width:8px; }
.chat-box::-webkit-scrollbar-track { background:var(--bg); }
.chat-box::-webkit-scrollbar-thumb { background:var(--btn); border-radius:4px; transition: background 0.2s; }
.chat-box::-webkit-scrollbar-thumb:hover { background:var(--btn-hover); }

/* Bulles */
.message {
  position:relative;
  padding:12px 16px;
  border-radius:12px;
  max-width:70%;
  word-wrap:break-word;
  line-height:1.6;
  opacity:0;
  transform: translateY(10px);
  animation:fadeSlide 0.25s forwards;
  border:1px solid rgba(255,255,255,.05);
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 30px rgba(0,0,0,.15);
}
@keyframes fadeSlide { to { opacity:1; transform: translateY(0); } }

.message.user { background:var(--user); color:var(--fg); align-self:flex-end; padding-right:50px; }
.message.bot  { background:var(--bot);  color:var(--fg); align-self:flex-start; padding-left:50px; }

.message:hover{ box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset, 0 12px 40px rgba(0,0,0,.22); }

/* Avatars */
.msg-avatar{
  position:absolute; top:12px; width:26px; height:26px;
  border-radius:50%; background:#222; display:grid; place-items:center;
  font-size:14px; opacity:.92; user-select:none;
}
.message.bot .msg-avatar  { left:12px; }
.message.user .msg-avatar { right:12px; }

/* Séparateur */
.separator{
  align-self:center;
  font-size:12px; color:var(--muted);
  padding:6px 10px; margin:8px 0;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.06);
  border-radius:999px;
}

/* Header central */
.dynamic-header {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  color: var(--fg);
  font-size: clamp(22px, 4vw, 34px);
  text-align: center;
  font-weight: 800;
  z-index: 900;
  opacity: .9;
  transition: opacity .25s ease;
  text-shadow: 0 1px 0 rgba(0,0,0,.8), 0 8px 40px rgba(0,0,0,.35);
  letter-spacing:.2px;
}

/* Barre input */
.center-bar-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 750px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 999;
  transition: all 0.3s ease;
}

.center-bar-footer {
  color: var(--muted);
  margin-top: 6px;
  font-size: 11px;
  text-align: center;
}

.center-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 14px;
  background: var(--panel);
  width: 100%;
  border: 1px solid #52535f;
}

/* textarea large + joli */
.center-bar textarea {
  flex: 1 1 auto;
  min-height: 52px;
  max-height: 180px;
  resize: none;
  padding: 14px 15px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  outline: none;
  background: var(--panel-2);
  color: white;
  line-height: 1.4em;
  font-size: 15px;
}
.center-bar textarea::placeholder { color:#cfcfd8; opacity:.75; }
.center-bar textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(142,142,254,.18);
}

/* bouton largeur fixe */
.center-bar button{
  flex: 0 0 100px;
  width: 100px;
  min-height: 52px;
  padding: 0 14px;
  border-radius:10px;
  border:1px solid var(--btn);
  background:var(--btn);
  color:white;
  font-weight:bold;
  cursor:pointer;
  transition: all 0.2s ease;
  transform: translateY(0);
  will-change: transform;
  text-align:center;
  white-space:nowrap;
}
.center-bar button:hover { background:var(--btn-hover); transform: translateY(-1px); }
@media (max-width: 420px) {
  .center-bar button { flex-basis: 88px; width: 88px; font-size: 14px; }
}

/* Typing indicator */
.typing{
  align-self:flex-start;
  background:var(--bot);
  border:1px solid rgba(255,255,255,.05);
  border-radius:12px;
  padding:12px 16px; margin-top:4px;
  width:56px; display:flex; gap:6px; justify-content:center;
}
.dot{ width:6px; height:6px; border-radius:50%; background:#bfc1c9; opacity:.65; animation:bounce 1.1s infinite; }
.dot:nth-child(2){ animation-delay:.15s; }
.dot:nth-child(3){ animation-delay:.3s; }
@keyframes bounce{ 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-4px)} }

/* Colonne droite vide */
.right-space { grid-column:3; background:transparent; }

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* --- Mobile ergonomique --- */
@media screen and (max-width: 768px) {
  body { grid-template-columns: 1fr; overflow:hidden; }

  /* Sidebar → drawer */
  .sidebar-left{
    width: 80%;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: 20px 0 50px rgba(0,0,0,.5);
  }
  .sidebar-left.open { transform: translateX(0); }

  .toggle-btn { left:10px; }
  .main { grid-column:1; padding:10px 5px; margin-left:0 !important; }
  .chat-container { max-width:100%; padding:10px; }
  .center-bar-container { max-width:100%; left:50%; transform:translateX(-50%); }
  .message { max-width:85%; }
}
