/* =========================================================
   Application shell: sidebar (lg and up), bottom tab bar and
   slide-over menu (below lg), top bar, Data Assistant dock.
   Colours come from the tokens in theme.css (loaded after this file).
   ========================================================= */

.fm-shell { display: flex; min-height: 100vh; }
.fm-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.fm-main > .container { width: 100%; }

/* ---- Brand --------------------------------------------------------------- */
.fm-brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 700; font-size: 1.1rem; color: var(--fm-ink);
  text-decoration: none;
}
.fm-logo { width: 2rem; height: 2rem; display: block; flex: none; }

/* ---- Top bar (phones, and for visitors who are not logged in) ------------- */
.fm-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem; padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
  background: var(--fm-surface); border-bottom: 1px solid var(--fm-line);
  margin-bottom: 1.25rem;
}

/* ---- Sidebar ---------------------------------------------------------------- */
.fm-sidebar { --bs-offcanvas-width: 18rem; --bs-offcanvas-bg: var(--fm-surface); }
.fm-sidebar .offcanvas-header { border-bottom: 1px solid var(--fm-line); }
.fm-sidebar-inner { display: flex; flex-direction: column; width: 100%; min-height: 100%; gap: 0.75rem; }
.fm-nav-scroll { flex: 1 1 auto; }
.fm-nav, .fm-sub { list-style: none; margin: 0; padding: 0; }
.fm-nav { display: flex; flex-direction: column; gap: 2px; }
.fm-group-label {
  margin: 1.1rem 0 0.35rem; padding: 0 0.75rem;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--fm-muted);
}
.fm-nav-scroll .fm-group-label:first-child { margin-top: 0; }

.fm-link {
  display: flex; align-items: center; gap: 0.75rem; width: 100%;
  min-height: 2.75rem; padding: 0.5rem 0.75rem;
  border: 0; border-radius: 0.75rem; background: transparent;
  color: var(--fm-ink); font: inherit; font-weight: 500; text-align: left; text-decoration: none;
}
.fm-link .bi:first-child { font-size: 1.15rem; color: var(--fm-muted); flex: none; }
.fm-link:hover { background: var(--bs-tertiary-bg); color: var(--fm-ink); }
.fm-link.active { background: var(--fm-brand-soft); color: var(--fm-brand-text); font-weight: 700; }
.fm-link.active .bi:first-child { color: var(--fm-brand-text); }
.fm-link:focus-visible, .fm-sublink:focus-visible, .fm-tab:focus-visible {
  outline: 3px solid var(--fm-brand-text); outline-offset: 2px;
}
.fm-parent span { flex: 1 1 auto; }
.fm-chevron { transition: transform 0.15s ease; font-size: 0.8rem; color: var(--fm-muted); }
.fm-parent:not(.collapsed) .fm-chevron { transform: rotate(180deg); }
.fm-sub { padding: 2px 0 4px 2.35rem; }
.fm-sublink {
  display: flex; align-items: center; min-height: 2.5rem; padding: 0.35rem 0.75rem;
  border-radius: 0.65rem; color: var(--fm-muted); font-size: 0.92rem; text-decoration: none;
}
.fm-sublink:hover { background: var(--bs-tertiary-bg); color: var(--fm-ink); }
.fm-sublink.active { color: var(--fm-brand-text); font-weight: 700; background: var(--fm-brand-soft); }

.fm-user { position: sticky; bottom: 0; background: var(--fm-surface); border-top: 1px solid var(--fm-line); padding: 0.75rem 0 0.25rem; margin-top: auto; }
.fm-userbtn .fm-avatar { width: 1.75rem; height: 1.75rem; object-fit: cover; flex: none; }
.fm-userbtn .fm-avatar-icon { font-size: 1.5rem; color: var(--fm-muted); flex: none; }
.fm-userbtn > span { flex: 1 1 auto; min-width: 0; }
.fm-chevron-static { font-size: 0.8rem; color: var(--fm-muted); }
.fm-user .dropdown-menu { min-width: 100%; }

/* From lg: a fixed-width sticky column */
@media (min-width: 992px) {
  .fm-sidebar-wrap {
    flex: 0 0 17rem; width: 17rem; position: sticky; top: 0; align-self: flex-start;
    height: 100vh; overflow-y: auto;
    background: var(--fm-surface); border-right: 1px solid var(--fm-line);
  }
  .fm-sidebar .offcanvas-body { padding: 1.25rem 0.9rem; }
  .fm-sidebar-inner { min-height: calc(100vh - 2.5rem); }
  .fm-main > .container { max-width: 1320px; }
}

/* ---- Bottom tab bar (below lg) ----------------------------------------------- */
.fm-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: flex; background: var(--fm-surface); border-top: 1px solid var(--fm-line);
  padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
}
.fm-tab {
  flex: 1 1 0; min-width: 0; min-height: 3.25rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: transparent; border-radius: 0.75rem;
  color: var(--fm-muted); font: inherit; font-size: 0.72rem; font-weight: 600; text-decoration: none;
}
.fm-tab .bi { font-size: 1.3rem; line-height: 1; }
.fm-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-tab.active { color: var(--fm-brand-text); }
.fm-tab.active .bi { background: var(--fm-brand-soft); border-radius: 99px; padding: 0.15rem 0.9rem; }
@media (max-width: 991.98px) {
  .fm-has-nav .fm-main { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)); }
}

/* ---- Data Assistant: a drawer docked to the right on large screens, a sheet above the tab bar on phones ---- */
@media (min-width: 992px) {
  #dataAssistantWidget {
    top: 0 !important; bottom: 0 !important; right: 0 !important; margin: 0 !important;
    width: min(26rem, 100vw); border-radius: 0; border-width: 0 0 0 1px;
    flex-direction: column;
  }
  #dataAssistantWidget:not(.d-none) { display: flex; }
  #dataAssistantBody { flex: 1 1 auto; max-height: none; }
}
@media (max-width: 991.98px) {
  #dataAssistantWidget,
  #dataAssistantLauncher {
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }
  #dataAssistantWidget { left: 0; right: 0 !important; margin: 0 0.75rem !important; width: auto; }
  #dataAssistantBody { max-height: 50vh; }
  body.da-has-widget { padding-bottom: 0; }
}

/* ---- Small helpers used by the Overview page ---------------------------------- */
.min-w-0 { min-width: 0; }
.amount-figure { font-variant-numeric: tabular-nums; }

@media (min-width: 992px) {
  .fm-main > .container:first-of-type { padding-top: 1.5rem; }
}
