/* =============================================================================
   Debt Manager Professional Help - Global Styles
   Consolidated & ordered for clarity
   ============================================================================
   Order:
   1) CSS Variables
   2) Base / Resets
   3) Layout Shell
   4) Header
   5) Navigation
   6) Hamburger (mobile toggle)
   7) Sidebar (structure, nav, scrollbar)
   8) Content (centered reading column)
   9) Footer
   10) Responsive (Mobile <768px, Desktop =768px)
   ========================================================================== */


/* ============================================================================
   1) CSS Variables
   - Centralized design tokens and app-wide values
   ========================================================================== */
:root {
  --header-h: 46px;
  --sidebar-w: 320px;
  --content-max: 55rem;

  /* Sidebar spacing and mobile gap helpers */
  --sidebar-pad: 12px;
  --header-gap-mobile: 8px;

  /* Global behavior */
  font-family: system-ui, Arial, sans-serif;
  scroll-padding-top: var(--header-h);
}


/* ============================================================================
   2) Base / Resets
   - Page colors, baseline spacing, overflow behavior
   ========================================================================== */
html, body { height: 100%; }

body {
  margin: 0;
  background: #fff;
  color: #1b1b1b;
  padding-top: var(--header-h);
  overflow-x: hidden; /* prevent horizontal scrollbars */
}


/* ============================================================================
   3) Layout Shell
   - Overall app wrapper and rows
   ========================================================================== */
.layout { min-height: calc(100vh - var(--header-h)); }
.layout__row { display: block; }


/* ============================================================================
   4) Header
   - Fixed header bar + inner alignment + brand treatment
   ========================================================================== */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: #f8f9fa;
  color: #212529;
  border-bottom: 1px solid #dee2e6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .5rem 1rem;
}

.site-brand {
  color: #212529;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.site-brand:hover,
.site-brand:focus {
  color: #0d6efd;
  text-decoration: none;
}

.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}


/* ============================================================================
   5) Navigation
   - Header nav list and link states
   ========================================================================== */
.site-nav {
  flex: 1 1 auto;
  display: flex;
  justify-content: flex-end;
}

.site-nav__list {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
}

.site-nav__list a {
  color: #212529;
  text-decoration: none;
  font-weight: 500;
}

.site-nav__list a:hover,
.site-nav__list a:focus {
  color: #0d6efd;
  text-decoration: underline;
}


/* ============================================================================
   6) Hamburger (mobile toggle)
   - Button and animated bars; transformed when sidebar is open
   ========================================================================== */
.hamburger {
  display: none;              /* shown on mobile via media queries */
  width: 40px;
  height: 36px;
  border: 1px solid rgba(0, 0, 0, .2);
  background: transparent;
  border-radius: .5rem;
  padding: 6px;
  cursor: pointer;
}

.hamburger:focus {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

.hamburger__bar {
  display: block;
  height: 2px;
  margin: 5px 0;
  background: #212529;
  transition: transform .2s ease, opacity .2s ease;
}

body.sidebar-open .hamburger__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
body.sidebar-open .hamburger__bar:nth-child(2) { opacity: 0; }
body.sidebar-open .hamburger__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


/* ============================================================================
   7) Sidebar
   - Panel, overlay, nav tree, scrollbar styling
   ========================================================================== */
#sidebar.sidebar {
  background: #f7f7f9;
  border-right: 1px solid #e2e2e6;
  overflow: auto;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 998;
}

/* Sidebar navigation structure */
.sidebar-title { margin: 0 0 .4rem; font-size: 1rem; }

.menu {
  list-style: none;
  margin: 0;
  padding: 0;               /* base reset; indent controlled below */
}

.menu > li {
  margin: .15rem 0;
  padding: .15rem 0;
  border-radius: .5rem;
}

.item-row {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .4rem;
}

.item-link {
  flex: 1 1 auto;
  text-decoration: none;
  color: #2b2b2b;
  line-height: 1.35;
}

.item-link:hover,
.item-link:focus { text-decoration: underline; }

.is-current > .item-row .item-link,
.submenu .is-current > .item-link,
.menu > li.is-current .item-link {
  font-weight: 700;
}

