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

body {
  font-family: system-ui, Arial, sans-serif;
  display: flex;
  min-height: 100vh;
  color: #1e293b;
}

/* ---- Barre latérale (fixe, masquable par bouton) ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 240px;
  background: #1e293b;
  color: #f1f5f9;
  padding: 56px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  overflow-y: auto;
}
body.menu-hidden .sidebar { display: none; }

/* Bouton masquer / afficher (coin haut-gauche) */
#menu-toggle {
  position: fixed; top: 10px; left: 10px; z-index: 101;
  background: #3b82f6; color: #fff; border: none;
  padding: 8px 14px; border-radius: 8px; font-size: 14px;
  cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#menu-toggle:hover { background: #2563eb; }

.sidebar h1 { font-size: 22px; margin-bottom: 16px; text-align: center; }

.sidebar-logo {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 16px;
}

.nav-btn {
  background: transparent; border: none; color: #cbd5e1;
  font-size: 16px; text-align: left; padding: 12px 16px;
  border-radius: 8px; cursor: pointer; transition: background 0.2s;
}
.nav-btn:hover { background: #334155; color: #fff; }
.nav-btn.active { background: #3b82f6; color: #fff; }

/* ---- Sélecteur de langue ---- */
.lang-selector {
  margin-top: auto; padding-top: 24px;
  display: flex; align-items: center; gap: 8px;
}
.lang-selector select {
  flex: 1; padding: 8px; border-radius: 8px; border: none;
  background: #334155; color: #f1f5f9; font-size: 15px; cursor: pointer;
}

/* ---- Zone de contenu ---- */
.content { flex: 1; margin-left: 240px; padding: 48px; transition: margin-left 0.2s ease; }
body.menu-hidden .content { margin-left: 0; }
.page { display: none; }
.page.active { display: block; }
.page h2 { font-size: 32px; margin-bottom: 16px; }
.page p { font-size: 18px; line-height: 1.6; color: #475569; }

/* ---- Bannière d'accueil : image fixe (ne défile jamais), seul le texte par-dessus défile ---- */
.hero-bg {
  position: fixed;
  top: 0; left: 240px; right: 0; bottom: 0;
  width: calc(100% - 240px); height: 100%;
  object-fit: contain;
  background: #0f172a;
  z-index: 0;
  transition: left 0.2s ease, width 0.2s ease;
}
body.menu-hidden .hero-bg { width: 100%; }
body.menu-hidden .hero-bg { left: 0; }
.hero-text {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 96px);
  display: flex; flex-direction: column; justify-content: center;
  color: #fff;
  background: linear-gradient(rgba(15, 23, 42, 0.15), rgba(15, 23, 42, 0.6));
  padding: 40px;
  margin: -48px;
}
.hero-text h2 { color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }
.hero-text p { color: #f1f5f9; text-shadow: 0 1px 4px rgba(0,0,0,0.6); max-width: 600px; }

/* ---- Cartes de raccourci (sous la bannière d'accueil) ---- */
.home-cards {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 40px;
  margin: 0 -48px -48px;
}
.home-card {
  flex: 1;
  min-width: 160px;
  background: rgba(30, 41, 59, 0.55);
  backdrop-filter: blur(4px);
  border-radius: 16px;
  padding: 32px 20px;
  text-align: center;
  text-decoration: none;
  color: #f1f5f9;
  font-size: 18px;
  font-weight: 600;
  transition: transform 0.2s ease, background 0.2s ease;
}
.home-card:hover { background: rgba(51, 65, 85, 0.7); transform: translateY(-4px); }
.home-card-icon { display: block; font-size: 48px; margin-bottom: 12px; }

/* ---- Chat : écran d'entrée ---- */
#chat-namebox { max-width: 460px; }
#chat-namebox p { margin-bottom: 16px; }
.chat-setup-row { margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
#chat-name-input {
  padding: 10px; font-size: 16px; border: 1px solid #cbd5e1;
  border-radius: 8px; width: 100%; max-width: 280px;
}
.chat-avatar-btn {
  display: inline-block; background: #e2e8f0; color: #334155;
  padding: 9px 14px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.chat-avatar-btn:hover { background: #cbd5e1; }
#chat-avatar-preview {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover;
  border: 2px solid #e2e8f0;
}
#chat-name-ok, #chat-form button {
  background: #3b82f6; color: #fff; border: none;
  padding: 10px 18px; border-radius: 8px; font-size: 16px; cursor: pointer;
}
#chat-name-ok:hover, #chat-form button:hover { background: #2563eb; }

/* ---- Chat : conversation ---- */
#chat-main { display: none; flex-direction: column; height: 62vh; max-width: 760px; }

#chat-messages {
  flex: 1; overflow-y: auto; border: 1px solid #e2e8f0;
  border-radius: 12px; background: #fff; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}

.msg-row {
  display: flex; gap: 8px; max-width: 85%;
  align-self: flex-start; align-items: flex-end;
}
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  flex-shrink: 0; background: #3b82f6; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.msg { background: #f1f5f9; padding: 8px 12px; border-radius: 12px; }
.msg-row.mine .msg { background: #dbeafe; }
.msg-head { font-size: 12px; color: #64748b; margin-bottom: 2px; }
.msg-user { font-weight: 600; color: #334155; }
.msg-text { font-size: 16px; color: #1e293b; white-space: pre-wrap; word-wrap: break-word; }

#chat-form { display: flex; gap: 8px; margin-top: 12px; }
#chat-input {
  flex: 1; padding: 12px; font-size: 16px;
  border: 1px solid #cbd5e1; border-radius: 8px;
}

#chat-userbar { margin-top: 10px; font-size: 14px; color: #64748b; }
#chat-change-name {
  background: none; border: none; color: #3b82f6;
  cursor: pointer; text-decoration: underline; font-size: 14px;
}

/* ---- Adaptation mobile (petit écran) ---- */
@media (max-width: 600px) {
  .sidebar {
    width: 80%;
    max-width: 280px;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
  }
  .content { margin-left: 0; padding: 24px 16px 24px 64px; }
  .page h2 { font-size: 24px; }
  .page p { font-size: 16px; }
  #jukebox.active { left: 0; }
  #chat-main { height: 70vh; max-width: 100%; }
  .hero-bg { left: 0; width: 100%; }
  .hero-text { padding: 20px; margin: -24px -16px -24px -64px; min-height: calc(100vh - 48px); }
  .home-cards { margin: 0 -16px -24px -64px; padding: 24px 16px; flex-direction: column; }
}

/* ---- Jukebox intégré (remplit tout, à droite de la barre) ---- */
#jukebox.active {
  position: fixed;
  top: 0; left: 240px; right: 0; bottom: 0;
  padding: 0; margin: 0;
  background: #000;
  z-index: 10;
}
body.menu-hidden #jukebox.active { left: 0; }
#jukebox-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}
