/* Bristol admin area: same tokens as app.css (loaded first), denser "control center" layout.
   Wider column than the learner app, tables for lists, one gradient hero tile (who is
   online), destructive actions in red behind a typed confirmation. */

.admin .svg-defs { position: absolute; }

/* --- Top bar ---------------------------------------------------------------- */

.admin-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: env(safe-area-inset-top) var(--gutter) 0;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 1px 0 var(--glass-edge), var(--shadow-soft);
}
.admin-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 0;
}
.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text-primary);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.admin-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--gradient-e);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 900;
  text-shadow: var(--on-color-shadow);
}
.admin-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 -4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-nav::-webkit-scrollbar { display: none; }
/* Phone: logo and "Se déconnecter" on the first row, the page links below.
   Wide screens: logo, links, then "Se déconnecter" on one row. */
.admin-brand { order: 1; }
.admin-logout-form { order: 2; }
.admin-nav { order: 3; flex-basis: 100%; }
@media (min-width: 760px) {
  .admin-nav { order: 2; flex-basis: auto; margin-left: auto; }
  .admin-logout-form { order: 3; }
}
.admin-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, transform 0.14s var(--ease-out);
}
.admin-nav-link:hover { color: var(--text-primary); }
.admin-nav-link:active { transform: scale(0.97); }
.admin-nav-link[aria-current="page"] {
  background: var(--accent-blue-soft);
  color: var(--accent-blue-ink);
}
.admin-logout .icon { width: 18px; height: 18px; }

/* --- Page ------------------------------------------------------------------- */

.admin-main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px var(--gutter) calc(40px + env(safe-area-inset-bottom));
}
.admin-auth .admin-main { max-width: 480px; padding-top: calc(env(safe-area-inset-top) + 16px); }

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 18px;
}
.admin-head h1,
.profile-head h1 {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.admin-sub {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 700;
}
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--accent-green);
  vertical-align: 1px;
  box-shadow: 0 0 0 0 rgba(52, 200, 90, 0.5);
  animation: live-pulse 2.4s ease-out infinite;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 200, 90, 0.5); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(52, 200, 90, 0); }
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title,
.card-title-lg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.card-title .icon { color: var(--accent-blue); }
.card-title-lg { font-size: 26px; }
.card-sub {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}
.card-sub code, .admin-sub code, .field-help code, .check-row code {
  font-family: var(--mono);
  font-size: 0.92em;
  overflow-wrap: anywhere;
}
.card-empty {
  padding: 18px 4px 6px;
  color: var(--text-secondary);
  font-weight: 700;
}
.subsection-title {
  margin: 26px 0 12px;
  font-size: 17px;
  font-weight: 900;
}

/* --- Buttons ------------------------------------------------------------------ */

.btn-sm {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-tile);
  font-size: 15px;
}
.btn-sm .icon { width: 18px; height: 18px; }
.btn-danger {
  background: linear-gradient(180deg, #FF6275, #D92B45);
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(217, 43, 69, 0.28);
}
.btn-ghost-danger {
  background: var(--accent-red-soft);
  color: var(--accent-red-ink);
}

/* --- KPI tiles ---------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 760px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.kpi {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 18px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.kpi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 800;
}
.kpi-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 10px;
  background: var(--g);
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgb(var(--tint) / 0.3);
}
.kpi-icon .icon { width: 17px; height: 17px; stroke-width: 2.4; }
.kpi-value {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.kpi-sub {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}
.kpi-hero {
  position: relative;
  overflow: hidden;
  background: var(--g);
  color: #FFFFFF;
  box-shadow: 0 10px 26px rgb(var(--tint) / 0.35);
}
.kpi-hero .kpi-label, .kpi-hero .kpi-sub { color: rgba(255, 255, 255, 0.92); }
.kpi-hero .kpi-value { font-size: 44px; text-shadow: var(--on-color-shadow); }
.kpi-hero::after {
  content: "";
  position: absolute;
  right: -36px;
  top: -36px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

/* --- Dashboard columns ------------------------------------------------------------ */

.admin-columns {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
@media (min-width: 900px) {
  .admin-columns { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
}
.chart-card, .online-card, .table-card, .admin-section, .admin-form-card { min-width: 0; }
.table-card, .admin-section { margin-bottom: 16px; }

/* --- Column chart (HTML): one column per day, bars grow from the baseline ---------- */

.chart {
  position: relative;
  margin: 18px 0 0;
}
.chart-plot {
  --plot-height: 168px;
  position: relative;
  padding-left: 30px;
}
.chart-grid {
  position: absolute;
  inset: 0 0 26px 0;
  pointer-events: none;
}
.chart-tick {
  position: absolute;
  left: 30px;
  right: 0;
  bottom: calc(var(--at) * 100%);
  height: 0;
  border-top: 1px solid var(--border-subtle);
}
.chart-tick-label {
  position: absolute;
  right: 100%;
  top: 0;
  padding-right: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transform: translateY(-50%);
}
.chart-days {
  position: relative;
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  height: calc(var(--plot-height) + 26px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.chart-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  border-radius: 8px;
  outline-offset: -2px;
  cursor: default;
}
.chart-day:hover, .chart-day:focus-visible { background: var(--surface-alt); }
.chart-bar {
  position: relative;
  display: block;
  width: min(24px, 62%);
  height: calc(var(--v, 0) * var(--plot-height));
  margin-bottom: 26px;
  border-radius: 4px 4px 0 0;
  background: var(--accent-blue);
  transition: height 0.4s var(--ease-out);
}
.chart-day:hover .chart-bar, .chart-day:focus-visible .chart-bar { background: var(--accent-blue-ink); }
.chart-value {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -4px);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 900;
}
.chart-label {
  position: absolute;
  bottom: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chart-day.is-today .chart-label { color: var(--text-primary); font-weight: 900; }
.chart-tip {
  position: absolute;
  z-index: 2;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-bar);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -100%);
}
.chart-tip strong { display: block; font-size: 17px; font-weight: 900; }
.chart-tip span { color: var(--text-secondary); }
.chart-table { margin-top: 14px; }
.chart-table > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent-blue-ink);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

/* --- Online list -------------------------------------------------------------------- */

.online-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.online-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "avatar name kind" "avatar seen kind";
  align-items: center;
  column-gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-row);
  background: var(--surface-alt);
}
.online-row .avatar { grid-area: avatar; }
.online-name { grid-area: name; overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.online-seen { grid-area: seen; color: var(--text-secondary); font-size: 13px; font-weight: 700; }
.online-kind {
  grid-area: kind;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-green-soft);
  color: var(--accent-green-ink);
  font-size: 12px;
  font-weight: 900;
}
.online-kind.is-admin { background: var(--accent-violet-soft); color: var(--accent-violet-ink); }
.online-empty { margin-top: 14px; color: var(--text-secondary); font-weight: 700; }

