/* RepairDock right-side desktop sidebar (v1).
   Loaded AFTER reno.css (and after rd-design-system.css when that link
   exists), so equal-specificity rules win without specificity wars.
   Token-only: no hardcoded surface/text colours, so Workshop, Slate,
   Clay and Midnight all keep working, including Midnight's inversions
   (accent-soft is a dark wash there, accent-ink is dark text).
   Focus is deliberately NOT restyled here: reno's :focus-visible
   outline applies unchanged. */

/* Base rule, all widths: hidden. The codebase's own idiom, same as the
   phone bottom nav which is display:none on desktop. Below 992px the
   sidebar markup is in the DOM but never shown; a server cannot know
   the viewport width, so CSS hiding is the honest mechanism. */
.rd-side-nav{display:none;}

/* Everything else lives inside min-width:992px and cannot leak below. */
@media (min-width:992px){
  :root{--rd-side-w:260px;}

  /* Desktop slimming of the top bar (coordinator decision 1). The top
     navbar is navbar-expand-xl, so at 992-1199px it would otherwise
     still show its hamburger next to the sidebar: two navigations.
     The sidebar carries every link, so the nav row and the toggler
     are hidden at desktop and the brand + actions stay.
     Scoped with body:has(.rd-side-nav) so pages that do NOT render
     the sidebar (logged-out header, customer portal) keep their
     toggler untouched. The !important on #nav1 is required because
     Bootstrap's navbar-expand-xl rule forces .navbar-collapse to
     display:flex !important at 1200px and up; without it the row
     would reappear on wide screens. */
  /* RD-NAV-V2-POS: v1 hid #nav1 at desktop in every mode; scoped to
     non-top modes so Top mode restores the pre-v1 navbar exactly.
     Missing/invalid data-rd-nav is NOT top, so it stays hidden
     (the left default). This is the ONLY rule in this file that
     hides #nav1, and the toggler rule below is its only pair. */
  html:not([data-rd-nav="top"]) body:has(.rd-side-nav) .app-navbar #nav1{display:none !important;}
  html:not([data-rd-nav="top"]) body:has(.rd-side-nav) .app-navbar .navbar-toggler{display:none;}

  /* The panel itself. top:0 + padding-top (NOT top:68px) because the
     navbar height is fluid (clamp 52-68px); the background runs
     behind the opaque navbar. No transform anywhere on this panel:
     a transform would re-parent position:fixed and break modals. */
  .rd-side-nav{
    display:block;
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    width:var(--rd-side-w,260px);
    z-index:1029;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior:contain;
    background:var(--rd-surface);
    border-right:1px solid var(--rd-border);
    padding:.75rem 1rem 1rem;
    color:var(--rd-ink);
  }

  /* Content offset. padding-right, NEVER margin-right: .container-fluid
     is width:100%, so margin-right would overflow (today masked only
     by body overflow-x:hidden, which would silently clip). The width
     and the offset share --rd-side-w so they can never drift apart.
     padding-bottom is deliberately untouched: the 86px FAB clearance
     from reno.css stays exactly as it is. */
  html:not([data-rd-nav="right"]):not([data-rd-nav="top"]) .app-main{padding-left:calc(var(--rd-side-w,260px) + 1rem);}
  html[data-rd-nav="right"] .app-main{padding-right:calc(var(--rd-side-w,260px) + 1rem);}

  /* Footer offset. footer.php renders </main> followed immediately by
     <footer>, so the adjacent-sibling selector is a clean, precise
     match. Pages with a different footer simply get no offset, and
     their centred footer text cannot clip under the sidebar. */
  html:not([data-rd-nav="right"]):not([data-rd-nav="top"]) main.app-main + footer{padding-left:calc(var(--rd-side-w,260px) + 1rem);}
  html[data-rd-nav="right"] main.app-main + footer{padding-right:calc(var(--rd-side-w,260px) + 1rem);}

  /* Brand: light surface, so icons use filter:none (the dropdown
     variant), never the dark-bar filter:invert(1). */
  .rd-side-brand{padding:.25rem .25rem .75rem;border-bottom:1px solid var(--rd-border);margin-bottom:.75rem;}
  .rd-side-brand-link{display:flex;align-items:center;gap:.5rem;color:var(--rd-ink);text-decoration:none;font-weight:700;font-size:1.05rem;min-width:0;}
  .rd-side-brand-link:hover{color:var(--rd-ink);text-decoration:none;}
  .rd-side-brand-icon{width:22px;height:22px;flex-shrink:0;filter:none;}
  .rd-side-brand-product{flex-shrink:0;}
  .rd-side-brand-sep{flex-shrink:0;opacity:.55;}
  .rd-side-brand-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}

  .rd-side-pinned{padding-bottom:.5rem;border-bottom:1px solid var(--rd-border);margin-bottom:.5rem;}
  .rd-side-direct{margin-bottom:.5rem;}

  /* Links. Transparent left border on every row so the active
     border does not shift text. Active = the header dropdown-item
     pattern: accent-soft wash, accent text, weight 600. */
  .rd-side-link{
    display:flex;align-items:center;gap:.5rem;
    padding:.45rem .6rem;border-radius:.5rem;
    color:var(--rd-ink);text-decoration:none;font-size:.9rem;
    border-left:3px solid transparent;
  }
  .rd-side-link:hover{color:var(--rd-ink);background:var(--rd-surface2);text-decoration:none;}
  .rd-side-link.active{background:var(--rd-accent-soft);color:var(--rd-accent);font-weight:600;border-left:3px solid var(--rd-accent);}
  .rd-side-icon{width:16px;height:16px;flex-shrink:0;filter:none;}
  .rd-side-label{flex:1 1 auto;min-width:0;}
  .rd-side-badge{
    flex-shrink:0;min-width:18px;height:18px;padding:0 4px;border-radius:9px;
    background:var(--rd-danger-soft);color:var(--rd-danger);font-size:.65rem;line-height:18px;
    text-align:center;font-weight:700;
  }
  .rd-side-pro{font-size:.6rem;flex-shrink:0;}

  /* Accordion groups. Multi-open by design: toggling one group never
     closes another (sidebar.js toggles only the clicked group). */
  .rd-side-group{margin-bottom:.25rem;}
  .rd-side-group-toggle{
    display:flex;align-items:center;justify-content:space-between;width:100%;
    padding:.5rem .6rem;border:0;border-radius:.5rem;background:transparent;
    color:var(--rd-muted);font-size:.8rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;
    cursor:pointer;text-align:left;
  }
  .rd-side-group-toggle:hover{color:var(--rd-ink);background:var(--rd-surface2);}
  .rd-side-group-title{flex:1 1 auto;}
  /* CSS-only chevron (border trick, no image asset). Points right
     when closed, down when open. */
  .rd-side-chev{
    width:8px;height:8px;flex-shrink:0;
    border-right:2px solid var(--rd-muted);border-bottom:2px solid var(--rd-muted);
    transform:rotate(-45deg);transition:transform .15s ease;
  }
  .rd-side-group.open .rd-side-chev{transform:rotate(45deg);}
  .rd-side-group-body{display:none;padding-left:.25rem;}
  .rd-side-group.open .rd-side-group-body{display:block;}

  /* Footer area: theme row + switcher + logout. The theme buttons
     reuse reno.css .rd-theme-row/.rd-theme-btn; only the sidebar
     padding context is adjusted here. */
  .rd-side-footer{border-top:1px solid var(--rd-border);margin-top:.75rem;padding-top:.75rem;}
  .rd-side-theme-label{font-size:.78rem;font-weight:600;color:var(--rd-muted);padding:0 .25rem .25rem;}
  .rd-side-footer .rd-theme-row{padding:.25rem 0 .75rem;}
  .rd-side-footer form{width:100%;padding-bottom:.5rem;}
  .rd-side-footer form .form-select{width:100%;}
  /* RD-NAV-V2-POS: right-mode panel mirror + top-mode panel off.
     Base panel above is LEFT (left:0, border-right); these
     overrides only match their own mode, so no mode leaks into
     another and Top mode never carries a sidebar offset: the
     offset rules above are scoped to left / right only, so in
     Top mode .app-main and the footer keep their natural
     padding (Bootstrap container gutter, 0.75rem each side at
     desktop for .app-main; 0 for the bare <footer>). Nothing is
     zeroed in Top mode — 'reset' means 'no sidebar offset'. */
  html[data-rd-nav="right"] .rd-side-nav{left:auto;right:0;border-left:1px solid var(--rd-border);border-right:0;}
  html[data-rd-nav="top"] .rd-side-nav{display:none;}
}

