/*
 * components/dashboard.css — Composite/page-level patterns (modern theme).
 * Loaded site-wide via header.php in the modern theme branch and
 * directly by global/twComponents.php for the style guide.
 */

/* ── Page layout helpers ────────────────────────────────────────────────── */

/* `.page` indents its body content by 12px so paragraphs/forms/buttons line up
   with the section-heading's text (which has 12px internal padding). The
   section-heading itself bleeds back out with -12px margins so its banner edge
   stays aligned with the navigation bar. */
.page {
   max-width: var(--page-max-width); 
   padding: 0 12px; 
  }
.page-help {
   color: var(--color-muted); 
   margin-bottom: 1rem; 
  }
.form-actions {
   margin-top: 1rem; 
   margin-bottom: 1.5rem; 
  }
.section {
   margin-top: 2rem; 
  }

/* Section heading — opt-in class for h2s that should look like menu group bars
   (rounded, page-width, matched padding). Scoped under `div.content` to beat
   base.css's `div.content h2` defaults without `!important`.
   Two contexts handled:
     * Standalone (no .page wrapper, e.g. global/index.php) — sits at margin-left: 2px
       like `h2:has(+ ul.blockmenu)` so it lines up with menu-block h2s.
     * Inside `.page` (which has 12px side padding) — bleed back -12px so the bar
       edge aligns with the page chrome and the body text below the heading sits at
       the same x-position as the heading's inner text. */
div.content h2.section-heading {
  max-width: var(--page-max-width);
  margin: 0 auto 6px 2px;
  border-radius: var(--radius-md);
  /* padding: 6px 12px; */
}
div.content .page > h2.section-heading {
  margin: 0 -12px 6px;
}

/* ── Stat grid (responsive wrapper for stat-card tiles) ─────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  max-width: var(--page-max-width);
}

/* ── Stat cards (dashboard metric tiles) ────────────────────────────────── */

.stat-card {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 0 1px 4px rgba(92, 99, 105, 0.1);
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(92, 99, 105, 0.18);
}
.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.25;
}
.stat-card .stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}
.stat-card .stat-freshness {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  font-style: italic;
  margin-top: 0.25rem;
}
.stat-card .stat-freshness-live { color: #16a34a; }
.stat-card .stat-desc {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  margin-top: 0.25rem;
}

/* Lazy-loaded preview tile in pvmMetricManagement.php — clickable placeholder until AJAX fills it. */
.metric-preview-card { cursor: pointer; }

/* Inline picker form (label + narrow select on one line). */
.picker-form { margin-bottom: 0.75rem; }
.picker-form .form-select,
.picker-form .ComboInput {
  width: auto;
  display: inline-block;
  margin-left: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: var(--color-bg);
  color: var(--color-text);
  padding: 0.4rem 0.75rem;
  font-size: var(--font-size-sm);
  font-family: var(--font-base);
}

/* Anchor variant — strip default link styling, keep card look (clickable tiles). */
a.stat-card,
a.stat-card:hover {
  text-decoration: none;
  color: inherit;
}

/* ── Picker (drag-and-drop list assigner) ───────────────────────────────── */

.pick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.pick-grid h4 {
  margin: 0 0 0.5rem 0;
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pick-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  min-height: 80px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-bg);
}
.pick-list:empty::after {
  content: "Drop here";
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  display: block;
  text-align: center;
  padding: 1.25rem;
  opacity: 0.6;
}
.pick-list.pick-drop-hover {
  background-color: var(--color-row-alt);
  border-color: var(--color-accent);
}

.pick-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
}
.pick-item:last-child { margin-bottom: 0; }
.pick-item-shown { cursor: grab; }
.pick-item-shown:active { cursor: grabbing; }

.pick-handle {
  color: var(--color-muted);
  cursor: grab;
  user-select: none;
  font-size: 1rem;
  line-height: 1;
}
.pick-title {
  flex: 1 1 auto;
  font-weight: 500;
  color: var(--color-text);
}
.pick-desc {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: normal;
  color: var(--color-muted);
  margin-top: 0.125rem;
}
.pick-action {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius);
}
.pick-action:hover {
  color: var(--color-accent);
  background-color: var(--color-row-alt);
}

/* "All Companies" inheritance badge — visible only while sitting in Shown,
   so dragging an inherited item out (suppressing it) hides the badge. */
.pick-badge { margin-left: auto; }
.pick-item-available .pick-badge { display: none; }

/* Stale assignment — metric was assigned to a role that's no longer in its
   GetAllowedGroups() list. Subtle red left-border accent (works in both themes). */
.pick-item-restricted { border-left: 3px solid #dc2626; }

/* sortable placeholder during drag */
.pick-placeholder {
  height: 38px;
  margin-bottom: 0.25rem;
  border: 1px dashed var(--color-accent);
  border-radius: var(--radius);
  background-color: var(--color-row-alt);
}

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  flex-direction: column;
}

.tabs-nav {
  display: flex;
  gap: 0.125rem;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 0.5rem 1rem;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 200ms, border-color 200ms;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--color-heading-text);
}
.tab-btn.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}
