/* ==========================================================================
   RBAC-CMS Prototype — Design Tokens
   Theme: "control room" — dark ink sidebar, warm paper content area,
   role colors double as the wayfinding system throughout the app.
   ========================================================================== */

:root {
  --ink: #1b222c;
  --ink-soft: #262f3b;
  --paper: #f7f5f1;
  --paper-card: #ffffff;
  --line: #e4dfd5;
  --text: #232b36;
  --text-dim: #6b7280;
  --text-inverse: #f2efe8;

  --amber: #c98a3e;      /* admin */
  --amber-soft: #f4e3c8;
  --teal: #3e8e8a;       /* mod */
  --teal-soft: #d9ece9;
  --slate: #5b6b8c;      /* user */
  --slate-soft: #e1e6f0;

  --danger: #b3492f;
  --danger-soft: #f6ddd5;
  --success: #3e8e5c;
  --success-soft: #dcefe2;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(27,34,44,0.06), 0 8px 24px -12px rgba(27,34,44,0.18);

  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 4px; letter-spacing: -0.01em; }
p { margin: 0 0 8px; line-height: 1.55; }
a { color: inherit; }
code, .mono { font-family: var(--font-mono); }

button, input, select, textarea { font-family: inherit; font-size: 14px; }

::selection { background: var(--amber-soft); }

/* focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 15% -10%, #2a3444 0%, transparent 60%),
    var(--ink);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px 26px;
}

.login-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.login-mark .dot-stack { display: flex; gap: 4px; }
.login-mark .dot-stack span {
  width: 9px; height: 9px; border-radius: 50%; display: block;
}
.login-mark .dot-stack span:nth-child(1) { background: var(--amber); }
.login-mark .dot-stack span:nth-child(2) { background: var(--teal); }
.login-mark .dot-stack span:nth-child(3) { background: var(--slate); }
.login-mark strong { font-family: var(--font-display); font-size: 16px; }

.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--paper); color: var(--text);
}
.field textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: transform .06s ease, opacity .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--text-inverse); }
.btn-primary:hover { opacity: .92; }
.btn-full { width: 100%; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.login-error {
  background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; margin-bottom: 14px; display: none;
}
.login-error.show { display: block; }

.demo-accounts {
  margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--text-dim);
}
.demo-accounts .row { display: flex; justify-content: space-between; padding: 3px 0; }
.demo-accounts strong { color: var(--text); font-family: var(--font-mono); }

/* ---------------------------------------------------------------------- */
/* App shell                                                              */
/* ---------------------------------------------------------------------- */

.app-shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--ink); color: var(--text-inverse);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 9px; padding: 4px 8px 20px;
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
}
.sidebar .brand .dot-stack { display: flex; gap: 4px; }
.sidebar .brand .dot-stack span { width: 8px; height: 8px; border-radius: 50%; }
.sidebar .brand .dot-stack span:nth-child(1) { background: var(--amber); }
.sidebar .brand .dot-stack span:nth-child(2) { background: var(--teal); }
.sidebar .brand .dot-stack span:nth-child(3) { background: var(--slate); }

.nav-group { margin-bottom: 18px; }
.nav-group .nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: #8b93a3; padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  font-size: 13.5px; color: #cdd3de; cursor: pointer; margin-bottom: 2px; border: none;
  background: transparent; width: 100%; text-align: left;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--ink-soft); color: #fff; }
.nav-item.active { background: var(--ink-soft); color: #fff; box-shadow: inset 2px 0 0 var(--amber); }
.nav-item .locked-badge { margin-left: auto; font-size: 10px; color: #6b7280; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid #313b48; }
.who {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px 10px;
}
.who .avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--ink);
  flex-shrink: 0;
}
.who .meta { min-width: 0; }
.who .meta .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .meta .role { font-size: 11px; color: #9aa2b1; }

/* ---------------------------------------------------------------------- */
/* Main content                                                           */
/* ---------------------------------------------------------------------- */

.main { padding: 26px 34px 60px; max-width: 1080px; }
.topbar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.topbar h1 { font-size: 22px; }
.topbar .desc { color: var(--text-dim); font-size: 13.5px; }
.topbar-actions { display: flex; gap: 8px; }

.card {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; margin-bottom: 10px; }
.card + .card { margin-top: 0; }

.toast-msg {
  position: fixed; top: 18px; right: 18px; background: var(--ink); color: var(--text-inverse);
  padding: 11px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-6px); transition: all .2s ease; pointer-events: none; z-index: 50;
}
.toast-msg.show { opacity: 1; transform: translateY(0); }

/* role pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.role-admin { background: var(--amber-soft); color: #8a5a1e; }
.pill.role-admin .dot { background: var(--amber); }
.pill.role-mod { background: var(--teal-soft); color: #235f5c; }
.pill.role-mod .dot { background: var(--teal); }
.pill.role-user { background: var(--slate-soft); color: #3c4a6b; }
.pill.role-user .dot { background: var(--slate); }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); padding: 8px 10px; border-bottom: 1px solid var(--line);
}
tbody td { padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfaf7; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-dim);
}
.empty-state .glyph { font-size: 26px; margin-bottom: 8px; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(27,34,44,0.45); display: none;
  align-items: center; justify-content: center; z-index: 40; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--paper-card); border-radius: var(--radius); padding: 22px 24px;
  width: 100%; max-width: 440px; box-shadow: var(--shadow); max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* content page list / viewer */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.page-tile {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--paper-card);
  cursor: pointer; transition: box-shadow .15s ease, transform .1s ease;
}
.page-tile:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.page-tile.locked { opacity: .55; cursor: not-allowed; }
.page-tile .tile-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.page-tile h4 { font-size: 14.5px; }
.page-tile p { font-size: 12.5px; color: var(--text-dim); margin: 0; }
.page-tile .lock-icon { font-size: 15px; }

.page-viewer { max-width: 640px; }
.page-viewer .body-text { white-space: pre-wrap; line-height: 1.7; font-size: 14.5px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-dim); cursor: pointer; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }

/* permission matrix (signature element) */
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; }
.matrix th, .matrix td { padding: 10px 12px; text-align: center; font-size: 13px; }
.matrix thead th { background: var(--paper); border-bottom: 1px solid var(--line); }
.matrix thead th:first-child, .matrix tbody td:first-child { text-align: left; font-weight: 600; }
.matrix tbody td { border-bottom: 1px solid var(--line); }
.matrix .yes { color: var(--success); font-weight: 700; }
.matrix .no { color: var(--text-dim); }
.matrix .current-col { background: #fbf8f1; }

.access-try { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; }
.access-try .result { margin-left: auto; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.access-try .result.allow { background: var(--success-soft); color: var(--success); }
.access-try .result.deny { background: var(--danger-soft); color: var(--danger); }

.hint { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }

.log-item { display: flex; gap: 10px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.log-item:last-child { border-bottom: none; }
.log-item .t { color: var(--text-dim); font-family: var(--font-mono); flex-shrink: 0; }

.badge-count {
  background: var(--ink); color: #fff; border-radius: 999px; font-size: 10.5px;
  padding: 1px 7px; margin-left: 6px;
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; align-items: center; }
  .sidebar .brand, .sidebar-foot { display: none; }
  .nav-group { display: flex; margin-bottom: 0; margin-right: 10px; }
  .nav-group .nav-label { display: none; }
  .main { padding: 18px 16px 50px; }
}
