/* ==========================================================================
   OB Scanner — admin page (accounts: create, reset password, revoke access)
   Everything here is layout/structure specific to this page; every colour
   comes from the custom properties in styles.css.
   ========================================================================== */

.admin { max-width: 1500px; margin: 0 auto; padding: 0 22px 60px; }

.admin-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent);
  background: rgba(88,166,255,.14);
  border: 1px solid rgba(88,166,255,.4);
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 2px;
}

.admin-main {
  max-width: 1000px;
  margin: 0 auto;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Stat cards -------------------------------------------------------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.stat-card {
  background: linear-gradient(180deg, var(--card), var(--bg-elev));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.stat-label { margin: 0 0 4px; font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.stat-value { margin: 0; font-size: 26px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.stat-value--ok { color: var(--bull); }
.stat-value--off { color: var(--text-mute); }

@media (max-width: 640px) {
  .stat-row { grid-template-columns: 1fr; }
}

/* --- Tab strip ----------------------------------------------------------
   Only "Utilisateurs" exists today, but the strip is built like SMC IA's
   (underline indicator on the active tab) so a second tab slots in later
   without restyling. */
.admin-tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border-soft); }
.admin-tab {
  position: relative;
  appearance: none; border: 0; cursor: pointer; background: transparent;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  color: var(--text-dim);
  padding: 10px 16px;
  transition: color .15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--text); }
.admin-tab.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}

/* Each panel reproduces .admin-main's own flex/gap so the cards inside it
   (create-form, reveal, toolbar, table) keep their spacing now that they are
   nested one level deeper than when there was only ever one tab. */
.admin-tab-panel { display: flex; flex-direction: column; gap: 20px; }

/* --- Error banner -------------------------------------------------------- */
.admin-error {
  margin: 0;
  color: #ffb4b0;
  background: var(--bear-soft);
  border: 1px solid rgba(239,83,80,.4);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
}

/* --- Card surface (shared by create-form / reveal / table) --------------- */
.admin-card {
  background: linear-gradient(180deg, var(--card), var(--bg-elev));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

/* --- Create account -------------------------------------------------------- */
.create-form { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.admin-card-title { margin: 0 0 3px; font-size: 15px; font-weight: 700; color: var(--text); }
.admin-card-sub { margin: 0; font-size: 12.5px; color: var(--text-mute); }
.create-row { display: flex; gap: 10px; }
.create-row .field-input { flex: 1; }

/* The invite-link form has three inputs of very different natural width
   (a free-text label vs. two small numbers) plus a submit button, so unlike
   the single-input account form above it needs its own field wrappers with
   labels rather than one bare flex-grown input. */
.create-row--invite { align-items: flex-end; flex-wrap: wrap; }
.field-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 160px; }
.field-group--narrow { flex: 0 0 150px; min-width: 0; }
.field-group .field-input { width: 100%; }

/* --- Password reveal ----------------------------------------------------
   Accent-tinted so it visually stands apart — this is the one moment the
   plaintext password exists on screen, before it is gone for good. */
.reveal {
  padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(88,166,255,.12), rgba(88,166,255,.04));
  border-color: rgba(88,166,255,.4);
}
.reveal-label { margin: 0 0 6px; font-size: 12.5px; color: var(--text-dim); }
.reveal-email { color: var(--text); font-weight: 700; }
.reveal-password { margin: 0; font-size: 20px; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.reveal-actions { display: flex; gap: 8px; align-items: center; }

/* --- Toolbar: search grows, segmented filter sits right ------------------- */
.admin-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-toolbar .field-input { flex: 1; min-width: 200px; }
.seg { display: inline-flex; gap: 2px; background: var(--bg-elev); border: 1px solid var(--border); padding: 3px; border-radius: 10px; }
.seg-btn {
  appearance: none; border: 0; cursor: pointer; background: transparent;
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--text-dim);
  padding: 6px 13px; border-radius: 7px;
  transition: color .13s, background .13s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { color: var(--text); background: var(--card-2); box-shadow: inset 0 0 0 1px var(--border); }

/* --- Table ---------------------------------------------------------------- */
.admin-table { overflow: hidden; }
.admin-thead, .admin-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.4fr) 100px 150px 100px auto;
  align-items: center;
  gap: 10px;
}
.admin-thead {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.th {
  appearance: none; border: 0; cursor: pointer; background: transparent;
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font); font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 700; color: var(--text-mute);
  padding: 0; text-align: left;
  transition: color .13s;
}
.th:hover { color: var(--text); }
.th--static { cursor: default; }
.th--static:hover { color: var(--text-mute); }
.th--right { justify-self: end; }
.th-arrow { font-size: 10px; }

