/**
 * Arbor (K5) — Admin/Ops Dashboard Styles
 *
 * All colour and type comes from ../shared/brand.css (Brandbook §3/§4).
 * No hard-coded hex lives in this file; the archived CohortTrials teal
 * (#1F6F6B / #155551 / #E2F0EF) has been removed entirely.
 */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

/* `hidden` must win over the layout rules below (.login-container is flex). */
[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  background: var(--chalk);
  color: var(--bark);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Native dialogs (focus trap + ESC come for free) ---- */
dialog {
  border: none; border-radius: 12px;
  padding: 24px; max-width: 480px; width: calc(100% - 32px);
  background: var(--paper); color: var(--bark);
  font-family: var(--font-body);
  box-shadow: 0 12px 32px rgba(42, 42, 42, 0.25);
}
dialog::backdrop { background: rgba(26, 75, 58, 0.45); }
dialog h2 { margin-bottom: 12px; font-size: var(--fs-h3); }
dialog p { margin-bottom: 4px; }
#notifyMessage, #confirmMessage { white-space: pre-line; }
dialog .dialog-actions,
dialog .modal-actions {
  display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px;
}
dialog .dialog-actions .btn,
dialog .modal-actions .btn { min-height: 44px; }
.modal-dialog { max-width: 520px; }
.modal-dialog.modal-wide { max-width: 680px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 20px;
}
.modal-header h2 { margin-bottom: 0; }
.modal-close {
  background: none; border: none;
  font-size: 1.5rem; line-height: 1;
  color: var(--stone); cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius);
}
.modal-close:hover { color: var(--danger); background: var(--danger-bg); }

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--grove);
  color: var(--paper);
  padding: 0 24px;
  min-height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-family: var(--font-heading); font-size: 1.125rem; font-weight: 600; }
/* Mist at full opacity: 8.9:1 on Grove. White at 75% measured 4.11:1. */
.topbar-subtitle { font-size: var(--fs-small); color: var(--mist); margin-left: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: var(--fs-small); color: var(--mist); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--fs-small);
  font-weight: 600;
  padding: 10px 20px;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--grove); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: var(--canopy); }
.btn-outline { background: transparent; color: var(--paper); border: 1.5px solid var(--mist); }
.btn-outline:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.btn-outline-dark { background: transparent; color: var(--grove); border: 1.5px solid var(--border-input); }
.btn-outline-dark:hover:not(:disabled) { background: var(--mist); }
.btn-danger { background: var(--danger); color: var(--paper); }
.btn-danger:hover:not(:disabled) { filter: brightness(0.88); }
.btn-sm { padding: 6px 14px; font-size: var(--fs-micro); }
.btn-xs { padding: 4px 10px; font-size: var(--fs-micro); }
.btn-full { width: 100%; }

.btn-link {
  background: none; border: none; padding: 4px 0;
  color: var(--grove); font-family: var(--font-body);
  font-size: var(--fs-small); font-weight: 600;
  text-decoration: underline; cursor: pointer;
}
.btn-link:hover { color: var(--canopy); }

/* ---- Login / MFA ---- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  padding: 24px;
}
.login-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-card);
}
.login-card h1 { font-size: var(--fs-h2); margin-bottom: 4px; }
.login-subtitle { color: var(--stone); margin-bottom: 24px; font-size: var(--fs-small); }
.login-links { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; align-items: flex-start; }

.session-notice {
  background: var(--flint-surface); color: var(--flint-text);
  border: 1px solid var(--flint);
  border-radius: var(--radius); padding: 10px 14px;
  font-size: var(--fs-small); margin-bottom: 16px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: var(--fs-small); font-weight: 600;
  color: var(--bark); margin-bottom: 6px;
}
.field input, .select, .textarea, .field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius);
  font-size: var(--fs-body);
  color: var(--bark);
  background: var(--paper);
  transition: border-color 0.15s;
  font-family: var(--font-body);
}
.field input:hover, .select:hover, .textarea:hover, .field textarea:hover { border-color: var(--canopy); }
.field input:disabled { background: var(--mist); color: var(--stone-on-mist); }
.textarea, .field textarea { resize: vertical; min-height: 96px; }
.error-msg { color: var(--danger); font-size: var(--fs-small); min-height: 20px; margin-bottom: 8px; }

/* ---- Admin Layout ---- */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
}

/* ---- Sidebar ---- */
.sidebar {
  width: 220px;
  background: var(--paper);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
}
.nav-list { list-style: none; }
.nav-list li { margin-bottom: 2px; }
.nav-link {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 24px;
  color: var(--bark);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.nav-link:hover {
  background: var(--chalk);
  color: var(--grove);
}
.nav-link.active {
  background: var(--mist);
  color: var(--grove);
  font-weight: 700;
  border-left-color: var(--grove);
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1100px;
  min-width: 0;
}

/* ---- Disclaimer Banner ----
   --flint-text on --flint-surface measures 6.05:1 (the previous
   #9A6B00 on #FBF0D6 pairing measured 4.14:1). */
.disclaimer-banner {
  background: var(--flint-surface);
  color: var(--flint-text);
  border: 1px solid var(--flint);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: var(--fs-small);
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}

/* ---- Pages ---- */
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: var(--fs-h2); }
.page-title:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 4px; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-actions { display: flex; align-items: center; gap: 12px; }

