*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #1e1e1e;
  --surf:    #252526;
  --surf2:   #2d2d2d;
  --surf3:   #333333;
  --border:  #454545;
  --border2: #3c3c3c;
  --text:    #d4d4d4;
  --muted:   #858585;
  --blue:    #007acc;
  --blue-l:  #4fc1ff;
  --green:   #4ec9b0;
  --red:     #f44747;
  --purple:  #a78bfa;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surf3);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
  filter: brightness(0.9);
}

.btn-logout {
  padding: 4px 8px;
  height: 28px;
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(244,71,71,0.4);
  border-radius: 2px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s;
  line-height: 1;
}
.btn-logout:hover { background: rgba(244,71,71,0.1); border-color: var(--red); }

/* ── Main ── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 56px;
}

/* ── Page layout (two-column) ── */
.page-layout {
  display: flex;
  gap: 24px;
  width: 100%;
  max-width: 960px;
  align-items: flex-start;
}

/* ── Sidebar ── */
.sidebar {
  width: 210px;
  flex-shrink: 0;
  position: sticky;
  top: 74px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 2px;
}

.tools-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tools-nav .btn-tool {
  width: 100%;
  justify-content: flex-start;
}

.nav-separator {
  height: 1px;
  background: var(--border2);
  margin: 4px 0;
}

.admin-link {
  font-size: 12px;
}

/* ── Content ── */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── Stats ── */
.stats-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surf);
  border: 1px solid var(--border2);
  border-top: 2px solid var(--border2);
  border-radius: 2px;
  padding: 20px 12px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.1s;
}
.stat-card:hover { background: var(--surf2); }

.stat-blue  { border-top-color: var(--blue); }
.stat-teal  { border-top-color: var(--green); }
.stat-purple { border-top-color: var(--purple); }

.stat-icon {
  font-size: 1.3rem;
  line-height: 1;
  opacity: 0.85;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.stat-blue   .stat-value { color: var(--blue-l); }
.stat-teal   .stat-value { color: var(--green); }
.stat-purple .stat-value { color: var(--purple); }

.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  line-height: 1.3;
}

/* ── btn-tool ── */
.btn-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  font-weight: 400;
  font-size: 13px;
  font-family: inherit;
  border-radius: 2px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  touch-action: manipulation;
}
.btn-tool .tool-icon { font-size: 1rem; }

.btn-tool.blue {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-tool.blue:hover { background: #0068b0; border-color: #0068b0; }

.btn-tool.green {
  background: #1a4a2e;
  color: var(--green);
  border-color: #2a6642;
}
.btn-tool.green:hover { background: #1e5535; border-color: var(--green); }

.btn-tool.ghost {
  background: var(--surf);
  color: var(--muted);
  border-color: var(--border2);
}
.btn-tool.ghost:hover { background: var(--surf2); color: var(--text); border-color: var(--border); }

/* ── Formations créées ── */
#formationsWrap {
  display: none;
  background: var(--surf);
  border: 1px solid var(--border2);
  border-radius: 2px;
  overflow: hidden;
}
#formationsWrap.open .missions-head { border-bottom: 1px solid var(--border2); }
#formationsWrap.open .missions-toggle-chev { transform: rotate(180deg); }
#formations-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
}
#formationsWrap.open #formations-body { max-height: 440px; }
#formations-list {
  max-height: 400px;
  overflow-y: auto;
}
#formations-list::-webkit-scrollbar { width: 4px; }
#formations-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── Feuilles de mission ── */
#missionsWrap {
  display: none;
  background: var(--surf);
  border: 1px solid var(--border2);
  border-radius: 2px;
  overflow: hidden;
}

.missions-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--surf3);
  transition: background 0.1s;
}
.missions-head:hover { background: var(--surf2); }
#missionsWrap.open .missions-head { border-bottom: 1px solid var(--border2); }

.missions-head-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.missions-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surf2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 1px 8px;
  line-height: 1.6;
}

.missions-toggle-chev {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s;
}
#missionsWrap.open .missions-toggle-chev { transform: rotate(180deg); }

#missions-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
}
#missionsWrap.open #missions-body { max-height: 440px; }

