/*
 * Dashboard layout
 * Only app-shell layout lives here. All components (cards, buttons, badges,
 * progress, forms, colors, typography) come from Silicon's theme.min.css.
 */

:root {
  --dash-sidebar-width: 256px;   /* Portal: the design's 260px, a touch narrower now the nav items are smaller */
  /* Portal: the canvas matches the sidebar (the theme's body background) instead of the design's #f3f6ff. */
  --dash-canvas-bg: var(--si-body-bg);
}
[data-bs-theme="dark"] {
  --dash-canvas-bg: var(--si-body-bg);
}

/* ---------- Sidebar ---------- */
.dash-sidebar .offcanvas-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding: 1.5rem 1.25rem;
  overflow-y: auto;
}

@media (min-width: 992px) {
  .dash-sidebar {
    position: fixed !important;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--dash-sidebar-width);
    height: 100vh;
    z-index: 1030;
    display: flex !important;
    flex-direction: column;
    box-shadow: none !important;
  }
  .dash-sidebar .offcanvas-body {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 auto !important;
    padding: 1.5rem 1.25rem !important;
    overflow-y: auto !important;
  }
  .dash-main {
    margin-left: var(--dash-sidebar-width);
  }
}

.dash-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .75rem;         /* Portal: well under the design's .75rem 1rem - the portal's menu is long */
  margin-bottom: .0625rem;
  font-size: .875rem;
  border-radius: var(--si-border-radius-lg);
  color: var(--si-body-color);
  font-weight: 500;
  transition: color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
/* Portal: in light mode the links sit a little darker than the body text - part way from gray-700 to gray-800. */
[data-bs-theme="light"] .dash-nav .nav-link:not(.active):not(:hover) {
  color: color-mix(in srgb, var(--si-gray-700) 55%, var(--si-gray-800));
}
.dash-nav .nav-link > i {
  font-size: 1.125rem;
  opacity: .7;
}
.dash-nav .nav-link:hover {
  color: var(--si-primary);
  background-color: rgba(var(--si-primary-rgb), .08);
}
/* Portal: a quieter active state than the design's solid primary pill - a tint, the primary text, no glow. */
.dash-nav .nav-link.active {
  color: var(--si-primary);
  font-weight: 600;
  background-color: rgba(var(--si-primary-rgb), .12);
  box-shadow: none;
}
.dash-nav .nav-link.active > i {
  opacity: 1;
}

/*
 * Portal: a dark navy rail. The sidebar carries data-bs-theme="dark", so the theme's own dark tokens (muted labels,
 * the close button, borders) apply inside it while the page stays in whichever mode the person chose. The navy is a
 * shade of the EACML blue, not the theme's near-black; in dark mode it sits a step above the page (#0b0f19) so the
 * rail stays distinct. The primary blue reads poorly on navy, so links go white on a translucent tint instead.
 */
.dash-sidebar[data-bs-theme="dark"] {
  --dash-rail-bg: #0c2a47;
  background-color: var(--dash-rail-bg) !important;
  border-color: rgba(255, 255, 255, .06) !important;
  color-scheme: dark;
}
[data-bs-theme="dark"] .dash-sidebar[data-bs-theme="dark"] {
  --dash-rail-bg: #111d2e;
}
.dash-sidebar[data-bs-theme="dark"] .offcanvas-header {
  border-color: rgba(255, 255, 255, .08) !important;
}
.dash-sidebar[data-bs-theme="dark"] .dash-nav > span.text-muted {
  color: rgba(255, 255, 255, .45) !important;
  letter-spacing: .04em;
}
.dash-sidebar[data-bs-theme="dark"] .dash-nav .nav-link:not(.active):not(:hover) {
  color: rgba(255, 255, 255, .72);
}
.dash-sidebar[data-bs-theme="dark"] .dash-nav .nav-link:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, .07);
}
.dash-sidebar[data-bs-theme="dark"] .dash-nav .nav-link.active {
  color: #fff;
  background-color: rgba(var(--si-primary-rgb), .55);
}
.dash-sidebar[data-bs-theme="dark"] .dash-nav .nav-link.active > i {
  color: #9fd0f5;
}
/* An open dropdown's parent is marked text-primary in the template; on navy that is the light blue, not the brand blue. */
.dash-sidebar[data-bs-theme="dark"] .dash-nav .nav-link.text-primary {
  color: #9fd0f5 !important;
}
/* A closed dropdown with counts inside gets a dot; Bootstrap drops .collapsed when it opens, and the dot goes with it. */
.dash-nav-dot {
  display: none;
  width: .5rem;
  height: .5rem;
  flex-shrink: 0;
  border-radius: 50%;
  background-color: var(--si-warning);
  box-shadow: 0 0 0 .1875rem rgba(var(--si-warning-rgb), .2);
}
.dash-nav .nav-link.collapsed .dash-nav-dot {
  display: inline-block;
}
.dash-sidebar[data-bs-theme="dark"] .offcanvas-body {
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

/* ---------- Main canvas ---------- */
.dash-main {
  min-height: 100vh;
  background-color: var(--dash-canvas-bg);
}

.dash-topbar {
  background-color: var(--si-body-bg);
  z-index: 1020;
}

.dash-search {
  max-width: 22rem;
}

/* ---------- Cards ---------- */
/* Portal: on the white canvas a card needs its edge, so it keeps the theme border (as in dark mode) plus the shadow. */
.dash-card {
  border: var(--si-border-width) solid var(--si-border-color);
  box-shadow: var(--si-box-shadow-sm);
}
[data-bs-theme="dark"] .dash-card {
  border: var(--si-border-width) solid var(--si-border-color);
  box-shadow: none;
}

.dash-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  color: #fff;
  font-size: 1.25rem;
}

