/*
 * Dashboard and shared ERP navigation - Stage B2, Change 4C.
 * Scope: .shell-body, #dashboardNavigation, #homeView and #workspaceView, all inside #appScreen.
 * Not targeted: the Login screen (#loginScreen), the fixed header (.app-shell > .topbar), the module table sidebar and the theme sheets.
 * Colours: Orange #FF5A00, Black #000000, White #FFFFFF. No new colours or neutral greys are introduced.
 * Breakpoint: 1100px. At and below it the shared navigation stacks above the content.
 */

/* Hidden views stay hidden: the display rules below would otherwise override the [hidden] attribute. */
#homeView[hidden],
#workspaceView[hidden] {
  display: none;
}

/* Two columns: the shared navigation (column 1) and the active view (column 2). The 76px header clearance comes from .app-shell. */
.shell-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  box-sizing: border-box;
  width: 100%;
  height: calc(100dvh - 76px);
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: #FFFFFF;
}

.shell-body.sidebar-hidden { grid-template-columns: minmax(0, 1fr); }
.shell-body.sidebar-hidden #dashboardNavigation { display: none; }
.shell-body > #workspaceView { background: #FFFFFF; }
/* Minimized shell has one column; the module workspace uses column 1 so it does not fall into an implicit column 2 (same rule as #homeView below). */
.shell-body.sidebar-hidden > #workspaceView { grid-column: 1; }
.dashboard-navigation-reveal {
  display: none;
  position: absolute;
  left: 0;
  top: 50%;
  z-index: 20;
  width: 72px;
  height: 52px;
  padding: 0 10px;
  border: 2px solid #000000;
  border-radius: 0 8px 8px 0;
  background: #FF5A00;
  color: #000000;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.shell-body.sidebar-hidden .dashboard-navigation-reveal { display: block; }
.shell-body:not(.sidebar-hidden) .dashboard-navigation-reveal { display: none; }
.dashboard-navigation-reveal:focus-visible { outline: 3px solid #000000; outline-offset: 2px; }

#dashboardNavigation {
  grid-column: 1;
  grid-row: 1;
  box-sizing: border-box;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: 24px 0 20px;
  background: #FF5A00;
  color: #000000;
}

#homeView,
#workspaceView {
  grid-column: 1;
  grid-row: 1;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
}

/* Dashboard content: the existing greeting, tiles and footer keep their spacing inside the content column. */
#homeView {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  background: #FFFFFF;
  overflow: auto;
}

#homeView > * {
  padding-inline: clamp(20px, 3.5vw, 50px);
}

#homeView > .hero-row {
  padding-top: clamp(22px, 5vh, 58px);
}

#homeView > .home-status {
  padding-bottom: clamp(20px, 3vh, 38px);
}

/* Top-level navigation: six semantic buttons inside list items. */
#dashboardNavigation > ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#dashboardNavigation > ul > li {
  margin: 0 12px 4px;
}

#dashboardNavigation > ul > li > button {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 13px 54px 13px 70px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #000000;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

#dashboardNavigation > ul > li > button::before {
  content: none;
  position: absolute;
  left: 14px;
  top: 50%;
  width: 34px;
  height: 34px;
  margin-top: -17px;
}

#dashboardNavigation > ul > li > button .module-icon { position: absolute; left: 18px; top: 50%; width: 34px; height: 34px; transform: translateY(-50%); fill: none; stroke: #000000; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
#dashboardNavigation > ul > li > button[data-module="master"] .module-icon { fill: none; }
#dashboardNavigation > ul > li > button[data-module="customer"] .module-icon { fill: none; }

#dashboardNavigation > ul > li > button .module-arrow {
  position: absolute;
  right: 18px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-right: 5px solid #000000;
  border-bottom: 5px solid #000000;
  transform: translateY(-50%) rotate(-45deg);
  pointer-events: auto;
}
#dashboardNavigation.sidebar-navigation-locked { overflow: hidden; }
#dashboardNavigation > ul > li.sidebar-module-locked > ul { background: #FF5A00; }
#dashboardNavigation > ul > li > button[aria-expanded="true"] .module-arrow { transform: translateY(-65%) rotate(45deg); }
#dashboardNavigation > ul > li > button[aria-current="page"] .module-arrow { border-color: #FFFFFF; }
#dashboardNavigation > ul > li.sidebar-module-locked > button {
  position: relative;
  top: 0;
  z-index: 5;
  background: #FF5A00;
}
#dashboardNavigation > ul > li.sidebar-module-locked > button[aria-current="page"] { background: #000000; }
#dashboardNavigation > ul > li.sidebar-module-locked {
  display: flex;
  min-height: 0;
  height: 100%;
  flex-direction: column;
}
#dashboardNavigation > ul > li.sidebar-module-locked > ul {
  position: relative;
  z-index: 1;
  min-height: 0;
  flex: 1 1 auto;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