@media print{
  /* Print: hide the panel and remove its offset, or every printed
     page would carry a 260px blank strip on the right. */
  .rd-side-nav{display:none !important;}
  .app-main{padding-right:0 !important;padding-left:0 !important;}
  main.app-main + footer{padding-right:0 !important;padding-left:0 !important;}
}

@media (prefers-reduced-motion:reduce){
  .rd-side-chev{transition:none;}
}

/* RD-NAV-V2-POS: navigation-position picker (Left / Right / Top).
   Per-device localStorage only ('rd-nav-pos'), same pattern as the
   theme picker; no server state, no migration. Token-only colours,
   so every theme keeps working. The topbar control is hidden at
   every width by the base rule below and shown ONLY in Top mode at
   >=992px; the sidebar-footer control lives inside .rd-side-nav,
   which is itself display:none below 992px and in Top mode. */
.rd-nav-pos-topbar{display:none;}
@media (min-width:992px){
  html[data-rd-nav="top"] .rd-nav-pos-topbar{display:flex;gap:.5rem;align-items:center;margin-left:auto;}
  .rd-nav-pos-row{display:flex;gap:.5rem;flex-wrap:wrap;}
  .rd-nav-pos-btn{
    flex:1 1 auto;border:1px solid var(--rd-border);background:var(--rd-surface);
    color:var(--rd-ink);border-radius:.6rem;padding:.5rem .4rem;font-size:.78rem;
    font-weight:600;cursor:pointer;
  }
  .rd-nav-pos-btn[aria-pressed="true"]{border-color:var(--rd-accent);box-shadow:0 0 0 2px var(--rd-accent-soft);}
  .rd-nav-pos-label{font-size:.78rem;font-weight:600;color:var(--rd-muted);padding:0 .25rem .25rem;}
  .rd-side-footer .rd-nav-pos-row{padding:.25rem 0 .75rem;}
  /* Dark top bar: same buttons, navbar tokens instead of surface. */
  .app-navbar .rd-nav-pos-btn{background:transparent;color:var(--rd-nav-ink);border-color:rgba(255,255,255,.3);}
  .app-navbar .rd-nav-pos-btn[aria-pressed="true"]{border-color:rgba(255,255,255,.9);box-shadow:0 0 0 2px rgba(255,255,255,.25);}
  .app-navbar .rd-nav-pos-topbar .rd-nav-pos-btn{flex:0 0 auto;padding:.4rem .6rem;}
}

