/*
    Org chart - stylesheet.

    ============================================================================
    EVERYTHING DOWN TO THE "SITE-SPECIFIC" MARKER IS SHARED.

    A deliberate, unchanged copy of the shared block at the top of
    it-reporting/src/styles.css (itself copied from MCA Auditor): the Metrc
    palette, the topbar, the control bar, the pill buttons. The plan is to extract
    that block into a common IT.Site folder; keeping every copy identical is what
    makes that a move rather than a rewrite. Change it in all of them or none.
    ============================================================================
*/


/*
    The `hidden` attribute is honoured only by the user-agent stylesheet, which
    any author-level `display` declaration beats. Several components below set
    display:flex, so without this `hidden` on them is silently ignored.
*/
[hidden] { display: none !important; }

:root {
  --deep-forest: #213f39;
  --forest-mid: #6B7F7B;
  --forest-pale: #DADFDE;
  --sage: #C8DCCA;
  --sage-mid: #DAE8DC;
  --sage-pale: #EDF3ED;
  --kelly: #149F69;
  --highlighter: #E9F800;
  --peach: #FF9D6F;
  --cream: #F5F3E7;
  --mocha: #D6C4B6;
  --white: #ffffff;
  --clay: #B4632F;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--cream);
  color: var(--deep-forest);
  font-family: Inter, "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

button, select, input { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  background: var(--deep-forest);
  color: var(--sage);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  flex: none;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--white);
  letter-spacing: -0.01em;
}

.stat-strip { margin-left: auto; display: flex; gap: 20px; }

.stat { text-align: right; line-height: 1.15; }
.stat b {
  display: block;
  font-size: 16px;
  color: var(--white);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stat span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--forest-pale);
}

/* ---------- control bar ---------- */

.controls {
  background: var(--white);
  border-bottom: 1px solid var(--forest-pale);
  padding: 9px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: none;
}

.chip-group { display: flex; gap: 4px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--forest-pale);
  background: var(--white);
  border-radius: 999px;
  padding: 5px 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--deep-forest); }
.chip[aria-pressed="true"] {
  background: var(--deep-forest);
  color: var(--sage);
  border-color: var(--deep-forest);
}
.chip:focus-visible { outline: 2px solid var(--kelly); outline-offset: 1px; }
.chip:disabled { opacity: 0.45; cursor: not-allowed; }

.divider { width: 1px; height: 22px; background: var(--forest-pale); }

.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--forest-mid);
}

.ghost-button {
  border: 1px solid var(--deep-forest);
  background: transparent;
  border-radius: 999px;
  padding: 5px 13px;
  cursor: pointer;
}
.ghost-button:hover { background: var(--deep-forest); color: var(--sage); }

select, input[type="date"] {
  background: var(--white);
  border: 1px solid var(--forest-pale);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}
select:hover, input[type="date"]:hover { border-color: var(--deep-forest); }

.muted { color: var(--forest-mid); }
.nowrap { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/*
    ============================================================================
    SITE-SPECIFIC - everything below belongs to the org chart alone.

    Ported from org-chart/design/org-chart-mockup.html, the approved design, with its
    colour variables mapped onto the shared palette above:
      --forest -> --deep-forest   --forest-tone -> --forest-mid
      --forest-light -> --forest-pale   --sage-light -> --sage-pale
    ============================================================================
*/

/* The mockup is white and 14px with near-black text; the shared block is cream and 13px. */
body {
  background: var(--white);
  color: #1b1b1b;
  font-size: 14px;
}

/* ---------- top bar ---------- */

.topbar { min-height: 52px; padding: 8px 20px; gap: 6px 16px; }
/*
    The logo is branding/Registered_DF-Logo.png recoloured to Sage, as the brand
    guide asks on Deep Forest, and sized to 24px high (112px wide; the guide's
    digital minimum is 100px). The 24px gap before "Org chart" is the guide's
    clear space: one shield width.
*/
.topbar .wordmark { display: flex; align-items: center; font-size: 17px; color: var(--sage); }
.topbar .wordmark .logo { display: block; height: 24px; width: auto; }
.topbar .wordmark span { font-weight: 400; opacity: .75; margin-left: 24px; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; opacity: .85; }

/* The way back to links.it.metrc.com. Plain text, like the signed-in name beside it. */
.topbar-link {
  color: var(--sage);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.topbar-link:hover { border-bottom-color: var(--sage); }
.topbar-link:focus-visible { outline: 2px solid var(--highlighter); outline-offset: 2px; }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 10px;
  flex-wrap: wrap;
  flex: none;
}
.toolbar .spacer { flex: 1; }
#count { font-size: 13px; }

.search-wrap { position: relative; width: 340px; max-width: 100%; }
#search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--forest-mid);
  border-radius: 6px;
  outline: none;
  background: var(--white);
}
#search:focus { border-color: var(--deep-forest); box-shadow: 0 0 0 2px var(--sage); }
.search-wrap kbd {
  position: absolute; right: 8px; top: 7px;
  font: 12px Inter, sans-serif; color: var(--forest-mid);
  border: 1px solid var(--forest-pale); border-radius: 4px; padding: 1px 6px;
  pointer-events: none;
}
#search-results {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; right: 0;
  margin: 0; padding: 4px 0; list-style: none;
  background: var(--white); border: 1px solid var(--forest-pale); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(33, 63, 57, .12);
}
#search-results li { padding: 6px 12px; cursor: pointer; display: flex; flex-direction: column; }
#search-results li .muted { font-size: 12px; }
#search-results li.active { background: var(--sage-pale); }
#search-results li.empty { cursor: default; }

