/* ============================================================
   SKAS Portal — Shell v2 styles
   Injected header menus + fixed collapsible sidebar.
   Everything is sk- prefixed and only applies when <body> has
   .sk-active, so the legacy UI is untouched when the shell is off.
   ============================================================ */

:root {
  --sk-sidebar-w: 210px;
  --sk-sidebar-w-collapsed: 54px;
  --sk-top: 88px; /* overwritten by shell.js with measured nav height */
  --sk-accent: #4f46e5;
  --sk-accent-soft: #eef2ff;
  --sk-text: #1e293b;
  --sk-text-muted: #64748b;
  --sk-border: #e2e8f0;
}

/* ---------- Top-bar grouped menus (inserted into existing nav) ---------- */

#skTopMenus {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sk-menu { position: relative; }

.sk-menu > button {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sk-text-muted);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sk-menu > button:hover,
.sk-menu.open > button { background: #f1f5f9; color: var(--sk-text); }

.sk-menu .sk-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 230px;
  background: #ffffff;
  border: 1px solid var(--sk-border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 6px;
  z-index: 400;
}

.sk-menu.open .sk-dropdown { display: block; }

.sk-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--sk-text);
  padding: 10px 14px;
  border-radius: 9px;
  cursor: pointer;
}

.sk-dropdown button:hover { background: var(--sk-accent-soft); color: var(--sk-accent); }

.sk-logout-btn {
  border: 1px solid var(--sk-border);
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sk-text-muted);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  margin-left: 6px;
}

.sk-logout-btn:hover { color: #dc2626; border-color: #fecaca; }

/* ---------- Sidebar ---------- */

#skSidebar {
  position: fixed;
  left: 0;
  top: var(--sk-top);
  bottom: 0;
  width: var(--sk-sidebar-w);
  background: #f8fafc;
  border-right: 1px solid var(--sk-border);
  padding: 12px 8px 8px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 40;
  transition: width 0.18s ease;
}

body.sk-collapsed #skSidebar { width: var(--sk-sidebar-w-collapsed); padding-left: 6px; padding-right: 6px; }

/* Push the dashboard content right of the rail */
body.sk-active #reportSection { padding-left: var(--sk-sidebar-w); transition: padding-left 0.18s ease; }
body.sk-active.sk-collapsed #reportSection { padding-left: var(--sk-sidebar-w-collapsed); }
/* Keep the sticky header full-bleed above the rail */
body.sk-active #reportSection > nav { margin-left: calc(-1 * var(--sk-sidebar-w)); padding-left: calc(1.5rem + var(--sk-sidebar-w)); }
body.sk-active.sk-collapsed #reportSection > nav { margin-left: calc(-1 * var(--sk-sidebar-w-collapsed)); padding-left: calc(1.5rem + var(--sk-sidebar-w-collapsed)); }

.sk-group-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  margin: 14px 10px 6px;
  white-space: nowrap;
}

.sk-group-label:first-child { margin-top: 2px; }
body.sk-collapsed .sk-group-label { visibility: hidden; height: 6px; margin: 8px 0 2px; }

/* #466 (Sean 11/22): section headings fold / unfold their section */
.sk-group-toggle { display: flex; align-items: center; justify-content: space-between; width: calc(100% - 20px); background: none; border: none; padding: 0; cursor: pointer; font-family: inherit; text-align: left; }
.sk-group-toggle:hover { color: #475569; }
.sk-group-toggle .sk-group-caret { font-size: 9px; transition: transform 0.15s ease; }
.sk-group-toggle.closed .sk-group-caret { transform: rotate(-90deg); }
.sk-group-items.closed { display: none; }
body.sk-collapsed .sk-group-items.closed { display: block; }   /* icon rail: no headings, so nothing is folded away */
body.sk-collapsed .sk-group-toggle { pointer-events: none; }

.sk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--sk-text-muted);
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  overflow: visible;
  position: relative;
}

.sk-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sk-item:hover { background: #eef2f7; color: var(--sk-text); }
.sk-item.active { background: var(--sk-accent-soft); color: var(--sk-accent); font-weight: 700; }

/* Collapsible sub-group (e.g. Outreach -> Mothership IN/OUT) */
.sk-caret { margin-left: auto; font-size: 9px; opacity: .65; transition: transform .15s ease; }
.sk-parent.open .sk-caret { transform: rotate(180deg); }
.sk-subitems { display: none; }
.sk-parent.open + .sk-subitems { display: block; }
.sk-subitem { padding-left: 34px; font-size: 12.5px; }
body.sk-collapsed .sk-caret { display: none; }
body.sk-collapsed .sk-subitems { display: none !important; }

/* Redundant homepage buttons — these actions now live under the Actions menu.
   !important overrides the inline display set by index.html's hideButtonIf(). */
body.sk-active button[onclick="openAddClient()"],
body.sk-active button[onclick="openSignup()"],
body.sk-active #logHoursBodyWrap { display: none !important; }

/* Data / Reports / Billing now open as Insights sidebar tabs, so hide the old
   top-bar dropdown buttons. !important beats hideDropdownIfEmpty()'s inline style. */
body.sk-active #dataDropdownWrap,
body.sk-active #reportsDropdownWrap,
body.sk-active #billingDropdownWrap { display: none !important; }

body.sk-collapsed .sk-item { justify-content: center; padding: 10px 0; }
body.sk-collapsed .sk-item .sk-item-label { display: none; }

body.sk-collapsed .sk-item:hover::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  white-space: nowrap;
  z-index: 500;
  pointer-events: none;
}