/* RD-NAV-V2A-SETTINGS-CSS: base styling for the settings-page navigation
   position buttons ONLY (scoped to .rd-nav-pos-settings). The reused
   v2 picker rules live inside @media (min-width:992px), so without
   this block the settings buttons would be unstyled browser buttons
   below 992px. Same tokens and same values as the desktop rules, so
   desktop rendering is unchanged and the pressed state is visible at
   every width. The setting itself still only affects desktop layout;
   only these buttons are styled at every width. */
.rd-nav-pos-settings .rd-nav-pos-row{display:flex;gap:.5rem;flex-wrap:wrap;}
.rd-nav-pos-settings .rd-nav-pos-btn{
  flex:1 1 auto;border:1px solid var(--rd-border);background:var(--rd-surface);
  color:var(--rd-ink);border-radius:.6rem;padding:.5rem .4rem;font-size:.78rem;
  font-weight:600;cursor:pointer;
}
.rd-nav-pos-settings .rd-nav-pos-btn[aria-pressed="true"]{border-color:var(--rd-accent);box-shadow:0 0 0 2px var(--rd-accent-soft);}

/* BUGFIX-V1-FAB-SIDEBAR: the fixed headset button in footer.php sits
   at bottom-left over the left sidebar footer (Logout). On desktop
   in left-sidebar mode only, move it right of the panel and give the
   panel bottom clearance. Right and top modes, and phones, unchanged. */