.dash-legend-dot {
  display: inline-block;
  flex-shrink: 0;
  width: .625rem;
  height: .625rem;
  border-radius: 50%;
}

.dash-progress {
  height: .375rem;
  min-width: 6rem;
}

/* ---------- Map ---------- */
.dash-map {
  height: 230px;
}
.dash-map-scale {
  display: flex;
  gap: 2px;
}
.dash-map-scale > span {
  flex: 1;
  height: .5rem;
}
.dash-map-scale > span:first-child { border-radius: 4px 0 0 4px; }
.dash-map-scale > span:last-child  { border-radius: 0 4px 4px 0; }

.jvm-tooltip {
  font-family: inherit;
  font-size: .8125rem;
  padding: .375rem .625rem;
  border-radius: var(--si-border-radius);
  background-color: var(--si-gray-900, #0b0f19);
  box-shadow: var(--si-box-shadow);
}

/* ApexCharts tooltip follows Silicon's typography */
.apexcharts-tooltip,
.apexcharts-xaxistooltip {
  font-family: inherit !important;
}

/* ---------------------------------------------------------------------------------------------------------
   Site checklists (templates/inspection/checklist_fill.html, static/js/checklist.js)
   An answer is an outline button filled in its tone once chosen, and the item carries a bar down its edge in
   the same tone, so a long form reads at a glance while scrolling.
   --------------------------------------------------------------------------------------------------------- */
.rating-btn[aria-checked="true"] { color: #fff !important; border-color: transparent !important; }
.rating-btn[aria-checked="true"][data-tone="success"] { background-color: var(--si-success) !important; }
.rating-btn[aria-checked="true"][data-tone="danger"]  { background-color: var(--si-danger) !important; }
.rating-btn[aria-checked="true"][data-tone="neutral"] { background-color: var(--si-gray-600) !important; }
.checklist-item { transition: background-color .2s; outline: none; }
.checklist-item[data-rating="pass"] { box-shadow: inset 3px 0 0 var(--si-success); }
.checklist-item[data-rating="fail"] { box-shadow: inset 3px 0 0 var(--si-danger); }
.checklist-item[data-rating="na"]   { box-shadow: inset 3px 0 0 var(--si-border-color); }
.checklist-item.is-current { background-color: var(--si-secondary-bg); }
.checklist-item.is-flagged { background-color: rgba(var(--si-warning-rgb), .1); }
.checklist-item.is-pending [data-saved] { color: var(--si-warning) !important; }

/* Card titles (class="h5 fw-semibold text-nav"): a step under Silicon's 1.25rem h5, on every page */
.h5.fw-semibold.text-nav { font-size: 1.125rem; }

/* Staff dashboard pipeline funnel (templates/dashboard/admin.html): each step's width is its share of the busiest
   step, but on a phone that leaves no room for the label, so the steps go full width there. */
.funnel-step { width: 100%; }
@media (min-width: 576px) { .funnel-step { width: var(--step-width, 100%); } }

/* Lets a flex child shrink below its content, so .text-truncate inside it can cut the text (Bootstrap has no such
   utility; the portal templates use it wherever a name sits in a flex row). */
.min-w-0 { min-width: 0 !important; }

/* The submission stage strip on the upload page (templates/project/upload_document.html) slides with its arrow
   buttons beside the Active badge (static/js/workspace.js), so it shows no scrollbar of its own. */
[data-stage-track] { scrollbar-width: none; }
[data-stage-track]::-webkit-scrollbar { display: none; }
