/* ============================================================================
   PERMISSION ⇄ DISCORD SYNC  (pages/permissions-discord.js — the `pd-*` scale)
   ----------------------------------------------------------------------------
   Loaded LAST, so it wins on source order over anything in 15-permissions-payment
   that shares a selector — the numeric filename prefix IS the cascade position
   (see parts/README.md); there is no manifest to edit.

   Everything here is namespaced `pd-` and every colour resolves to an existing
   token, so the panel reads as part of the same product as the `ga-*` panel it
   sits inside. The three tones are the same three the page's own logic uses:
   ok = matches, warn = one side has moved, bad = both have and Azra will not guess.
   ========================================================================== */

/* ── Status pill in the panel title ─────────────────────────────────────── */
.pd-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  margin-left: .5rem; padding: .15rem .5rem;
  border-radius: 999px; font-size: .6875rem; font-weight: 600;
  vertical-align: middle; letter-spacing: .01em;
}
.pd-pill ion-icon { font-size: .85em; }
.pd-pill.ok  { background: rgba(147,197,114,.14); color: var(--pistachio); border: 1px solid rgba(147,197,114,.3); }
.pd-pill.off { background: rgba(148,163,184,.12); color: var(--text-muted);  border: 1px solid rgba(148,163,184,.25); }

/* ── Action row ─────────────────────────────────────────────────────────── */
.pd-actions {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin: 0 0 .4rem;
}

.pd-fine  { font-size: .75rem; line-height: 1.5; }
.pd-muted { color: var(--text-muted); }
.pd-lede  { font-size: .8125rem; line-height: 1.6; color: var(--text-secondary); margin: 0; }

/* ── Notices: note → warn → danger, in ascending seriousness ───────────── */
.pd-note, .pd-warn, .pd-danger {
  border-radius: 10px; padding: .7rem .85rem;
  font-size: .8125rem; line-height: 1.55;
  margin: 0 0 .75rem;
}
.pd-note {
  display: flex; gap: .55rem; align-items: flex-start;
  background: rgba(148,163,184,.08); border: 1px solid var(--border); color: var(--text-secondary);
}
.pd-warn   { background: rgba(245,158,11,.09);  border: 1px solid rgba(245,158,11,.3); }
.pd-danger {
  display: flex; gap: .6rem; align-items: flex-start;
  background: rgba(220,38,38,.1); border: 1px solid rgba(220,38,38,.32); color: #fca5a5;
}
.pd-note ion-icon, .pd-danger ion-icon { flex: none; font-size: 1.05rem; margin-top: .1rem; }
.pd-danger strong { color: #fecaca; }

.pd-warn-head {
  display: flex; align-items: center; gap: .4rem;
  font-weight: 700; font-size: .8125rem; color: var(--yellow); margin-bottom: .35rem;
}
.pd-warn-list { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .3rem; }
.pd-warn-list li { color: var(--text-secondary); }
.pd-warn-list strong { color: var(--text-primary); }
.pd-warn-list em { color: var(--text-muted); font-style: normal; }

/* ── Preview rows (one per role) ────────────────────────────────────────── */
.pd-row {
  border: 1px solid var(--border); border-radius: 10px;
  padding: .65rem .8rem; background: rgba(255,255,255,.015);
  display: flex; flex-direction: column; gap: .4rem;
}
.pd-row + .pd-row { margin-top: .5rem; }
.pd-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .8125rem; }
.pd-row-body { display: flex; flex-direction: column; gap: .3rem; font-size: .75rem; }
.pd-row-body > div { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }

/* A pickable row — the checkbox is the affordance, so the whole row is the label. */
.pd-pick { flex-direction: row; align-items: flex-start; gap: .65rem; cursor: pointer; }
.pd-pick input { margin-top: .25rem; flex: none; accent-color: var(--crimson); }
.pd-pick:hover { border-color: rgba(255,255,255,.16); }

/* The lead word before a chip list ("Grant", "Remove", "Held back"). Fixed width so
   several rows read as a column rather than as ragged prose. */