#missions-list {
  max-height: 400px;
  overflow-y: auto;
}
#missions-list::-webkit-scrollbar { width: 4px; }
#missions-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.missions-empty {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.mission-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border2);
  transition: background 0.1s;
}
.mission-item:last-child { border-bottom: none; }
.mission-item:hover { background: var(--surf2); }

.mission-item-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  opacity: 0.65;
}
.mission-item-body {
  flex: 1;
  min-width: 0;
}
.mission-item-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mission-item-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.mission-item-arrow {
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s, transform 0.1s;
}
.mission-item:hover .mission-item-arrow {
  opacity: 1;
  transform: translate(1px, -1px);
}

/* ── Phrase du jour ── */
#phraseWrap {
  display: none;
}
.phrase-card {
  background: var(--surf);
  border: 1px solid var(--border2);
  border-radius: 2px;
  padding: 14px;
}
.phrase-card-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.phrase-input-row { display: flex; gap: 6px; }
#phraseInput {
  flex: 1;
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.1s;
}
#phraseInput:focus { border-color: var(--blue); }
#phraseInput::placeholder { color: var(--muted); }
.phrase-actions { display: flex; gap: 6px; }
#phraseBtn     { padding: 7px 14px; white-space: nowrap; }
#phraseClearBtn { padding: 7px 10px; white-space: nowrap; }
#phraseStatus {
  font-size: 11px;
  color: var(--green);
  margin-top: 6px;
  min-height: 16px;
}

/* ── Radio ── */
#radioWrap {
  display: none;
  background: var(--surf);
  border: 1px solid var(--border2);
  border-radius: 2px;
  overflow: hidden;
}
.radio-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--surf3);
  transition: background 0.1s;
}
.radio-head:hover { background: var(--surf2); }
#radioWrap.open .radio-head { border-bottom: 1px solid var(--border2); }
.radio-head-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
#radio-now {
  font-size: 11px;
  font-weight: 400;
  color: var(--blue-l);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.radio-toggle-chev {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s;
}
#radioWrap.open .radio-toggle-chev { transform: rotate(180deg); }
#radio-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
#radioWrap.open #radio-body { max-height: 400px; }

.radio-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
}
.radio-btn {
  width: 34px; height: 34px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--surf2);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  font-family: inherit;
  touch-action: manipulation;
}
.radio-btn:hover { border-color: var(--blue); color: var(--text); background: rgba(0,122,204,0.1); }
#radio-playbtn {
  width: 44px; height: 44px;
  font-size: 1rem;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
#radio-playbtn:hover { background: #0068b0; border-color: #0068b0; }

.radio-vol {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 10px;
}
.radio-vol-ico { font-size: 12px; color: var(--muted); width: 18px; text-align: center; }
.radio-slider {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--blue) var(--v,60%), var(--border) var(--v,60%));
  outline: none;
}
.radio-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--blue-l);
  cursor: pointer;
}
.radio-slider::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--blue-l);
  border: none; cursor: pointer;
}
.radio-list { max-height: 160px; overflow-y: auto; border-top: 1px solid var(--border2); }
.radio-list::-webkit-scrollbar { width: 4px; }
.radio-list::-webkit-scrollbar-thumb { background: var(--surf2); border-radius: 2px; }
.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  transition: background 0.1s, color 0.1s;
}
.radio-item:hover { background: var(--surf2); color: var(--text); }
.radio-item.active { color: var(--blue-l); }
.radio-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border); flex-shrink: 0; transition: background 0.1s; }
.radio-item.active .radio-dot { background: var(--blue-l); }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 14px 20px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border2);
}

/* ── Responsive : tablette/mobile ── */
@media (max-width: 700px) {
  .page-layout {
    flex-direction: column;
    align-items: center;
  }

  .sidebar {
    width: 100%;
    max-width: 520px;
    position: static;
  }

  .tools-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  /* recentre les boutons sur mobile */
  .tools-nav .btn-tool {
    justify-content: center;
  }

  /* le séparateur et le btn admin prennent toute la largeur */
  .nav-separator {
    grid-column: 1 / -1;
  }
  .tools-nav .admin-link {
    grid-column: 1 / -1;
  }

  .content {
    width: 100%;
    max-width: 520px;
  }
}

@media (max-width: 480px) {
  .tools-nav {
    grid-template-columns: 1fr;
  }

  .stats-section {
    grid-template-columns: 1fr;
  }

  .phrase-input-row { flex-direction: column; }
}
