/* =========================================================
   Layout helpers (shared across all apps)
   ========================================================= */

/* Page scaffold: keeps footer full-width and bottom-aligned on short pages */
html, body { height: 100%; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Ensure main content grows to push footer down */
main {
  flex: 1;
}

/* ✅ FULL-WIDTH CONTAINER (header/footer/content all match) */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 18px; /* subtle gutter like original */
  box-sizing: border-box;
}

/* =========================================================
   Card header helpers (title + actions)
   ========================================================= */

/* Header row inside cards (title + actions) */
.card-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start; /* LEFT align title */
  gap: 12px;
  margin-bottom: 6px;
}

/* Title: always left-justified */
.card-header .title {
  margin: 0;
  text-align: left;
}

/* Action area pinned to the right */
.card-header .header-actions {
  position: absolute;
  right: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Back to Apps button (blue) */
.btn-home,
a.btn-home {
  box-sizing: border-box;
  border: 1px solid #e6e9ee;
  background: #ffffff;
  color: #1f6fd6; /* EPIC blue */
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  line-height: 1;        /* lock height consistency */
  appearance: none;      /* normalize button rendering */
  -webkit-appearance: none;
}

.btn-home:active,
a.btn-home:active {
  transform: translateY(1px);
}

/* Back button (black) — consistent everywhere */
.btn-secondary,
a.btn-secondary {
  box-sizing: border-box;
  border: 1px solid #e6e9ee;
  background: #ffffff;
  color: #1f2937; /* Black */
  border-radius: 999px;
  padding: 8px 14px; /* match btn-home */
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none; /* prevent underline on <a> */
  display: inline-flex;
  align-items: center;
  line-height: 1;        /* fixes subtle height differences */
  appearance: none;      /* removes OS button styling */
  -webkit-appearance: none;
}

.btn-secondary:active,
a.btn-secondary:active {
  transform: translateY(1px);
}

/* Mobile safety */
@media (max-width: 420px) {
  .card-header {
    padding-right: 96px; /* prevents title/button overlap */
  }
}

/* =========================================================
   Top action row ABOVE the card title
   Use when you want buttons above the title (Apps left, Back right)
   ========================================================= */

.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between; /* left group sticks left, right group sticks right */
  gap: 12px;
  margin-bottom: 12px;
  width: 100%;
  white-space: nowrap;
}

.top-actions .left,
.top-actions .right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* If no right buttons, don't reserve space */
.top-actions .right:empty {
  display: none;
}

/* =========================================================
   Auth stage (prevents layout shift on index.html)
   Keeps a stable height while auth resolves and views swap.
   ========================================================= */

.auth-stage {
  position: relative;
  width: 100%;
  min-height: 520px; /* stable space for signed-in menu */
}

@media (max-width: 420px) {
  .auth-stage { min-height: 560px; } /* a bit taller on small screens */
}

.auth-pane {
  position: absolute;
  inset: 0;
  transition: opacity 140ms ease;
}

.auth-pane.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-pane.is-shown {
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================
   PWA: Hide "Back to Apps" when running as installed app
   - Android/Chrome: display-mode: standalone
   - iOS: navigator.standalone -> body.standalone (set in index.html)
   ========================================================= */

@media (display-mode: standalone) {
  .btn-home,
  a.btn-home {
    display: none !important;
  }
}

/* iOS PWA fallback (requires body.classList.add("standalone") in HTML) */
body.standalone .btn-home,
body.standalone a.btn-home {
  display: none !important;
}

/* =========================================================
   App Shell / Module Header (standard UI)
   FULL WIDTH + RESPONSIVE like the original “perfect” layout
   ========================================================= */

.inv-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid #e6e6e6;
  background: #ffffff;
}

/* 3-column shell: left (logo+nav), center (title), right (user+actions) */
.inv-header-inner {
  display: flex;
  gap: 16px;
  align-items: stretch;
  padding: 14px 0;
}

/* LEFT: logo top-left, module nav below */
.inv-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 260px;
}

.inv-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inv-logo img {
  height: 34px;
  width: auto;
  display: block;
}

/* Module navigation row (left side) */
.inv-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* CENTER: module title */
.inv-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 6px;
}

.inv-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

/* RIGHT: user imprint top-right, functional buttons below */
.inv-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 260px;
}

.inv-user {
  font-size: 13px;
  color: #666;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 18px; /* keeps layout stable if blank */
}

.inv-right-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

/* Disabled buttons */
.btn-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* Responsive behavior: stack like Items */
@media (max-width: 900px) {
  .inv-header-inner {
    flex-direction: column;
    gap: 12px;
  }

  .inv-left,
  .inv-right {
    min-width: unset;
    align-items: flex-start;
  }

  .inv-right {
    align-items: flex-start;
  }

  .inv-right-nav {
    justify-content: flex-start;
  }

  .inv-center {
    justify-content: flex-start;
    text-align: left;
  }
}

