/* ============================================================================
   theme-erp.css  —  HYBRID ERP skin for the KKI QMS
   ----------------------------------------------------------------------------
   Purpose : Give the QMS the KKI ERP look WITHOUT touching any page logic,
             routing, component, or business code. Pure additive, cosmetic-only
             overrides (background / color / border / font / layout-chrome).

   HYBRID layout (this build):
       • A white MasterControl-style TOP BAR across the top holding the
         chrome — green KKI brand tile, date/time clock, "● Live" status +
         build, and the user chip.
       • The FULL QMS module SIDEBAR retained on the LEFT (navy rail), below
         the top bar — every nav group and every module link preserved.
       • Page canvas sits below the top bar and to the right of the sidebar.

   The QMS renders a single <nav class="sidebar"> with five children:
       nav.sidebar > div:nth-child(1)  = brand (shield + titles)
       nav.sidebar > div:nth-child(2)  = date/time clock  (bg-navy-750)
       nav.sidebar > div:nth-child(3)  = user info + logout
       nav.sidebar > div:nth-child(4)  = nav groups list  (flex-1, scrollable)  → LEFT RAIL
       nav.sidebar > div:nth-child(5)  = connection status + build version
       main.main-content               = page canvas (was ml-64)

   To build the hybrid with CSS only, the <nav> itself becomes the white top
   bar (children 1,2,3,5), and child 4 (the module list) is re-pinned as a
   fixed navy sidebar on the left. No DOM is added or removed; NO module,
   stat tile, deadline, or SOP card is hidden.

   Tokens  : MasterControl palette + KKI green brand + the QMS navy ramp.
               canvas #f4f6f8  panel #ffffff  line #e3e8ee
               ink    #1b2733  muted #5b6b7b
               accent #1f5fa6  accent-bg #eaf2fb
               head   #16324f  brand #22c55e (KKI green box)   font Inter
               navy-800 #1a2847 (sidebar bg, matches tailwind config)

   REVERT  : Delete this file and remove its single <link> from index.html.
             Nothing else changes. 100% reversible.
   ============================================================================ */

:root {
  --erp-bg: #f4f6f8;
  --erp-panel: #ffffff;
  --erp-head: #16324f;
  --erp-accent: #1f5fa6;
  --erp-accent-hover: #184d8e;
  --erp-accent-bg: #eaf2fb;
  --erp-line: #e3e8ee;
  --erp-ink: #1b2733;
  --erp-muted: #5b6b7b;
  --erp-brand: #22c55e;
  --erp-navy: #1a2847;   /* navy-800 — the retained QMS sidebar background */
  --erp-navh: 56px;      /* top bar height */
  --erp-railw: 16rem;    /* left sidebar width (= original w-64) */
}

/* ---- Typography: adopt the ERP's Inter stack ---------------------------- */
body,
.sidebar,
.main-content {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif !important;
}

/* ---- Canvas: flat MasterControl grey instead of the blue gradient ------- */
body {
  background: var(--erp-bg) !important;
}

/* ============================================================================
   1. THE <nav> BECOMES A WHITE HORIZONTAL TOP BAR
   Was: fixed left-0 top-0 bottom-0 w-64 flex-col bg-navy-800 (a vertical rail).
   Now: fixed full-width white bar pinned to the top, laid out as a row.
   ============================================================================ */
nav.sidebar {
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  bottom: auto !important;
  width: auto !important;
  height: var(--erp-navh) !important;
  flex-direction: row !important;
  align-items: stretch !important;
  background: var(--erp-panel) !important;
  color: var(--erp-ink) !important;
  border-bottom: 1px solid var(--erp-line) !important;
  box-shadow: 0 1px 2px rgba(20, 40, 60, 0.05) !important;
  overflow: visible !important;
}

/* Push the page canvas BELOW the bar AND to the RIGHT of the sidebar. */
main.main-content {
  margin-left: var(--erp-railw) !important;
  margin-top: var(--erp-navh) !important;
}

/* ---- Top-bar chrome: navy-on-dark text → ink/muted on white -------------
   Scoped to the top-bar children ONLY (1,2,3,5). Child 4 (the module rail)
   is intentionally left with its original navy styling.                    */