/* ---------- Collapse toggle ---------- */

.sk-collapse-btn {
  margin-top: auto;
  border: none;
  background: transparent;
  color: var(--sk-text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}

.sk-collapse-btn:hover { background: #eef2f7; color: var(--sk-text); }
.sk-collapse-btn svg { width: 16px; height: 16px; flex-shrink: 0; transition: transform 0.18s ease; }
body.sk-collapsed .sk-collapse-btn { justify-content: center; }
body.sk-collapsed .sk-collapse-btn svg { transform: rotate(180deg); }
body.sk-collapsed .sk-collapse-btn .sk-item-label { display: none; }

/* ---------- Small screens: force icon rail ---------- */

@media (max-width: 900px) {
  body.sk-active #skSidebar { width: var(--sk-sidebar-w-collapsed); }
  body.sk-active #reportSection { padding-left: var(--sk-sidebar-w-collapsed); }
  body.sk-active #reportSection > nav { margin-left: calc(-1 * var(--sk-sidebar-w-collapsed)); padding-left: calc(1.5rem + var(--sk-sidebar-w-collapsed)); }
  body.sk-active .sk-group-label { visibility: hidden; height: 6px; margin: 8px 0 2px; }
  body.sk-active .sk-group-items.closed { display: block; }   /* #466: icon rail shows everything */
  body.sk-active .sk-group-toggle { pointer-events: none; }
  body.sk-active .sk-item { justify-content: center; padding: 10px 0; }
  body.sk-active .sk-item .sk-item-label { display: none; }
}

/* ---------- #465 (Sean 2026-11-23): ONE header row at the far left; SMALL only while Leonidas is open ----------
   Sean 11/23: with Leonidas open the bar wrapped to two rows and covered the left menu; then "merge the headers ... all
   the options in a single line beside the SKAS NAME: CLIENT ID", "merge everything to the far left", "make it like that
   all the time", "only make it small when leonidas is open". So on screens >= 900px the bar is one row at the far LEFT
   (logo, NAME / CLIENT ID, then every option beside it) at its normal size; while the Leonidas panel is open the same row
   is made compact so it fits beside the panel. Overrides the #354 wrap rule in leonidas.js. Phones (< 900px) and the
   legacy nav (?newnav=0, no body.sk-active) are untouched. */
@media (min-width: 900px) {
  /* layout, always: one row, far left */
  body.sk-active #reportSection > nav { padding-left: 16px !important; padding-right: 12px !important; }
  body.sk-active.sk-collapsed #reportSection > nav { padding-left: 16px !important; }
  body.sk-active #reportSection > nav > div { flex-wrap: nowrap !important; row-gap: 0 !important; column-gap: 18px !important; max-width: none !important; margin: 0 !important; justify-content: flex-start !important; }
  body.sk-active #reportSection > nav h1 { flex: 0 0 auto !important; }
  body.sk-active #activeClientLabel { white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; min-width: 0 !important; }
  body.sk-active #skTopMenus { flex-wrap: wrap !important; row-gap: 4px !important; margin-left: 0 !important; min-width: 0 !important; justify-content: flex-start !important; flex: 1 1 0 !important; }   /* one line when it fits; wraps instead of running off the screen - the coach "Viewing:" box (Sean 11/23) */
  body.sk-active #skTopMenus .sk-menu > button, body.sk-active #skTopMenus #cpHubBtn, body.sk-active #skTopMenus .sk-logout-btn { white-space: nowrap !important; }

  /* size, only while Leonidas is open */
  body.leo-side #reportSection > nav { padding-top: 6px !important; padding-bottom: 6px !important; padding-left: 12px !important; padding-right: 8px !important; }
  body.leo-side #reportSection > nav > div { column-gap: 14px !important; }
  body.leo-side #reportSection > nav h1 { gap: 5px !important; }
  body.leo-side #headerLogo { height: 28px !important; }
  body.leo-side #activeClientLabel { font-size: 9px !important; letter-spacing: .02em !important; line-height: 1.3 !important; }
  body.leo-side #skTopMenus { gap: 1px !important; }
  body.leo-side #skTopMenus .sk-menu > button { font-size: 10px !important; letter-spacing: .01em !important; padding: 5px 5px !important; gap: 3px !important; }
  body.leo-side #skHelpDeskMenu > button > svg { display: none !important; }
  body.leo-side #skTopMenus .skv-toggle { margin-left: 2px !important; padding: 1px !important; }
  body.leo-side #skTopMenus .skv-toggle button { font-size: 8.5px !important; padding: 3px 5px !important; letter-spacing: .01em !important; }
  body.leo-side #skTopMenus #cpHubBtn { font-size: 9.5px !important; padding: 3px 7px !important; margin-right: 0 !important; margin-left: 2px !important; }
  body.leo-side #skTopMenus .sk-logout-btn { font-size: 9.5px !important; padding: 4px 7px !important; letter-spacing: .02em !important; margin-left: 3px !important; }
  body.leo-side #leoMenu { display: none !important; }
}
/* panel open (Sean 11/23 "keep the navigation bar in line with Client Management System. keep SKAS and client info to
   the left"): SKAS + NAME / CLIENT ID stay at the far left, the options start on the same line as the page title
   (the left menu's width + 40px). Not with the menu collapsed (too little room for the logo + name) or below 1200px. */
@media (min-width: 1200px) {
  body.leo-side:not(.sk-collapsed) #reportSection > nav > div { column-gap: 0 !important; }
  body.leo-side:not(.sk-collapsed) #reportSection > nav h1 { flex: 0 0 auto !important; width: calc(var(--sk-sidebar-w) + 40px - 12px) !important; }
}
/* (panel closed on a narrower screen used to wrap here - replaced by ONE ROW, ALWAYS below, Sean 11/24) */
/* panel open on a narrower screen: "Help Desk" -> "Help", "Client Messages" -> "Messages" (the counts stay) */
@media (min-width: 900px) and (max-width: 1250px) {
  body.leo-side #skTopMenus #skHelpDeskMenu > button { font-size: 0 !important; }
  body.leo-side #skTopMenus #skHelpDeskMenu > button::before { content: "Help"; font-size: 10px; }
  body.leo-side #skHelpDeskMenu > button > span { font-size: 9px !important; }
  body.leo-side #skTopMenus #cpHubBtn { font-size: 0 !important; }
  body.leo-side #skTopMenus #cpHubBtn::before { content: "Messages"; font-size: 9.5px; }
  body.leo-side #skTopMenus #cpHubBtn > span { font-size: 9.5px !important; }
}

/* ONE ROW, ALWAYS (Sean 11/24: "all of navigation should be on one row"). >= 900px the bar never wraps; shell.js (fitTop)
   adds sk-fit1..3 to <body> only while the options would not fit at full size. */
@media (min-width: 900px) {
  body.sk-active #reportSection > nav > div { flex-wrap: nowrap !important; row-gap: 0 !important; }
  body.sk-active #skTopMenus { flex-wrap: nowrap !important; row-gap: 0 !important; }
  /* step 1: compact spacing (the same sizes as with Leonidas open) */
  body.sk-fit1 #reportSection > nav > div { column-gap: 12px !important; }
  body.sk-fit1 #skTopMenus { gap: 1px !important; }
  body.sk-fit1 #skTopMenus .sk-menu > button { font-size: 10px !important; letter-spacing: .01em !important; padding: 5px 5px !important; gap: 3px !important; }
  body.sk-fit1 #skHelpDeskMenu > button > svg { display: none !important; }
  body.sk-fit1 #skTopMenus .skv-toggle { margin-left: 2px !important; padding: 1px !important; }
  body.sk-fit1 #skTopMenus .skv-toggle button { font-size: 8.5px !important; padding: 3px 5px !important; letter-spacing: .01em !important; }
  body.sk-fit1 #skTopMenus #cpHubBtn { font-size: 9.5px !important; padding: 3px 7px !important; margin-right: 0 !important; margin-left: 2px !important; }
  body.sk-fit1 #skTopMenus .sk-logout-btn { font-size: 9.5px !important; padding: 4px 7px !important; letter-spacing: .02em !important; margin-left: 3px !important; }
  body.sk-fit1 #kpiTopBtn { font-size: 10px !important; padding: 5px 5px !important; letter-spacing: .01em !important; }
  body.sk-fit1 #clientSwitcherWrap { gap: 4px !important; }
  body.sk-fit1 #clientSwitcherSelect { font-size: 10px !important; padding: 4px 6px !important; }
  /* step 2: short labels, narrower Viewing box */
  body.sk-fit2 #skTopMenus #skHelpDeskMenu > button { font-size: 0 !important; }
  body.sk-fit2 #skTopMenus #skHelpDeskMenu > button::before { content: "Help"; font-size: 10px; }
  body.sk-fit2 #skHelpDeskMenu > button > span { font-size: 9px !important; }
  body.sk-fit2 #skTopMenus #cpHubBtn { font-size: 0 !important; }
  body.sk-fit2 #skTopMenus #cpHubBtn::before { content: "Messages"; font-size: 9.5px; }
  body.sk-fit2 #skTopMenus #cpHubBtn > span { font-size: 9.5px !important; }
  body.sk-fit2 #clientSwitcherSelect { max-width: 170px !important; }
  /* step 3: no "Viewing:" word, smaller still */
  body.sk-fit3 #clientSwitcherWrap > label { display: none !important; }
  body.sk-fit3 #clientSwitcherSelect { max-width: 120px !important; }
  body.sk-fit3 #reportSection > nav > div { column-gap: 8px !important; }
  body.sk-fit3 #skTopMenus .sk-menu > button, body.sk-fit3 #kpiTopBtn { font-size: 9.5px !important; padding: 4px 4px !important; }
}