.pd-lead {
  display: inline-block; min-width: 8.5rem;
  font-weight: 600; font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
}
.pd-lead.pd-add  { color: var(--pistachio); }
.pd-lead.pd-rem  { color: var(--red, #ef4444); }
.pd-lead.pd-hold { color: var(--yellow); }

/* ── Permission chips ───────────────────────────────────────────────────── */
.pd-chip {
  display: inline-block; padding: .12rem .45rem;
  border-radius: 6px; font-size: .6875rem; font-weight: 500;
  background: rgba(148,163,184,.12); border: 1px solid rgba(148,163,184,.22);
  color: var(--text-secondary); white-space: nowrap;
}
.pd-chip.add  { background: rgba(147,197,114,.13); border-color: rgba(147,197,114,.3); color: var(--pistachio); }
.pd-chip.rem  { background: rgba(220,38,38,.13);   border-color: rgba(220,38,38,.32);  color: #fca5a5; }
.pd-chip.hold { background: rgba(245,158,11,.13);  border-color: rgba(245,158,11,.3);  color: var(--yellow); }

/* ── The at-a-glance role table ─────────────────────────────────────────── */
.pd-table { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: .5rem; }
.pd-trow {
  display: grid; grid-template-columns: minmax(9rem, 1.1fr) minmax(0, 2fr) auto;
  gap: .75rem; align-items: center;
  padding: .5rem .25rem; border-bottom: 1px solid var(--border);
  font-size: .75rem;
}
.pd-tname { display: flex; align-items: center; gap: .35rem; font-weight: 600; color: var(--text-primary); }
.pd-tmid  { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; min-width: 0; }
.pd-tstat { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; white-space: nowrap; }
.pd-tstat.ok   { color: var(--pistachio); }
.pd-tstat.warn { color: var(--yellow); }
.pd-tstat.bad  { color: #fca5a5; }

/* ── Settings rows ──────────────────────────────────────────────────────── */
.pd-opt {
  display: flex; gap: .65rem; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem;
}
.pd-opt:hover { border-color: rgba(255,255,255,.16); }
.pd-opt input { margin-top: .2rem; flex: none; accent-color: var(--crimson); }
.pd-opt strong { display: block; font-size: .8125rem; margin-bottom: .15rem; }
.pd-opt span   { display: block; font-size: .75rem; line-height: 1.5; color: var(--text-muted); }
.pd-opt em     { font-style: normal; color: var(--text-secondary); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.pd-empty {
  display: flex; align-items: center; gap: .5rem; justify-content: center;
  padding: 1.1rem; border: 1px dashed var(--border); border-radius: 10px;
  color: var(--text-muted); font-size: .8125rem; text-align: center;
}
.pd-empty ion-icon { font-size: 1.1rem; }

/* ============================================================================
   ADMIN PANEL — the per-server allowlist (`ps-*`, admin/permsync-access.js)
   The one place this feature can be granted to a server. Styled as a single
   decisive card rather than as one toggle in a row, because switching it on is
   what brings the feature into EXISTENCE for that server.
   ========================================================================== */
.ps-lede { font-size: .8125rem; line-height: 1.6; color: var(--text-muted); margin: 0 0 1rem; }
.ps-lede strong { color: var(--text-secondary); }
.ps-fine { font-size: .75rem; color: var(--text-muted); margin: .75rem 0 0; }

.ps-card {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem; background: rgba(255,255,255,.015);
}
.ps-card.is-on { border-color: rgba(147,197,114,.35); background: rgba(147,197,114,.05); }

.ps-card-main {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.ps-state { display: flex; align-items: flex-start; gap: .65rem; min-width: 0; }
.ps-state > ion-icon { font-size: 1.5rem; flex: none; margin-top: .1rem; color: var(--text-muted); }
.ps-card.is-on .ps-state > ion-icon { color: var(--pistachio); }
.ps-state strong { display: block; font-size: .875rem; margin-bottom: .15rem; }
.ps-state span   { display: block; font-size: .75rem; line-height: 1.5; color: var(--text-muted); max-width: 46ch; }

.ps-meta {
  margin-top: .85rem; padding-top: .75rem; border-top: 1px solid var(--border);
  font-size: .75rem; color: var(--text-muted);
}
.ps-meta code { font-size: .7rem; }
.ps-note {
  margin-top: .35rem; padding: .4rem .55rem; border-radius: 6px;
  background: rgba(148,163,184,.08); color: var(--text-secondary);
}

.ps-usage {
  margin-top: .85rem; padding-top: .75rem; border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .6rem;
}
.ps-usage > div { display: flex; flex-direction: column; gap: .1rem; }
.ps-usage span   { font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.ps-usage strong { font-size: .8125rem; color: var(--text-primary); font-weight: 600; }

/* ── Narrow viewports ───────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .pd-trow { grid-template-columns: 1fr; gap: .3rem; }
  .pd-tstat { justify-self: start; }
  .pd-lead { min-width: 0; display: block; }
  .pd-actions .btn { flex: 1 1 auto; justify-content: center; }
  .ps-card-main { flex-direction: column; align-items: stretch; }
  .ps-card-main .btn { justify-content: center; }
}