/* =========================================================
   Full-width Footer Bar (standard UI)
   Updated left, Support right, responsive stack on small screens
   ========================================================= */

.app-footer {
  width: 100%;
  border-top: 1px solid #e6e6e6;
  background: #ffffff;
}

.app-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px; /* matches container gutter */
  box-sizing: border-box;
}

@media (max-width: 520px) {
  .app-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* =========================================================
   HEADER FINAL OVERRIDE (2-row / 3-column standard)
   Logo top-left, User top-right
   Nav left + Title center + Action buttons right on SAME row
   ========================================================= */

.inv-header .inv-header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 18px;
  row-gap: 10px;
  align-items: center;
}

/* LEFT column spans both rows: logo on row 1, nav on row 2 */
.inv-header .inv-left {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: auto auto;
  gap: 10px;
  min-width: 0;
}

.inv-header .inv-logo { grid-row: 1; }
.inv-header .inv-nav  { grid-row: 2; align-items: center; }

/* CENTER title sits ONLY on row 2 */
.inv-header .inv-center {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  text-align: center;
}

.inv-header .inv-title {
  white-space: nowrap;
}

/* RIGHT column spans both rows: user row 1, actions row 2 */
.inv-header .inv-right {
  grid-column: 3;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: auto auto;
  gap: 10px;
  justify-items: end;
  min-width: 0;
}

.inv-header .inv-user {
  grid-row: 1;
  line-height: 1;
  white-space: nowrap;
}

.inv-header .inv-right-nav {
  grid-row: 2;
  align-items: center;
  justify-content: flex-end;
}

/* Keep nav/action buttons on same visual baseline */
.inv-header .inv-nav,
.inv-header .inv-right-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Responsive: stack cleanly */
@media (max-width: 900px) {
  .inv-header .inv-header-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .inv-header .inv-left,
  .inv-header .inv-right {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .inv-header .inv-center {
    justify-content: flex-start;
    text-align: left;
  }

  .inv-header .inv-right-nav {
    justify-content: flex-start;
  }
}

/* =========================================================
   FINAL UI NORMALIZATION PATCH
   - Fix header pill alignment (Items)
   - Ensure .btn anchors/buttons render as buttons (ARAP footer + header)
   ========================================================= */

/* Make all btns baseline-consistent (anchors + buttons) */
a.btn,
button.btn,
a.btn-ghost,
button.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
  text-decoration: none;     /* prevents blue underline link look */
}

/* If your button styles come from components/app css, this just prevents drift */
a.btn:visited,
a.btn-ghost:visited {
  text-decoration: none;
}

/* Header: force nav/action rows to share identical height + alignment */
.inv-header .inv-nav,
.inv-header .inv-right-nav {
  align-items: center;
}

/* Tighten the user line so it doesn't push the action row down */
.inv-header .inv-user {
  line-height: 1;
  margin: 0;
  padding: 0;
}

/* Ensure the two “button rows” sit on the same baseline */
.inv-header .inv-left,
.inv-header .inv-right {
  align-self: stretch;
}

.inv-header .inv-left .inv-nav,
.inv-header .inv-right .inv-right-nav {
  margin-top: 0;
}

/* ARAP: if any module CSS makes links look like links, neutralize within shell/footer */
.inv-header a,
.app-footer a {
  text-decoration: none;
}

/* =========================================================
   FINAL HEADER POLISH
   - ARAP: header should span full viewport width
   - Items: align header pills to same baseline (match ARAP)
   ========================================================= */

/* 1) Make header bar truly full-width even if body/wrap has max-width styling */
.inv-header {
  width: 100%;
  left: 0;
  right: 0;
}

.inv-header > .container {
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding-left: 18px;
  padding-right: 18px;
  box-sizing: border-box;
}

/* Ensure the header's bottom rule spans the viewport */
.inv-header {
  border-bottom: 1px solid #e6e9ee;
  background: #fff;
}

/* 2) Normalize header pills ONLY inside the header so ARAP/Items match exactly */
.inv-header .btn,
.inv-header a.btn,
.inv-header button.btn,
.inv-header .btn-ghost,
.inv-header a.btn-ghost,
.inv-header button.btn-ghost {
  height: 30px;               /* consistent pill height */
  padding: 6px 12px;          /* consistent geometry */
  line-height: 1;             /* prevents baseline drift */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Keep the two header button rows aligned */
.inv-header .inv-nav,
.inv-header .inv-right-nav {
  align-items: center;
}

/* Prevent the user imprint from affecting vertical alignment */
.inv-header .inv-user {
  line-height: 1;
  min-height: 14px;
}

/* If any browser adds different button defaults */
.inv-header button.btn,
.inv-header button.btn-ghost {
  background: #fff;
}

