/**
 * src/css/pages/admin-cloud.css — Cloud Permissions admin matrix
 * (admin-cloud.html).
 *
 * Owns: admin-cloud.html only. Consumes tokens from design-system.css
 * (read-only reference — "Industrial Modern" token sheet, loaded before
 * this file). Quality bar: src/css/pages/index.css (project cards) — same
 * elevation/hover/entrance-animation craft applied here to the legend,
 * search input, table, and per-user cards. Loaded LAST so it wins
 * equal-specificity ties against the Tailwind CDN utility classes and this
 * page's own small inline <style> block (sidebar-collapse mechanics only,
 * copied byte-identical from cloud.html — no page-specific component CSS
 * remains inline).
 *
 * This page is deliberately self-contained (does NOT load
 * src/css/pages/admin.css, which is scoped to admin.html/admin-users.html/
 * admin-projects.html/admin-system.html only) — its shell mechanics
 * (sidebar/topbar/breadcrumb-ish header) are copied from cloud.html's own
 * inline block instead, per the task's "do not touch existing admin.*
 * pages" boundary.
 */

#adminCloudPage *, #adminCloudPage *::before, #adminCloudPage *::after { box-sizing: border-box; }

/* ── Shared visibility gate (JS toggles this one class; CSS media queries
   below independently decide which of #acTableWrap / #acCards is ever
   visible AT ALL for the current viewport — see the breakpoint block at
   the bottom of this file) ─────────────────────────────────────────────── */
.ac-hidden { display: none !important; }

/* ── Breadcrumb (byte-identical pattern to admin.css's .admin-breadcrumb,
   duplicated here rather than imported since this page does not load
   admin.css) ───────────────────────────────────────────────────────────── */
.ac-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--text-3);
  margin-bottom: 10px;
}
.ac-breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  text-decoration: none;
  transition: color var(--dur-1) var(--ease-std);
}
.ac-breadcrumb a:hover { color: var(--navy-500); }
.ac-breadcrumb .material-symbols-outlined { font-size: 16px; }
.ac-breadcrumb .current { color: var(--navy-500); font-weight: 600; }

/* ── Page header text ────────────────────────────────────────────────── */
.ac-eyebrow {
  font-size: var(--fs-11);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-4);
  margin: 0 0 4px;
}
.ac-title {
  font-size: var(--fs-24);
  font-weight: 700;
  color: var(--navy-500);
  letter-spacing: var(--tracking-tight);
  margin: 0;
}
.ac-subtitle {
  font-size: var(--fs-14);
  color: var(--text-3);
  margin: 4px 0 0;
}

/* ── Buttons (scoped copies of design-system.css's dp-btn--ghost look, so
   this page needs no Tailwind-only fallback) ──────────────────────────── */
.ac-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--touch);
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  font-size: var(--fs-14);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease-std), border-color var(--dur-1) var(--ease-std);
}
.ac-btn--ghost {
  background: var(--surface-0);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.ac-btn--ghost:hover { background: var(--surface-100); border-color: var(--surface-300); }

/* ── Legend ──────────────────────────────────────────────────────────── */
.ac-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-13);
  color: var(--text-2);
}
.ac-legend-item { display: inline-flex; align-items: center; gap: 8px; }
.ac-dot { width: 9px; height: 9px; border-radius: var(--r-full); flex-shrink: 0; }
.ac-dot--auto   { background: var(--surface-400); }
.ac-dot--hidden { background: var(--danger); }
.ac-dot--ro     { background: var(--warning); }
.ac-dot--rw     { background: var(--success); }

/* ── Search ──────────────────────────────────────────────────────────── */
.ac-search-wrap {
  position: relative;
  max-width: 360px;
  margin-bottom: var(--sp-5);
}
.ac-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  font-size: 18px !important;
  pointer-events: none;
}
.ac-search-input {
  width: 100%;
  min-height: var(--touch);
  padding: 0 var(--sp-4) 0 38px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-0);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-14);
  transition: border-color var(--dur-1) var(--ease-std), box-shadow var(--dur-1) var(--ease-std);
}
.ac-search-input::placeholder { color: var(--text-4); }
.ac-search-input:focus {
  outline: none;
  border-color: var(--navy-400);
  box-shadow: 0 0 0 3px var(--ring-navy);
}

