/* Access control UI: form tabs, the Permissions tab of the user form, the Activity Log. Tokens from admin.css only; logical properties for RTL. */

/* a tall drawer (the permissions grid) scrolls inside its body: without this the grid row grows with the content and pushes the footer off screen */
.backdrop-drawer { grid-template-rows: minmax(0, 1fr); }
.backdrop-drawer > .drawer { min-height: 0; }

/* ------------------------------------------------------------ tabs inside a record drawer */
.form-tabbed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.form-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.form-tabs::-webkit-scrollbar { display: none; }
.form-tabs .tab { background: transparent; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; min-height: 44px; font: inherit; font-weight: 700; color: var(--muted); white-space: nowrap; cursor: pointer; }
.form-tabs .tab:hover { color: var(--ink); }
.form-tabs .tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.form-tabs .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }

/* ------------------------------------------------------------ permissions tab */
.acc-perm, .acc-body { display: grid; gap: 22px; min-width: 0; }
.acc-sec { display: grid; gap: 10px; min-width: 0; }
.acc-sec .form-section { margin: 0; }
.acc-body > .acc-sec:first-child .form-section, .acc-detail-sec:first-child .form-section { border-top: 0; padding-top: 0; }
.acc-admin { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid color-mix(in srgb, var(--info) 35%, var(--line)); border-radius: var(--r-sm); background: var(--info-soft); }
.acc-admin .ico { color: var(--info-ink); flex: 0 0 auto; margin-top: 1px; }
.acc-admin p { margin: 4px 0 0; font-size: 13px; }

.acc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-chip { position: relative; display: inline-flex; }
.acc-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.acc-chip span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-weight: 650; pointer-events: none; transition: background .15s, border-color .15s; }
.acc-chip:hover span { border-color: var(--muted); }
.acc-chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .acc-chip input:checked + span { color: #1a120c; }
.acc-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.acc-tpl-desc { margin: 0; min-height: 1.4em; }

.acc-grid { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel); }
.acc-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 340px); gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
.acc-row:last-child { border-bottom: 0; }
.acc-app { display: grid; gap: 3px; min-width: 0; align-content: center; }
.acc-seg { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel); }
.acc-lvl { position: relative; display: grid; border-inline-start: 1px solid var(--line-2); cursor: pointer; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.acc-lvl:first-child { border-inline-start: 0; }
.acc-lvl input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.acc-lvl span { display: grid; place-items: center; min-height: 40px; padding: 0 4px; text-align: center; pointer-events: none; transition: background .12s; }
.acc-lvl:hover span { background: var(--panel-2); }
.acc-lvl input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.acc-lvl input:checked + span { font-weight: 800; }
.acc-lvl.lv0 input:checked + span { background: var(--panel-3); color: var(--ink); }
.acc-lvl.lv1 input:checked + span { background: var(--info-soft); color: var(--info-ink); }
.acc-lvl.lv2 input:checked + span { background: var(--ok-soft); color: var(--ok-ink); }
.acc-lvl.lv3 input:checked + span { background: var(--warn-soft); color: var(--warn-ink); }
.acc-lvl.lv4 input:checked + span { background: var(--danger-soft); color: var(--danger-ink); }

.acc-hint { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.acc-hint .ico { margin-top: 1px; flex: 0 0 auto; }
.acc-hint > span:not(.ico) { flex: 1 1 160px; min-width: 0; }
.acc-hint.warn { color: var(--warn-ink); }
.acc-hint-btn { min-height: 34px; padding: 0 12px; font-size: 12.5px; }

.acc-rights { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel); }
.acc-right { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 56px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.acc-right:last-child { border-bottom: 0; }
.acc-right-txt { display: grid; gap: 2px; flex: 1; min-width: 0; cursor: pointer; }

/* ------------------------------------------------------------ activity (detail drawer, compact list, log) */
.acc-detail { display: grid; gap: 18px; min-width: 0; }
.acc-detail-sec { display: grid; gap: 8px; min-width: 0; }
.acc-detail-sec .form-section { margin: 0; }
.acc-summary { margin: 0; overflow-wrap: anywhere; font-size: 13.5px; }
.acc-path { overflow-wrap: anywhere; font-size: 12.5px; }
.acc-kv dd { overflow-wrap: anywhere; }
.acc-val { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; }
.acc-diff td { vertical-align: top; overflow-wrap: anywhere; }
.acc-diff td:first-child { width: 28%; }
.acc-before { background: var(--danger-soft); }
.acc-after { background: var(--ok-soft); }
.acc-json { margin: 0; padding: 10px 12px; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.acc-sum { overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; max-width: 560px; }

.acc-act { display: grid; gap: 10px; min-width: 0; }
.acc-act-list { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel); }
.acc-act-row { display: grid; grid-template-columns: 84px auto minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; min-height: 44px; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line-2); background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.acc-act-row:last-child { border-bottom: 0; }
.acc-act-row:hover { background: var(--panel-2); }
.acc-act-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.acc-act-sum { min-width: 0; overflow-wrap: anywhere; font-size: 13.5px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.acc-act-all { justify-self: start; min-height: 40px; }

/* ------------------------------------------------------------ phone */
@media (max-width: 600px) {
  .acc-grid { border: 0; gap: 10px; overflow: visible; background: transparent; }
  .acc-row { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
  .acc-row:last-child { border-bottom: 1px solid var(--line); }
  .acc-lvl span { min-height: 44px; }
  .acc-hint-btn { min-height: 40px; }
  .acc-right { padding-block: 12px; }
  .acc-act-row { grid-template-columns: auto minmax(0, 1fr); }
  .acc-act-sum { grid-column: 1 / -1; }
  .acc-chip span { padding: 0 14px; }
}
