/* ---------- Estate app switcher (nine dots) ----------
   Transcribed from CC-IT_Dashboard docs/handoffs/switcher-canonical.md (v2.1) --
   that file is the single source of truth. Ported from CC-Comar_Compliance
   app/static/app.css §App switcher. Loaded after app.css (see _head.html).

   Every value is the canonical literal or a --mg-* token whose value is IDENTICAL
   to it (teal #17A38C, teal-deep #0E7C6B, teal-tint #E2F3EF, teal-tint-border
   #B9E0D7, ink-hover #2E3836, ink-text #B9C2BF, ink-text-strong #E8ECEA,
   row-hover #F6FAF9, text #222927, text-2 #5A6461, text-muted #6B7370, border
   #DDE1DF, amber trio, radius 4px, radius-md 6px, shadow-float). The font stack
   is written out: --font-sans is Arial-first, and canonical v2.1 dropped
   'Helvetica Neue' (partial installs render 600+ as condensed oblique).

   base.html mounts the partial TWICE: .switcher--foot in the dark rail foot and
   .switcher--head in the light top bar. Exactly one is visible at any width. */

/* The rail foot is estate chrome too: canonical stack (overrides app.css). */
.sidebar-foot { font-family: Helvetica, Arial, sans-serif; }

/* Trigger + panel share ONE position:relative wrapper, so the panel is never
   clipped by .nav's scroller or any other overflow box (§3). */
.switcher { position: relative; display: inline-flex; flex: none; }

/* --- 1. the dots trigger (the <summary> IS the button) --- */
.switcher-btn {
  display: inline-flex;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  list-style: none;
  transition: background-color 80ms linear, color 80ms linear, border-color 80ms linear;
}
.switcher-btn::-webkit-details-marker { display: none; }
.switcher-btn::marker { content: ""; }
.switcher-glyph { display: grid; grid-template-columns: repeat(3, 3px); gap: 3px; }
.switcher-dot { width: 3px; height: 3px; border-radius: 999px; background: currentColor; }

/* 0. focus ring, :focus-visible only. box-shadow cancels app.css's global
   button/a focus ring so only the canonical outline shows. */
.switcher-btn:focus-visible,
.switcher-pill:focus-visible,
.switcher-app:focus-visible {
  outline: 2px solid #17A38C;
  outline-offset: 1px;
  border-radius: 3px;
  box-shadow: none;
}

/* Per-surface trigger colors; hover and open share one treatment (§1). */
.switcher--foot > .switcher-btn { color: #B9C2BF; }
.switcher--foot > .switcher-btn:hover,
.switcher--foot[open] > .switcher-btn,
.switcher--foot.is-open > .switcher-btn { background: #2E3836; color: #E8ECEA; }
.switcher--head > .switcher-btn { color: #6B7370; }
.switcher--head > .switcher-btn:hover,
.switcher--head[open] > .switcher-btn,
.switcher--head.is-open > .switcher-btn { background: #F6FAF9; color: #222927; }

/* --- 3. the panel: one opaque box, never scrolls or clips --- */
.switcher-panel {
  position: absolute;
  width: 268px;
  padding: 10px;
  background: #FFFFFF;
  color: #222927;
  border: 1px solid #DDE1DF;
  border-radius: 6px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.14);
  z-index: 40;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
}
/* Rail foot: opens UPWARD, left-aligned. */
.switcher--foot .switcher-panel { bottom: calc(100% + 6px); left: 0; }
/* Top bar: opens DOWNWARD, right-anchored. */
.switcher--head .switcher-panel { top: calc(100% + 6px); right: 0; max-width: calc(100vw - 28px); }

/* --- 4. head row: "Switch Sites" + the Sign out pill (always rendered) --- */
.switcher-head-row { display: flex; align-items: center; gap: 8px; padding: 0 6px 8px; }
.switcher-head-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6B7370;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.switcher-signout { margin: 0; flex: none; }
/* The app's ONE sign-out affordance: submit of the POST /auth/logout form. */
.switcher-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid #17A38C;
  border-radius: 999px;
  background: #17A38C;
  color: #FFFFFF;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.5;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 80ms linear, color 80ms linear, border-color 80ms linear;
}
.switcher-pill:hover { background: #0E7C6B; border-color: #0E7C6B; color: #FFFFFF; }

/* --- 5. the tile grid --- */
.switcher-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.switcher-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
  transition: background-color 80ms linear, color 80ms linear, border-color 80ms linear;
}
.switcher-name { line-height: 1.2; }
a.switcher-app { color: #5A6461; text-decoration: none; }
a.switcher-app:hover { background: #F6FAF9; border-color: #B9E0D7; color: #222927; text-decoration: none; }
a.switcher-app:hover .switcher-icon { color: #0E7C6B; }
.switcher-app.is-current {
  background: #E2F3EF;
  border-color: #B9E0D7;
  color: #0E7C6B;
  font-weight: 600;
  cursor: default;
}
.switcher-app.is-current .switcher-icon { color: #0E7C6B; }
.switcher-icon { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; color: #6B7370; }
.switcher-icon svg { width: 24px; height: 24px; display: block; }
.switcher-letter { font-size: 13px; font-weight: 700; }
.switcher-maint {
  display: inline-block;
  margin-top: 2px;
  padding: 2px 6px;
  border: 1px solid #E8D89A;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #8A6D1F;
  background: #FBF3D9;
}

/* Desktop-first: the head mount is the narrow-width one. */
.switcher--head { display: none; }

/* <=840px the rail hides behind the hamburger, so the dots move to the
   always-visible top bar (§2). Hiding the foot mount also keeps ONE pill. */
@media (max-width: 840px) {
  .switcher--head { display: inline-flex; }
  .switcher--foot { display: none; }
}

/* Under 380px the head panel narrows and tiles go 2-up (§3). */
@media (max-width: 379px) {
  .switcher--head .switcher-panel { width: 208px; }
  .switcher--head .switcher-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Chrome never prints (§6). */
@media print {
  .switcher, .no-print { display: none !important; }
}