.avatar-sm { width: 36px; height: 36px; font-size: 15px; }
.avatar-lg { width: 64px; height: 64px; font-size: 26px; box-shadow: 0 8px 18px rgb(var(--tint, 62 123 250) / 0.3); }

/* --- Tables --------------------------------------------------------------------------- */

.table-wrap {
  position: relative; /* keeps the visually hidden caption inside the scroll area */
  margin: 0 -8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 15px;
}
.data-table-compact { min-width: 0; }
.data-table th, .data-table td {
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}
.data-table thead th {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.data-table tbody tr { border-top: 1px solid var(--border-subtle); }
.data-table tbody th { font-weight: 800; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-profile { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-title { display: block; color: inherit; font-weight: 900; text-decoration: none; }
a.cell-title:hover { color: var(--accent-blue-ink); text-decoration: underline; }
.cell-sub { display: block; color: var(--text-secondary); font-size: 13px; font-weight: 700; }
.cell-sub code { font-family: var(--mono); font-size: 12px; }
.cell-action { text-align: right; white-space: nowrap; }
.file-name { font-family: var(--mono); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }

.presence {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.status-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--border-subtle);
}
.presence.is-online { color: var(--accent-green-ink); }
.presence.is-online .status-dot { background: var(--accent-green); box-shadow: 0 0 0 3px var(--accent-green-soft); }

/* --- Profile detail ------------------------------------------------------------------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 16px;
}
.profile-head-text { display: grid; gap: 4px; min-width: 0; }
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.admin-actions form { display: contents; }
.admin-section .upload-help { margin: 10px 0 14px; }
.folder-warning { margin-top: 14px; line-height: 1.45; }
.folder-warning code { font-family: var(--mono); font-size: 0.92em; }
.admin-form-grid {
  display: grid;
  gap: 20px;
  margin-top: 16px;
}
@media (min-width: 760px) {
  .admin-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
.admin-form-card { max-width: 560px; margin: 8px auto 0; }
.admin-form-card .form { margin-top: 18px; }

.inline-confirm { position: relative; display: inline-block; }
.inline-confirm > summary { list-style: none; }
.inline-confirm > summary::-webkit-details-marker { display: none; }
.inline-confirm-body {
  position: absolute;
  right: 0;
  z-index: 5;
  display: grid;
  gap: 10px;
  width: 240px;
  margin-top: 8px;
  padding: 14px;
  border-radius: var(--radius-row);
  background: var(--surface);
  box-shadow: var(--shadow-bar);
  white-space: normal;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
}

.danger-zone { box-shadow: 0 0 0 2px var(--accent-red-soft), var(--shadow-card); }
.danger-zone .card-title .icon { color: var(--accent-red); }
.danger-form {
  padding: 16px;
  border-radius: var(--radius-row);
  background: var(--surface-alt);
}
.danger-form h3 { font-size: 16px; font-weight: 900; }
.danger-form .field-help { margin-top: 0; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.check-row input { width: 22px; height: 22px; margin-top: 1px; flex: none; accent-color: var(--accent-red); }

/* --- Login ----------------------------------------------------------------------------- */

.auth-mark { display: block; margin: 0 auto 12px; }
.auth-sub {
  margin: -12px 0 20px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .chart-bar { transition: none; }
}