@media (min-width:992px) {
  html:not([data-rd-nav="right"]):not([data-rd-nav="top"]) .contact-admin-fab {
    left: calc(var(--rd-side-w, 260px) + 20px) !important;
  }
  /* FINAL-V1-FAB: right:auto so no right-based rule fights the left move; footer clearance so Logout clears even an unmoved button. */
  html:not([data-rd-nav="right"]):not([data-rd-nav="top"]) .contact-admin-fab {
    right: auto !important;
  }
  html:not([data-rd-nav="right"]):not([data-rd-nav="top"]) .rd-side-footer {
    padding-bottom: 90px;
  }
  html:not([data-rd-nav="right"]):not([data-rd-nav="top"]) .rd-side-nav {
    padding-bottom: 90px;
  }
}

/* CLEANUP-V1A-TOPBAR: desktop left and right sidebar modes, the
   dark top bar goes away because the sidebar already carries the
   brand and the nav, saving vertical space. Top mode keeps the bar
   (the nav lives there) and phones keep it (the sidebar panel is
   hidden below 992px). The sidebar panel is fixed at top 0 and the
   bar is in normal flow, so no content or sidebar offset changes
   are needed, and the bugfix v1 help-button move and sidebar
   bottom clearance are untouched. */
@media (min-width:992px) {
  html:not([data-rd-nav="top"]) body:has(.rd-side-nav) .app-navbar{display:none;}
}

/* CLEANUP-V1-LANG-CSS: language buttons reuse the theme button look;
   only the pressed state is defined here, scoped to the language row. */
.rd-lang-row .rd-lang-btn[aria-pressed="true"]{border-color:var(--rd-accent);box-shadow:0 0 0 2px var(--rd-accent-soft);}

/* SIDEBAR-TOP-POLISH-V1: logo + scan as an in-flow panel header. No fixed positioning: the zone is the panel's first child, so it sits at the panel top in every mode, and the panel's own hiding (top mode, phones) hides it too. */
.rd-side-logo{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.25rem .25rem .75rem;border-bottom:1px solid var(--rd-border);margin-bottom:.75rem;}
.rd-side-logo-img{max-height:44px;max-width:150px;object-fit:contain;flex-shrink:1;min-width:0;border-radius:.5rem;}
.rd-side-logo-text{font-weight:700;font-size:1rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:1;min-width:0;}
.rd-side-scan{display:inline-flex;align-items:center;gap:.35rem;font-weight:600;font-size:.85rem;padding:.45rem .7rem;border-radius:999px;background:var(--rd-accent,#0e5a4e);color:#fff;text-decoration:none;white-space:nowrap;flex-shrink:0;box-shadow:0 1px 3px rgba(0,0,0,.18);}
.rd-side-scan:hover{color:#fff;text-decoration:none;filter:brightness(1.1);}
.rd-side-scan img{width:18px;height:18px;flex-shrink:0;filter:invert(1);}