/* --- base page --- */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: black;
  overflow: hidden;
}

:root {
  --sideSpace: 0px; /* calculé en JS */
  --panelPad: 12px;
  --panelBg: rgba(15, 15, 15, 0.92);
  --panelBorder: rgba(255, 255, 255, 0.12);
}

/* --- Boutons UI --- */
.ui-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 9999;
  border: none;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  color: white;
  font: 700 14px system-ui, -apple-system, Segoe UI, Roboto, Arial;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ui-btn:hover { background: rgba(0, 0, 0, 0.5); }

/* Supprime le contour blanc de focus */
#menuToggle:focus,
#menuToggle:focus-visible,
#fullscreenBtn:focus,
#fullscreenBtn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* Fullscreen à droite (icône) */
#fullscreenBtn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 9999;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}
#fullscreenBtn img {
  width: 40px;
  height: 40px;
  display: block;
}

/* --- Menu latéral --- */
#sidePanel {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: max(260px, var(--sideSpace));
  max-width: 360px;
  z-index: 9998;
  transform: translateX(-100%);
  transition: transform 220ms ease;
  pointer-events: none;
}

#sidePanel.open {
  transform: translateX(0);
  pointer-events: auto;
}

/* Le panneau interne */
#sidePanel .panelInner {
  height: 100%;
  box-sizing: border-box;

  /* IMPORTANT: réserve de la place pour le bouton Menu au-dessus */
  padding: 64px var(--panelPad) 18px;

  background: var(--panelBg);
  border-right: 1px solid var(--panelBorder);
  color: white;
  font: 14px system-ui, -apple-system, Segoe UI, Roboto, Arial;

  /* Pour pousser Guides et garder Version en bas */
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#sidePanel h2 {
  margin: 6px 0 10px;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
}

.panelBlock {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

/* Header dans les panelBlock */
.panelHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.panelHeader h2 { margin: 0; }

/* -------- LOGIN (refined) -------- */
.authForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Grille: colonne label fixe + input flexible */
.fieldRow {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 0px;
}

.fieldRow label {
  font-size: 13px;
  opacity: 0.9;
  white-space: nowrap;
}

/* Inputs dark */
.fieldRow input {
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.28);
  color: rgba(255,255,255,0.92);
  outline: none;
  transition: 0.18s ease;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.fieldRow input::placeholder {
  color: rgba(255,255,255,0.35);
}

.fieldRow input:focus {
  border-color: rgba(255,255,255,0.30);
  background: rgba(0,0,0,0.45);
}

/* Actions */
.authActions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

/* Bouton principal */
.primaryBtn {
  height: 38px;
  border-radius: 999px;
  padding: 0 14px;
  width: fit-content;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.95);
  font-weight: 800;
  cursor: pointer;
  transition: 0.18s ease;
}
.primaryBtn:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}
.primaryBtn:active { transform: translateY(0); }
.primaryBtn:focus,
.primaryBtn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* Bouton secondaire (Logout) */
.secondaryBtn {
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.14);
}
.secondaryBtn:hover {
  background: rgba(255,255,255,0.08);
}

/* Liens secondaires */
.authLinks {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}
.linkBtn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.22);
  text-underline-offset: 3px;
  transition: 0.15s ease;
}
.linkBtn:hover {
  color: rgba(255,255,255,0.95);
  text-decoration-color: rgba(255,255,255,0.45);
}
.linkBtn:focus,
.linkBtn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.muted {
  opacity: 0.8;
}
.tiny {
  font-size: 12px;
  line-height: 1.35;
}

/* --- Guides layout: prend l'espace vertical dispo --- */
.panelBlockGrow {
  flex: 1;
  min-height: 160px;
}

.guidesList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.guideLink {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 13px;
  transition: 0.15s ease;
}

.guideLink:hover {
  background: rgba(255,255,255,0.10);
  transform: translateX(3px);
}