/* ── Loading skeleton / empty / error states (same craft as dp-empty /
   dp-skeleton-card in design-system.css, scoped copies so this page has no
   cross-file coupling beyond the token variables) ─────────────────────── */
@keyframes ac-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.ac-skeleton {
  height: 52px;
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface-100) 25%, var(--surface-200) 37%, var(--surface-100) 63%);
  background-size: 400% 100%;
  animation: ac-shimmer 1.4s ease infinite;
  margin-bottom: var(--sp-3);
}
.ac-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-16) var(--sp-6);
  text-align: center;
  color: var(--text-3);
}
.ac-empty .material-symbols-outlined {
  font-size: 40px;
  color: var(--surface-300);
}
.ac-empty-title {
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--text-2);
  margin: 0;
}
@media (prefers-reduced-motion: reduce) {
  .ac-skeleton { animation: none; }
}

/* ── Desktop matrix table ────────────────────────────────────────────── */
.ac-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  overflow: auto;
  max-height: calc(100vh - 380px);
  min-height: 200px;
}
.ac-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-13);
}
.ac-th {
  position: sticky;
  top: 0;
  z-index: var(--z-raised);
  background: var(--bg-subtle);
  color: var(--text-2);
  font-weight: 700;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ac-th--user {
  position: sticky;
  left: 0;
  z-index: calc(var(--z-raised) + 1);
  min-width: 220px;
}
.ac-row:hover .ac-td { background: var(--bg-subtle); }
.ac-td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  transition: background var(--dur-1) var(--ease-std);
}
.ac-td--user {
  position: sticky;
  left: 0;
  z-index: var(--z-raised);
  background: var(--bg-card);
  min-width: 220px;
}
.ac-row:hover .ac-td--user { background: var(--bg-subtle); }
.ac-row:last-child .ac-td { border-bottom: none; }

.ac-user-name {
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.ac-user-email {
  font-size: var(--fs-12);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.ac-td--locked {
  color: var(--text-3);
  font-style: italic;
}
.ac-locked-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: 600;
  font-style: normal;
}
.ac-locked-pill .material-symbols-outlined { font-size: 15px; }

/* ── Mode <select> (used in BOTH table cells and mobile cards) ──────── */
.ac-select {
  width: 100%;
  min-width: 150px;
  min-height: 36px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-0);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-13);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-std), box-shadow var(--dur-1) var(--ease-std), opacity var(--dur-1) var(--ease-std);
}
.ac-select:hover:not(:disabled) { border-color: var(--surface-300); }
.ac-select:focus {
  outline: none;
  border-color: var(--navy-400);
  box-shadow: 0 0 0 3px var(--ring-navy);
}
.ac-select:disabled { opacity: 0.55; cursor: wait; }

/* ── Mobile per-user cards ───────────────────────────────────────────── */
.ac-cards {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.ac-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  padding: var(--sp-4);
}
.ac-card-head { margin-bottom: var(--sp-3); }
.ac-card-head .ac-user-name,
.ac-card-head .ac-user-email { max-width: none; white-space: normal; }
.ac-locked-pill--card { margin-top: var(--sp-1); }
.ac-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-soft);
}
.ac-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.ac-card-row-label {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}
.ac-card-row .ac-select { max-width: 180px; }

/* ── Toast (byte-identical pattern to cloud.css's .cloud-toast) ─────── */
.ac-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--navy-500);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--r-full);
  font-size: var(--fs-14);
  font-weight: 500;
  box-shadow: var(--sh-lg);
  z-index: var(--z-toast);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ac-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Breakpoint: table on md+, cards below md ───────────────────────── */
@media (min-width: 768px) {
  .ac-cards { display: none !important; }
}
@media (max-width: 767px) {
  .ac-table-wrap { display: none !important; }
  .ac-legend { gap: var(--sp-3); font-size: var(--fs-12); }
}