/* The mockup's pill buttons are the shared .ghost-button; "My position" is the highlighter one. */
.ghost-button { font-weight: 500; color: var(--deep-forest); background: var(--white); padding: 6px 14px; }
.ghost-button.primary { background: var(--highlighter); border-color: var(--highlighter); }
.ghost-button.primary:hover { background: var(--deep-forest); border-color: var(--deep-forest); color: var(--highlighter); }
.ghost-button:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost-button:disabled:hover { background: var(--white); color: var(--deep-forest); }
.ghost-button.primary:disabled:hover { background: var(--highlighter); border-color: var(--highlighter); color: var(--deep-forest); }
.ghost-button:focus-visible { outline: 2px solid var(--kelly); outline-offset: 1px; }

.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-left: 6px; cursor: pointer; }
.toggle input { accent-color: var(--deep-forest); }

/* ---------- status and errors ---------- */

.status { margin: 14px 20px; color: var(--forest-mid); }
.error {
  margin: 14px 20px;
  padding: 10px 14px;
  border: 1px solid var(--forest-pale);
  border-left: 3px solid var(--clay);
  border-radius: 6px;
  max-width: 760px;
}

/* ---------- reporting line ---------- */

#reporting-line {
  margin: 0 20px 10px;
  padding: 10px 14px;
  background: var(--sage-pale);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  min-height: 44px;
  flex: none;
}
#reporting-line .chain a { color: var(--deep-forest); text-decoration: none; }
#reporting-line .chain a:hover { text-decoration: underline; }
#reporting-line .separator { color: var(--forest-mid); margin: 0 8px; }
.selected-meta { display: flex; align-items: center; gap: 4px 12px; font-size: 13px; flex-wrap: wrap; min-width: 0; }
.selected-meta > span { overflow-wrap: anywhere; }
.text-button {
  font: 500 13px Inter, sans-serif; color: var(--deep-forest);
  background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline;
  white-space: nowrap;
}

/* ---------- tree grid ---------- */