.menu > li.has-active-child > .item-row { background: #eef3ff; }

.item-expander {
  border: 1px solid #d8d8de;
  background: #fff;
  border-radius: .375rem;
  padding: .15rem;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.item-expander .chevron {
  display: block;
  width: 14px;
  height: 14px;
  transform: rotate(-90deg);
  transition: transform .15s ease-in-out;
  fill: currentColor;
  color: #5a5a68;
}

.menu > li[aria-expanded="true"] .item-expander .chevron { transform: rotate(0deg); }

.submenu {
  list-style: none;
  margin: .25rem 0 .35rem;
  padding-left: 1rem;
}

.submenu > li { margin: .1rem 0; }
.submenu .item-link { color: #42424f; font-size: .92rem; }

/* Ensure inherited font/color in sidebar controls */
#sidebar .item-link,
#sidebar .item-expander { font: inherit; color: inherit; }

/* Consistent left indent inside sidebar */
#sidebar .menu,
#sidebar .submenu { margin: 0; padding-left: 1rem; }

/* Scrollbar cosmetics (WebKit) */
#sidebar.sidebar::-webkit-scrollbar { width: 8px; }
#sidebar.sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, .2);
  border-radius: 4px;
}

#sidebar .sidebar-controls .btn {
  background: #fff;
  border: 1px solid #d8d8de;
  border-radius: .375rem;
  padding: .2rem .5rem;
  font: inherit;
  cursor: pointer;
}
#sidebar .sidebar-controls .btn:hover { background: #f2f4ff; }


/* ============================================================================
   8) Content (centered reading column)
   - Three-column grid with centered main column
   ========================================================================== */
.content {
  margin-left: var(--sidebar-w);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr min(var(--content-max), 100%) 1fr;
  column-gap: 0;
}

.content > * { grid-column: 2; }
.full-bleed { grid-column: 1 / -1; }

.h1 { font-size: 2rem; margin: .25rem 0 .5rem; }
.lead { font-size: 1.1rem; margin: 0 0 .5rem; color: #333; }
.content p { line-height: 1.6; }


/* ============================================================================
   9) Footer
   - Compact, centered, full-bleed bar
   ========================================================================== */
.site-footer {
  position: relative;
  z-index: 10;
  box-sizing: border-box;
  border-top: 1px solid #dee2e6;
  background: #f8f9fa;
  color: #212529;

  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  padding: 0.25rem 1rem;
  font-size: 0.9rem;
  line-height: 1.3;

  /* Full-bleed relative to viewport */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  box-shadow: 0 -1px 2px rgba(0, 0, 0, .05);
}


/* ============================================================================
   10) Responsive
   - Breakpoint-specific behavior, kept together for easy scanning
   ========================================================================== */

/* -- Mobile: < 768px ------------------------------------------------------- */
@media (max-width: 767.98px) {
  /* Collapse sidebar width var for layout calculations */
  :root { --sidebar-w: 0px; }

  .hamburger { display: inline-block; }
  .site-nav { display: none; }

  .content {
    margin-left: 0;
    grid-template-columns: 1fr min(var(--content-max), 100%) 1fr;
  }

  #sidebar.sidebar {
    position: fixed;
    z-index: 999;
    top: calc(var(--header-h) + var(--header-gap-mobile)); /* clear fixed header */
    left: 0;
    width: min(86vw, 320px);
    height: calc(100vh - var(--header-h));
    transform: translateX(-100%);
    transition: transform .2s ease-out;

    /* Visuals */
    padding: var(--sidebar-pad);
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    box-shadow: 2px 0 12px rgba(0, 0, 0, .15);
  }

  body.sidebar-open #sidebar.sidebar { transform: translateX(0); }
  body.sidebar-open #sidebarOverlay { display: block; }
  body.sidebar-open #sidebarOverlay[hidden] { display: block; }

  .brand-logo { height: 24px; }
}

/* -- Desktop/Tablet: = 768px ---------------------------------------------- */
@media (min-width: 768px) {
  #sidebar.sidebar {
    position: fixed;
    top: var(--header-h);             /* flush under header */
    left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - var(--header-h));
    padding: var(--sidebar-pad);      /* breathing room for contents */
  }

  .sidebar-title {
    margin-top: 0;                    /* remove accidental top bump */
    padding-top: 2px;                 /* tiny visual balance */
  }
}

/* ============================================================================
   Global Section Spacing
   Adds bottom margin to every <section> element
   ========================================================================== */
section {
  margin-bottom: 4rem !important; /* same as Bootstrap's mb-5 */
}

/* Smooth scroll (optional) and a default offset */
:root {
  --header-offset: 72px;          /* fallback; will be updated by JS */
  scroll-padding-top: var(--header-offset);
}

/* Whatever elements you link to (adjust selectors to fit your page) */
h1[id], h2[id], h3[id], section[id], [data-anchor="true"] {
  scroll-margin-top: var(--header-offset);
}

/* -------------------------------------------------------------
   Hide header when printing
   ------------------------------------------------------------- */
@media print {
  .site-header,
  .site-nav,
  .hamburger {
    display: none !important;
  }
}
@media print {
  .site-header,
  #sidebar {
    display: none !important;
  }