/* ---- Loading ---- */
.loading-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-small); color: var(--stone);
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--lichen); border-top-color: var(--canopy);
  animation: arbor-spin 0.7s linear infinite;
}
@keyframes arbor-spin { to { transform: rotate(360deg); } }

/* ---- Status Cards (Health) ---- */
.status-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.status-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  text-align: center;
  border-top: 4px solid var(--lichen);
}
.status-card.up { border-top-color: var(--ok); }
.status-card.down { border-top-color: var(--danger); }
.status-card-name {
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--stone);
  margin-bottom: 8px;
}
.status-card-status {
  font-family: var(--font-heading);
  font-size: var(--fs-h2);
  font-weight: 600;
}
.status-card.up .status-card-status { color: var(--ok); }
.status-card.down .status-card-status { color: var(--danger); }

/* ---- Panels ---- */
.panel {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.panel h2, .panel h3 { font-size: var(--fs-h3); margin-bottom: 12px; }
.panel-sub { color: var(--stone); font-size: var(--fs-small); margin-bottom: 8px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
thead th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--stone);
  font-weight: 700;
  text-transform: uppercase;
  font-size: var(--fs-micro);
  letter-spacing: 0.04em;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--mist); }
tbody tr:hover { background: var(--chalk); }
.table-empty { color: var(--stone); text-align: center; font-style: italic; }

/* ---- Chips ---- */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
}
.chip-green { background: var(--ok-bg); color: var(--ok); }
.chip-red   { background: var(--danger-bg); color: var(--danger); }
.chip-amber { background: var(--warn-bg); color: var(--warn); }
.chip-gray  { background: var(--mist); color: var(--stone-on-mist); }
.chip-blue  { background: var(--mist); color: var(--grove); }

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: var(--fs-micro); font-weight: 600; color: var(--bark); }
.input-filter {
  padding: 8px 12px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  color: var(--bark);
  background: var(--paper);
  min-width: 160px;
}
.input-filter:hover { border-color: var(--canopy); }
.select-filter {
  padding: 8px 12px;
  min-width: 160px;
  font-size: var(--fs-small);
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pagination button {
  padding: 6px 14px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--grove);
  transition: background 0.12s;
}
.pagination button:hover:not(:disabled) { background: var(--mist); }
.pagination button.active {
  background: var(--grove);
  color: var(--paper);
  border-color: var(--grove);
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pagination .page-info {
  font-size: var(--fs-small);
  color: var(--stone);
}

/* ---- Auto Refresh Label ---- */
.auto-refresh-label {
  font-size: var(--fs-micro);
  color: var(--stone-on-mist);
  padding: 4px 10px;
  background: var(--mist);
  border-radius: 12px;
}

/* ---- Criteria Result ---- */
.criteria-preview {
  background: var(--chalk);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  max-height: 300px;
  overflow-y: auto;
  font-size: var(--fs-small);
}
.criteria-result-head { font-weight: 600; margin-bottom: 8px; white-space: normal; }
.criteria-preview .criterion-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.criteria-preview .criterion-item:last-child { border-bottom: none; }
.criterion-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  margin-right: 8px;
}
.criterion-type.inclusion { background: var(--ok-bg); color: var(--ok); }
.criterion-type.exclusion { background: var(--danger-bg); color: var(--danger); }

.text-muted { color: var(--stone); font-size: var(--fs-small); }

/* ---- Pending Criteria Review (C10) ---- */
.pending-review-list { max-height: 400px; overflow-y: auto; margin: 12px 0; }
.pending-review-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.pending-review-item:last-child { border-bottom: none; }
.pending-review-text { margin: 8px 0; font-size: var(--fs-small); color: var(--bark); white-space: normal; }
.pending-review-actions { display: flex; gap: 8px; }

/* ---- Health Meta ---- */
#healthMeta { font-size: var(--fs-small); color: var(--bark); }
#healthMeta .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--mist);
}
#healthMeta .meta-label { font-weight: 600; color: var(--stone); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .nav-list {
    display: flex;
    overflow-x: auto;
    gap: 0;
  }
  .nav-link {
    width: auto;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 8px 16px;
    white-space: nowrap;
  }
  .nav-link.active {
    border-left-color: transparent;
    border-bottom-color: var(--grove);
  }
  .main-content { padding: 16px; }
  .status-cards { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-field { width: 100%; }
  .input-filter, .select-filter { min-width: 0; width: 100%; }
}

@media (max-width: 480px) {
  .status-cards { grid-template-columns: 1fr; }
}