/* --- Footer version --- */
.panelFooter .muted {
  margin: 0;
  opacity: 0.8;
}

/* --- Backdrop (mobile/tablet) --- */
#backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 9997; /* juste sous le panel (9998) */
}

body.menu-open #backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Mode “pas assez de bande noire” => menu overlay */
body.overlay-menu #sidePanel {
  width: 86vw;
  max-width: 360px;
}

/* ---------------- Discord Floating Button ---------------- */
#discordBtn.floatingDiscord {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 10000;

  display: inline-flex;
  align-items: center;
  gap: 10px;

  padding: 10px 14px;
  border-radius: 999px;

  background: rgba(88, 101, 242, 0.18);
  border: 1px solid rgba(88, 101, 242, 0.38);

  color: rgba(235, 238, 255, 0.95);
  text-decoration: none;
  font: 800 13px system-ui, -apple-system, Segoe UI, Roboto, Arial;

  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

#discordBtn.floatingDiscord:hover {
  transform: translateY(-2px);
  background: rgba(88, 101, 242, 0.26);
  border-color: rgba(88, 101, 242, 0.55);
}

#discordBtn .discordDot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(88, 101, 242, 0.95);
  box-shadow: 0 0 0 4px rgba(88, 101, 242, 0.18);
}

#discordBtn .discordLabel {
  letter-spacing: 0.02em;
}

.secondaryBtn {
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.14);
}
.secondaryBtn:hover {
  background: rgba(255,255,255,0.08);
}

/* --- Auth status + spinner + disabled --- */
.authStatus {
  min-height: 18px;
  font-size: 12px;
  opacity: 0.85;
}

.authStatus.error { color: rgba(255, 120, 120, 0.95); }
.authStatus.ok { color: rgba(140, 255, 170, 0.95); }

.authLoggedMsg {
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.9;
  padding: 6px 2px;
}

.primaryBtn[disabled],
.linkBtn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.primaryBtn .spinner {
  display: none;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.9);
  animation: spin 0.8s linear infinite;
}

.authForm.is-loading .primaryBtn .spinner {
  display: inline-block;
}

.authForm.is-loading .primaryBtn .btnText {
  opacity: 0.85;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================
   Responsive menu (mobile/tablet)
   ========================= */
@media (max-width: 1024px) {
  /* Le panel doit être fixed pour overlay correctement */
  #sidePanel {
    position: fixed;         /* au lieu de absolute */
    top: 0;
    left: 0;
    height: 100dvh;
    width: min(360px, 88vw); /* largeur mobile */
    max-width: 360px;
    z-index: 9998;

    transform: translateX(-105%);
    transition: transform 220ms ease;
    pointer-events: none;
  }

  #sidePanel.open {
    transform: translateX(0);
    pointer-events: auto;
  }

  /* Le contenu interne doit pouvoir scroller */
  #sidePanel .panelInner {
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Le bouton menu reste accessible */
  #menuToggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 9999; /* au-dessus */
  }
}

/* Desktop : si tu ouvres le menu, pas besoin de backdrop */
@media (min-width: 1025px) {
  body.menu-open #backdrop {
    opacity: 0;
    pointer-events: none;
  }
}

/* =========================
   Menu: scroll global unique
   ========================= */

/* Tout le menu scrolle */
.panelInner {
  height: 100%;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* Login ne doit jamais être écrasé */
.panelInner > .panelBlock:first-child {
  flex: 0 0 auto;
  flex-shrink: 0;
}

/* Le bloc guides reprend un comportement normal */
.panelBlockGrow {
  flex: 0 0 auto;   /* IMPORTANT: plus de flex:1 */
  min-height: auto;
  display: block;   /* annule le flex column */
}

/* Pas de scroll interne */
.panelBlockGrow .guidesList {
  overflow: visible;
}

/* Footer fait partie du scroll */
.panelInner > .panelFooter {
  flex: 0 0 auto;
  flex-shrink: 0;
}