.admin-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  transition: background .12s;
}
.admin-row:last-child { border-bottom: 0; }
.admin-row:hover { background: var(--card-2); }

.row-email { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-email-text { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-date { font-size: 12.5px; color: var(--text-dim); }
.row-access { font-size: 12.5px; color: var(--text-dim); }
/* No dedicated "warning" custom property exists in styles.css — this reuses
   --touch/--touch-soft, the amber already used elsewhere for an OB's
   "touched" state, since an expired licence is the same kind of "needs
   attention, not an error" signal. */
.row-access--expired { color: var(--touch); font-weight: 600; }
.row-status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-mute); }
.dot.active { background: var(--bull); box-shadow: 0 0 0 3px var(--bull-soft); }
.dot.revoked { background: var(--bear); box-shadow: 0 0 0 3px var(--bear-soft); }

.badge.role-admin { color: var(--accent); background: rgba(88,166,255,.14); border-color: rgba(88,166,255,.4); font-weight: 700; text-transform: uppercase; font-size: 10px; }

.row-btn {
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--text-dim); background: transparent;
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 11px;
  transition: color .13s, border-color .13s;
}
.row-btn:hover { color: var(--text); border-color: #45505c; }
.row-btn.danger:hover { color: #ffb4b0; border-color: rgba(239,83,80,.5); }
/* The "Liens Telegram" toggle while its panel is open, same accent used for the active seg/tab. */
.row-btn.active { color: var(--accent); border-color: rgba(88,166,255,.5); }

.admin-empty { padding: 34px 16px; text-align: center; color: var(--text-dim); font-size: 13.5px; margin: 0; }

/* --- Telegram invite links panel ------------------------------------------
   A sibling block dropped under the row that opened it (not a grid cell of
   .admin-row), so it spans the full row width on its own. Same accent tint
   as .reveal — this is the other spot where a single-use, hand-off value
   sits on screen waiting to be copied. */
.invites-panel {
  padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, rgba(88,166,255,.12), rgba(88,166,255,.04));
  border-top: 1px solid rgba(88,166,255,.4);
  border-bottom: 1px solid var(--border-soft);
}
.invites-note { margin: 0; font-size: 12px; color: var(--text-dim); }
.invites-status { margin: 0; font-size: 13px; color: var(--text-dim); }

.invite-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
/* The tint that flags a failed mint — same red used by .admin-error, applied per row. */
.invite-row--error { background: var(--bear-soft); }
.invite-label { flex: 0 0 140px; font-size: 12.5px; font-weight: 700; color: var(--text); }
.invite-link {
  flex: 1; min-width: 160px;
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.invite-muted { flex: 1; font-size: 12.5px; color: var(--text-mute); }
.invite-error { flex: 1; font-size: 12.5px; color: #ffb4b0; }
.invite-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

@media (max-width: 640px) {
  .invite-row { padding: 8px 0; }
  .invite-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
}

/* --- Signup invite links table ---------------------------------------------
   Deliberately its own classes (links-*, link-*) rather than reusing
   .admin-thead/.admin-row — those are pinned to the 5-column user-table grid
   above, and this table has a different column shape (a URL column instead
   of Statut). Visual language (card, borders, hover) matches admin-table. */
.links-table { overflow: hidden; }
.links-thead, .link-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(200px, 2fr) 110px 100px auto;
  align-items: center;
  gap: 10px;
}
.links-thead {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.link-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  transition: background .12s;
}
.link-row:last-child { border-bottom: 0; }
.link-row:hover { background: var(--card-2); }
/* Dead links (revoked, expired, or exhausted) stay in the list (an admin
   needs the audit trail of who got what) rather than disappearing — muted
   in place, with no Copier/Révoquer left since neither action means
   anything once nothing about the link can still change. */
.link-row--dead { opacity: .55; }
.link-label { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-url {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-uses { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.link-date { font-size: 12.5px; color: var(--text-dim); }
.link-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.link-state { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); }

@media (max-width: 640px) {
  .admin-thead { display: none; }
  .admin-row { grid-template-columns: 1fr; gap: 6px; }
  .row-actions { justify-content: flex-start; }

  .links-thead { display: none; }
  .link-row { grid-template-columns: 1fr; gap: 6px; }
  .link-actions { justify-content: flex-start; }
}