nav.sidebar > div:nth-child(1) .text-white,
nav.sidebar > div:nth-child(2) .text-white,
nav.sidebar > div:nth-child(3) .text-white,
nav.sidebar > div:nth-child(5) .text-white { color: var(--erp-ink) !important; }
nav.sidebar > div:nth-child(1) .text-navy-300,
nav.sidebar > div:nth-child(2) .text-navy-300,
nav.sidebar > div:nth-child(3) .text-navy-300,
nav.sidebar > div:nth-child(5) .text-navy-300 { color: var(--erp-muted) !important; }
nav.sidebar > div:nth-child(1) .text-navy-400,
nav.sidebar > div:nth-child(2) .text-navy-400,
nav.sidebar > div:nth-child(3) .text-navy-400,
nav.sidebar > div:nth-child(5) .text-navy-400 { color: #8595a5 !important; }
nav.sidebar > div:nth-child(5) .text-navy-500 { color: #8595a5 !important; }

/* ============================================================================
   2. BRAND BLOCK (child 1) — green KKI shield tile + dark titles, top-left
   ============================================================================ */
nav.sidebar > div:nth-child(1) {
  order: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 16px !important;
  border-bottom: none !important;
  border-right: 1px solid var(--erp-line) !important;
}
nav.sidebar > div:nth-child(1) .bg-navy-600 {
  background: var(--erp-brand) !important;
}
nav.sidebar > div:nth-child(1) h1 { color: var(--erp-ink) !important; }
nav.sidebar > div:nth-child(1) .text-navy-300 { color: var(--erp-muted) !important; }

/* ============================================================================
   3. LEFT MODULE SIDEBAR (child 4) — the FULL QMS nav rail, retained.
      Re-pinned as a fixed navy column below the top bar. Every group and
      every module link is preserved with its original navy styling.
   ============================================================================ */
nav.sidebar > div:nth-child(4) {
  position: fixed !important;
  left: 0 !important;
  top: var(--erp-navh) !important;
  bottom: 0 !important;
  width: var(--erp-railw) !important;
  background: var(--erp-navy) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0 !important;
  padding: 16px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  z-index: 39 !important;
  border-right: 1px solid rgba(0, 0, 0, 0.15) !important;
}
/* Groups stack vertically (restore original vertical spacing). */
nav.sidebar > div:nth-child(4) > div {
  display: block !important;
}
/* Nav links: full-width rows (original QMS look, keep navy palette intact). */
nav.sidebar > div:nth-child(4) a {
  width: 100% !important;
}

/* ============================================================================
   4. USER INFO (child 3) — pushed to the far right of the top bar, green chip
   ============================================================================ */
nav.sidebar > div:nth-child(3) {
  order: 4;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 12px !important;
  border-bottom: none !important;
  border-left: 1px solid var(--erp-line) !important;
}
nav.sidebar > div:nth-child(3) .text-white { color: var(--erp-ink) !important; }
nav.sidebar > div:nth-child(3) .bg-navy-600.rounded-full {
  background: var(--erp-brand) !important;
}
nav.sidebar > div:nth-child(3) .text-navy-200 { color: #ffffff !important; }

/* ============================================================================
   5. DATE / TIME CLOCK (child 2) — right side of the bar, transparent
   ============================================================================ */
nav.sidebar > div:nth-child(2) {
  order: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  margin-left: auto !important;   /* pushes clock + live + user to the right */
  padding: 0 14px !important;
  background: transparent !important;
  border-bottom: none !important;
  border-left: 1px solid var(--erp-line) !important;
}
nav.sidebar > div:nth-child(2),
nav.sidebar > div:nth-child(2) * { color: var(--erp-ink) !important; }

/* ============================================================================
   6. FOOTER / STATUS (child 5) — "● Live" connection + build, right of bar
   ============================================================================ */
nav.sidebar > div:nth-child(5) {
  order: 3;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 14px !important;
  border-top: none !important;
  border-left: 1px solid var(--erp-line) !important;
}
nav.sidebar > div:nth-child(5) .text-navy-400 { color: var(--erp-muted) !important; }
/* Kill the mt-3 that stacked the connection row under the build in the rail. */
nav.sidebar > div:nth-child(5) .mt-3 { margin-top: 0 !important; }

/* ============================================================================
   7. PAGE HEADERS — headings adopt the ERP navy head color
   ============================================================================ */
.main-content h1,
.main-content h2 {
  color: var(--erp-head) !important;
  letter-spacing: -0.2px;
}

/* ============================================================================
   8. CARDS / STAT TILES — MasterControl panel treatment
      (#e3e8ee hairline, 10px radius, soft shadow). All stat tiles kept.
   ============================================================================ */
.main-content .bg-white.rounded-lg,
.main-content .bg-white.rounded-xl {
  background: var(--erp-panel) !important;
  border-color: var(--erp-line) !important;
  border-radius: 10px !important;
  box-shadow: 0 1px 2px rgba(20, 40, 60, 0.04) !important;
}
.main-content .bg-white.border-blue-100,
.main-content .bg-white.border-orange-100,
.main-content .bg-white.border-green-100,
.main-content .bg-white.border-red-100,
.main-content .bg-white.border-purple-100,
.main-content .bg-white.border-cyan-100 {
  border-color: var(--erp-line) !important;
}

/* ============================================================================
   9. BUTTONS — primary/action buttons adopt the ERP accent blue
   ============================================================================ */
.main-content button.bg-navy-600,
.main-content .bg-navy-600.rounded-lg.text-white {
  background: var(--erp-accent) !important;
}
.main-content button.bg-navy-600:hover {
  background: var(--erp-accent-hover) !important;
}

/* ============================================================================
   10. TABLE HEADERS — navy header band to match ERP data grids
   ============================================================================ */
.main-content table thead th,
.main-content thead.bg-gray-50 th,
.main-content thead .bg-gray-50 {
  background: var(--erp-head) !important;
  color: #ffffff !important;
  border-color: var(--erp-head) !important;
}

/* ============================================================================
   11. SCROLLBAR — thin ERP-tinted scrollbar (cosmetic parity)
   ============================================================================ */
::-webkit-scrollbar-thumb { background: #c7d2dd !important; }
::-webkit-scrollbar-thumb:hover { background: #a9b8c7 !important; }

/* ============================================================================
   12. RETURN-TO-DASHBOARD BUTTON — link back to kki.kefirkultures.com.
       Stock (unthemed) view: navy chip stacked under the brand titles.
       Themed hybrid view: inline in the 56px top bar, ERP accent blue.
   ============================================================================ */
nav.sidebar > div:nth-child(1) .return-to-dashboard {
  margin-top: 0 !important;
  margin-left: 14px !important;
  background: var(--erp-accent, #1f5fa6) !important;
  color: #ffffff !important;
  white-space: nowrap;
}
nav.sidebar > div:nth-child(1) .return-to-dashboard:hover {
  background: var(--erp-accent-hover, #184d8e) !important;
}