.grid-wrap { flex: 1; overflow: auto; margin: 0 20px 14px;border: 1px solid var(--forest-pale); border-radius: 6px; }
.grid { min-width: 980px; }
.row, .header-row {
  display: grid;
  grid-template-columns: minmax(300px, 2.2fr) minmax(200px, 1.6fr) minmax(170px, 1.2fr) 120px minmax(220px, 1.4fr);
}
.header-row {
  position: sticky; top: 0; z-index: 2;
  background: var(--deep-forest); color: var(--white);
  font-weight: 500; font-size: 12px;
}
.header-row > div { padding: 8px 10px; }
.row { border-bottom: 1px solid #eef0ef; cursor: default; }
.row:hover { background: #f7f9f7; }
.row.selected { background: var(--sage-mid); box-shadow: inset 3px 0 0 var(--deep-forest); }
.row:focus { outline: none; }
.row:focus-visible { box-shadow: inset 0 0 0 2px var(--deep-forest); }
.cell { padding: 0 10px; height: 34px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cell.muted { font-size: 13px; }
.cell-text { overflow: hidden; text-overflow: ellipsis; }
.name-cell { padding-left: 6px; }
.guide { flex: none; width: 20px; align-self: stretch; border-left: 1px solid var(--forest-pale); margin-left: 9px; margin-right: -9px; }
.twisty, .twisty-spacer { flex: none; width: 20px; height: 20px; margin-right: 4px; }
.twisty {
  border: none; background: none; color: var(--deep-forest); cursor: pointer; padding: 0;
  font-size: 12px; line-height: 20px; border-radius: 4px;
}
.twisty:hover { background: var(--sage); }
.person-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.report-count { flex: none; margin-left: 8px; font-size: 12px; color: var(--forest-mid); }
.tag {
  flex: none; margin-left: 8px;
  font-size: 11px; font-weight: 500; color: var(--deep-forest);
  border: 1px solid var(--deep-forest); border-radius: 999px; padding: 0 7px; line-height: 17px;
}
.email-copy {
  font: 13px Inter, sans-serif; color: var(--deep-forest);
  background: none; border: none; padding: 2px 4px; margin-left: -4px; border-radius: 4px;
  cursor: copy; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
}
.email-copy:hover { text-decoration: underline; }
.email-copy.copied { background: var(--highlighter); text-decoration: none; font-weight: 500; }

/* ---------- Tree | Chart switch ---------- */

.view-switch { display: inline-flex; border: 1px solid var(--deep-forest); border-radius: 999px; overflow: hidden; }
.view-switch button {
  font: 500 13px Inter, sans-serif; color: var(--deep-forest); background: var(--white);
  border: none; padding: 6px 16px; cursor: pointer;
}
.view-switch button + button { border-left: 1px solid var(--deep-forest); }
.view-switch button[aria-pressed="true"] { background: var(--deep-forest); color: var(--sage); }
.view-switch button:focus-visible { outline: 2px solid var(--kelly); outline-offset: -3px; }

/* ---------- chart view ---------- */

.chart-viewport {
  position: relative; flex: 1; min-height: 0; margin: 0 20px 14px; overflow: hidden;
  border: 1px solid var(--forest-pale); border-radius: 6px;
  background-color: #fbfbfa;
  background-image: radial-gradient(#e2e5e4 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab; touch-action: none; user-select: none;
}
.chart-viewport.dragging { cursor: grabbing; }
#chart-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.chart-lines { position: absolute; left: 0; top: 0; overflow: visible; }
.chart-lines path { fill: none; stroke: #9aa7a4; stroke-width: 1.5; }

/* Card colours are set per card from config/departments.json: a tint fill, the full colour as border. */
.card {
  position: absolute; width: 240px; height: 84px;
  border: 1.5px solid; border-radius: 8px; padding: 8px 10px;
  display: flex; gap: 8px; align-items: flex-start;
  cursor: pointer; overflow: visible;
}
/* Focus first, selection after: a selected card is also focused, and must keep its Deep Forest outline. */
.card:focus { outline: none; }
.card:focus-visible { outline: 2px solid var(--kelly); outline-offset: 2px; }
.card.selected, .card.selected:focus, .card.selected:focus-visible { outline: 3px solid var(--deep-forest); outline-offset: 2px; }

.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; background: var(--forest-pale);
}
.avatar-initials {
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font: 600 13px Inter, sans-serif; letter-spacing: .02em;
}
.card-text { min-width: 0; flex: 1; }
.card-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; display: flex; align-items: center; }
.card-name .person-name { overflow: hidden; text-overflow: ellipsis; }
.card-title { font-size: 12px; line-height: 1.3; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-department { font-size: 11px; font-weight: 500; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; filter: brightness(.75); }
.tag-small { font-size: 10px; line-height: 15px; padding: 0 6px; background: var(--white); margin-left: 6px; }
.card-toggle {
  position: absolute; left: 50%; bottom: -11px; transform: translateX(-50%);
  min-width: 26px; height: 20px; padding: 0 6px;
  font: 600 11px Inter, sans-serif; color: var(--deep-forest);
  background: var(--white); border: 1.5px solid; border-radius: 999px; cursor: pointer;
}
.card-toggle:hover { background: var(--deep-forest); color: var(--white); border-color: var(--deep-forest) !important; }
.card-toggle:focus-visible { outline: 2px solid var(--kelly); outline-offset: 1px; }

.chart-controls {
  position: absolute; right: 12px; top: 12px; display: flex; gap: 4px; align-items: center;
  background: var(--white); border: 1px solid var(--forest-pale); border-radius: 6px; padding: 4px;
}
.chart-controls button {
  font: 500 13px Inter, sans-serif; color: var(--deep-forest); background: none;
  border: none; border-radius: 4px; padding: 4px 9px; cursor: pointer;
}
.chart-controls button:hover { background: var(--sage-pale); }
.chart-controls button:focus-visible { outline: 2px solid var(--kelly); outline-offset: 1px; }
#zoom-level { font-size: 12px; color: var(--forest-mid); min-width: 38px; text-align: center; }

.legend {
  position: absolute; left: 12px; bottom: 12px; max-height: calc(100% - 24px); overflow: auto;
  background: var(--white); border: 1px solid var(--forest-pale); border-radius: 6px; padding: 8px 12px; font-size: 12px;
}
#legend-toggle { font: 500 12px Inter, sans-serif; color: var(--deep-forest); background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; }
.legend-group { margin-top: 8px; }
.legend-group-label { font-weight: 700; color: var(--deep-forest); margin-bottom: 2px; }
.legend-item { display: flex; align-items: center; line-height: 18px; }
.swatch { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; }