#dashboardNavigation > ul > li > button:hover {
  background: rgba(0, 0, 0, 0.18);
}

#dashboardNavigation > ul > li > button:focus-visible {
  outline: 3px solid #000000;
  outline-offset: 2px;
}

/* Current section: black highlight (approved palette). */
#dashboardNavigation > ul > li > button[aria-current="page"] {
  background: #000000;
  color: #FFFFFF;
}

#dashboardNavigation > ul > li > button[aria-current="page"]::before {
  background: #FFFFFF;
}

#dashboardNavigation > ul > li > button[aria-current="page"] .module-icon { stroke: #FFFFFF; }

/* Submenus: subordinate to their parent, display-only, long labels wrap instead of clipping. */
/* Orange gutter: the submenu is orange, so the padding around the white entries stays orange, including the strip between the white panel and the scrollbar. */
#dashboardNavigation ul ul {
  list-style: none;
  margin: 2px 0 8px;
  padding: 0 12px 0 16px;
  background: #FF5A00;
  scrollbar-width: thin;
  scrollbar-color: #000000 #FF5A00;
}

#dashboardNavigation ul ul[hidden] {
  display: none;
}

#dashboardNavigation .unified-submenu-button {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 8px 10px 8px 8px;
  border: 0;
  background: transparent;
  color: #000000;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

#dashboardNavigation .unified-submenu-button:hover,
#dashboardNavigation .unified-submenu-button:focus-visible,
#dashboardNavigation .unified-submenu-button.active {
  background: transparent;
  color: #000000;
  outline: 3px solid #000000;
  outline-offset: -3px;
}


#dashboardNavigation ul ul li {
  margin: 0;
  padding: 4px 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
  color: #000000;
  background: #FFFFFF;
  opacity: 1;
  white-space: normal;
  cursor: default;
}

/* At and below 1100px the shared navigation stacks above the content, so module content keeps usable width. */
@media (max-width: 1100px) {
  .shell-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  #dashboardNavigation {
    grid-column: 1;
    grid-row: 1;
    height: auto;
    max-height: 40vh;
    padding: 10px 0;
    overflow-x: auto;
  }

  #homeView,
  #workspaceView {
    grid-column: 1;
    grid-row: 2;
    height: 100%;
    overflow: auto;
  }

  #dashboardNavigation > ul {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 6px;
    padding: 0 10px;
  }

  #dashboardNavigation > ul > li {
    margin: 0;
    flex: 0 0 auto;
  }

  #dashboardNavigation > ul > li > button {
    width: auto;
    padding: 10px 14px 10px 30px;
    font-size: 15px;
    white-space: normal;
  }

  #dashboardNavigation > ul > li > button::before {
    left: 11px;
  }

  #dashboardNavigation ul ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 0 0 6px;
    padding: 2px 0 0 16px;
  }

  #dashboardNavigation ul ul li {
    padding: 2px 0;
    font-size: 13px;
  }
}

/* Approved after-login landing page (owner correction 2026-10-25): welcome block centred in the workspace; lower status strip removed. */
#homeView {
  display: flex;
  flex-direction: column;
}

/* Original five-card Dashboard (owner decision 2026-10-25): heading, greeting and workspace message are left-aligned as in the approved screenshot. */
#homeView > .hero-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  margin: 0;
  width: 100%;
  text-align: left;
}

/* With the navigation hidden the shell has one grid column, so the landing area must use column 1; column 2 would be an empty implicit track that pushes the block right. */
.shell-body.sidebar-hidden > #homeView {
  grid-column: 1;
}

html body .app-shell #homeView > .home-status {
  display: none;
}

/* Original five-card Dashboard (owner decision 2026-10-25): the LHS navigation and its Menu trigger are hidden only while Home is displayed.
   #appScreen gains .home-active in showHome() and loses it in openModule(), so module workspaces keep the navigation they need for table selection. */
#appScreen.home-active #dashboardNavigation,
#appScreen.home-active #dashboardNavigationReveal {
  display: none;
}

#appScreen.home-active .shell-body {
  grid-template-columns: minmax(0, 1fr);
}

#appScreen.home-active #homeView {
  grid-column: 1;
}

/* Phone width: the shared navigation takes a compact band so the content has most of the height. */
@media (max-width: 760px) {
  #dashboardNavigation {
    max-height: 34vh;
  }

  #homeView > * {
    padding-inline: 18px;
  }
}
