/*
  Inwall Admin, redesign mockup — dashboard-specific components only.
  Reuses every token and shared class from css/styles.css (the Inwall
  design system); this file adds only what a back-office app shell
  needs on top of it: app sidebar, topbar, stat tiles, key/value table.
  Static prototype, no backend — data below mirrors what's visible in
  the real admin.inwall.app "Users & Access" screen, for a faithful
  before/after comparison.
*/

html, body { height: 100%; }
body { background: var(--color-bg); }

.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */

.app-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--brand-900);
  color: var(--neutral-0);
  display: flex;
  flex-direction: column;
  padding: var(--space-6) var(--space-4);
}

.app-sidebar .brand-word { color: var(--neutral-0); margin-bottom: var(--space-8); }
.app-sidebar .brand-word .brand-sub { display: none; }

.app-nav-group {
  font-family: var(--font-family-ui);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.45);
  margin: var(--space-5) var(--space-2) var(--space-2);
}

.app-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.app-nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0; flex-shrink: 0; }

.app-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }

.app-nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-weight: 700;
}
.app-nav a.active .dot { opacity: 1; background: var(--brand-400); }

/* ---------- Main column ---------- */

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-8);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface-tint);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  width: 320px;
  color: var(--color-text-subtle);
  font-size: 0.9rem;
}
.app-search svg { width: 16px; height: 16px; flex-shrink: 0; }

.app-topbar-actions { display: flex; align-items: center; gap: var(--space-4); }

.app-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gradient-hero);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0;
}

.app-content { padding: var(--space-8); max-width: 1180px; }

.app-content h1 {
  font-family: var(--font-family-display);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.app-breadcrumb { font-size: 0.85rem; color: var(--color-text-subtle); margin-bottom: var(--space-2); }
.app-breadcrumb a { color: var(--brand-500); text-decoration: none; }

.app-desc { color: var(--color-text-subtle); font-size: 0.95rem; margin: 0 0 var(--space-6); }

/* ---------- Stat tiles ---------- */

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); margin-bottom: var(--space-6); }

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-5) var(--space-6);
}

.stat-tile .stat-label { font-size: 0.82rem; color: var(--color-text-subtle); margin-bottom: 6px; }

.stat-tile .stat-value {
  font-family: var(--font-family-display);
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-heading);
  font-variant-numeric: tabular-nums;
}

/* ---------- Key/value panel (Users by Role / Status) ---------- */

.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); margin-bottom: var(--space-6); }

.kv-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.kv-panel h3 {
  margin: 0;
  padding: var(--space-4) var(--space-5);
  font-size: 0.95rem;
  background: var(--color-surface-tint);
  border-bottom: 1px solid var(--color-border);
}

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--color-border);
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k { font-weight: 600; color: var(--color-heading); }
.kv-row .v { font-family: var(--font-family-mono); color: var(--color-text); }

/* ---------- Actions row ---------- */

.actions-row { display: flex; gap: var(--space-3); margin-bottom: var(--space-6); }

/* ---------- Data table panel ---------- */

.data-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.data-panel h3 { margin: 0; padding: var(--space-5); font-size: 1rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.data-panel h3 .count { font-weight: 400; color: var(--color-text-subtle); font-size: 0.85rem; }
.cell-sub { display: block; font-size: 0.78rem; color: var(--color-text-subtle); margin-top: 2px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.page-head > div { flex: 1; }
.page-head h1, .page-head .app-breadcrumb, .page-head .app-desc { margin-bottom: 0; }
.page-head .app-desc { margin-top: 8px; }
.data-panel table { font-size: 0.88rem; }
.data-panel th, .data-panel td { border-bottom: 1px solid var(--color-border); padding: var(--space-3) var(--space-5); }
.data-panel th { background: transparent; color: var(--color-text-subtle); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-panel tr:last-child td { border-bottom: none; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.status-pill.active,
.status-pill.approved { background: var(--success-100); color: var(--success-700); }
.status-pill.active::before,
.status-pill.approved::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success-700); }

.status-pill.pending { background: var(--warning-100); color: var(--warning-700); }
.status-pill.pending::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warning-700); }

.status-pill.system { background: var(--neutral-100); color: var(--color-text); }

.status-pill.role { background: var(--brand-100); color: var(--brand-700); }

/* ---------- Table row actions ---------- */

.row-actions { display: flex; gap: var(--space-2); }

.row-link {
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.row-link.edit { color: var(--brand-700); border-color: var(--brand-300); background: var(--brand-100); }
.row-link.danger { color: var(--critical-500); border-color: #F4C4D3; background: var(--color-error-tint); }

/* ---------- Code cell (permission keys) ---------- */

.code-cell { font-family: var(--font-family-mono); font-size: 0.82rem; color: var(--brand-700); font-weight: 600; }

/* ---------- Select field ---------- */

.select-field {
  appearance: none;
  font-family: var(--font-family-ui);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-heading);
  background: var(--color-surface) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"><path d="M6 9l6 6 6-6" stroke="%235B5F7A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat right 14px center;
  background-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 40px 10px 14px;
  min-width: 180px;
}

.filter-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}
.filter-panel .filter-label { font-weight: 700; font-size: 0.9rem; margin-bottom: var(--space-2); display: block; }

.empty-row td { text-align: center; color: var(--color-text-subtle); background: var(--color-surface-tint); padding: var(--space-6); }

.compare-banner {
  background: var(--brand-100);
  border: 1px solid var(--brand-300);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  font-size: 0.9rem;
  color: var(--brand-700);
}
.compare-banner strong { color: var(--color-heading); }

@media (max-width: 980px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; }
  .stat-row, .panel-row { grid-template-columns: 1fr; }
  .app-search { width: 200px; }
}
