/* ─────────────────────────────────────────────────────────────
   AGT left sidebar menu (Oct 2026)
   Computers (wider than 900px): the top bar becomes a fixed menu on the left.
   Phones/tablets: the ☰ button moves to the left and the menu slides in from
   the left (the slide-in drawer itself is unchanged).
   Loaded last in includes/header.php, only matters when body has .agt-sidebar
   (signed-in pages). Login / public pages are untouched.
   ───────────────────────────────────────────────────────────── */

.sidebar-only { display: none; }

@media (min-width: 901px) {
  :root { --agt-sidebar-w: 240px; }

  body.agt-sidebar { padding-left: var(--agt-sidebar-w); }
  body.agt-sidebar .sidebar-only { display: inline-block; }

  /* Bar → fixed column on the left */
  :root[data-theme] body.agt-sidebar .topnav,
  body.agt-sidebar .topnav {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--agt-sidebar-w); height: auto;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    padding: 0; gap: 0;
    border-bottom: 0; border-right: 1px solid rgba(255,255,255,.06);
    box-shadow: 1px 0 0 rgba(0,0,0,.2);
    overflow-y: auto !important; overflow-x: hidden !important;
    overflow-anchor: none;
    scrollbar-width: thin; z-index: 1000;
  }
  body.agt-sidebar .topnav::-webkit-scrollbar { width: 6px; }
  body.agt-sidebar .topnav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 6px; }

  :root[data-theme] body.agt-sidebar .topnav-brand,
  body.agt-sidebar .topnav-brand {
    height: auto; padding: 18px 16px 14px; margin: 0;
    border-right: 0; border-bottom: 1px solid rgba(255,255,255,.08);
    flex-direction: column; align-items: flex-start; gap: 10px;
  }
  body.agt-sidebar .topnav-logo img { height: 32px; }
  body.agt-sidebar .topnav .brand { white-space: normal; font-size: 15px; line-height: 1.25; }
  body.agt-sidebar .topnav-sub { white-space: normal; max-width: none; color: rgba(255,255,255,.5); }

  body.agt-sidebar #siteNav { flex: 1 0 auto; height: auto; overflow: visible !important; }
  body.agt-sidebar .desktop-nav,
  body.agt-sidebar .desktop-nav-main {
    height: auto; flex-direction: column; align-items: stretch; justify-content: flex-start;
  }

  /* Main links */
  body.agt-sidebar .desktop-nav-primary {
    flex-direction: column; align-items: stretch; height: auto;
    overflow: visible; gap: 2px; padding: 10px 10px 4px; flex: 0 0 auto;
  }
  :root[data-theme] body.agt-sidebar .desktop-nav-primary > a,
  body.agt-sidebar .desktop-nav-primary > a {
    height: auto; padding: 9px 12px; gap: 10px;
    border-radius: 9px; font-size: 13.5px;
    color: rgba(255,255,255,.72);
  }
  body.agt-sidebar .desktop-nav-primary > a::after { display: none; }
  body.agt-sidebar .desktop-nav-primary > a:hover { background: rgba(255,255,255,.07); color: #fff; }
  body.agt-sidebar .desktop-nav-primary > a.active { background: rgba(59,130,246,.22); color: #fff; }

  /* Groups → accordions */
  body.agt-sidebar .desktop-nav-sections {
    flex-direction: column; align-items: stretch; height: auto;
    padding: 4px 10px 14px; gap: 2px; flex-shrink: 0;
  }
  body.agt-sidebar .desktop-nav-group { height: auto; display: block; position: static; }
  :root[data-theme] body.agt-sidebar .desktop-nav-group > summary,
  body.agt-sidebar .desktop-nav-group > summary {
    display: flex; justify-content: space-between; width: 100%;
    height: auto; padding: 9px 12px; border-radius: 9px;
    font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    color: rgba(255,255,255,.45);
  }
  body.agt-sidebar .desktop-nav-group > summary:hover { color: #fff; background: rgba(255,255,255,.05); }
  body.agt-sidebar .desktop-nav-group > summary::after { content: '▸'; font-size: 10px; transition: transform .15s ease; }
  body.agt-sidebar .desktop-nav-group[open] > summary::after { transform: rotate(90deg); }
  body.agt-sidebar .desktop-nav-group.is-current > summary { color: rgba(255,255,255,.85); }

  :root[data-theme] body.agt-sidebar .desktop-nav-dropdown,
  body.agt-sidebar .desktop-nav-dropdown {
    position: static; min-width: 0; padding: 0 0 6px 4px; margin: 0;
    background: transparent !important; border: 0 !important; box-shadow: none;
    border-radius: 0; animation: none;
  }
  :root[data-theme] body.agt-sidebar .desktop-nav-dropdown a,
  body.agt-sidebar .desktop-nav-dropdown a {
    padding: 8px 12px; border-radius: 9px; font-size: 13px;
    color: rgba(255,255,255,.68) !important;
  }
  body.agt-sidebar .desktop-nav-dropdown a:hover { background: rgba(255,255,255,.07) !important; color: #fff !important; }
  body.agt-sidebar .desktop-nav-dropdown a.active { background: rgba(59,130,246,.22) !important; color: #fff !important; }

  /* "+ New" button: full width at the top of the groups */
  :root[data-theme] body.agt-sidebar .desktop-nav-group-new > summary {
    height: 38px; margin: 0 0 6px; justify-content: center; gap: 6px;
    font-size: 13px; letter-spacing: 0; text-transform: none; color: #fff !important;
  }
  body.agt-sidebar .desktop-nav-group-new > summary::after { content: '▾'; }
  body.agt-sidebar .desktop-nav-group-new[open] > summary::after { transform: none; }
  :root[data-theme] body.agt-sidebar .desktop-nav-group-new .desktop-nav-dropdown { padding: 0 0 8px; }

  /* Settings link */
  body.agt-sidebar .desktop-nav-settings {
    display: flex; align-items: center; gap: 10px; margin-top: 6px;
    padding: 9px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
    color: rgba(255,255,255,.72); border-top: 1px solid rgba(255,255,255,.07);
  }
  body.agt-sidebar .desktop-nav-settings:hover { background: rgba(255,255,255,.07); color: #fff; }
  body.agt-sidebar .desktop-nav-settings.active { background: rgba(59,130,246,.22); color: #fff; }

  /* Theme switch + account at the bottom */
  :root[data-theme] body.agt-sidebar .agt-theme-toggle-desktop { margin: 8px 2px 4px; align-self: flex-start; }
  :root[data-theme] body.agt-sidebar .desktop-nav-group-account > summary {
    text-transform: none; letter-spacing: 0; font-size: 13px; color: rgba(255,255,255,.8);
    justify-content: flex-start; gap: 8px;
  }
  body.agt-sidebar .desktop-nav-group-account > summary::after { margin-left: auto; }
  body.agt-sidebar .desktop-nav-icon { width: 18px; text-align: center; flex-shrink: 0; }

  /* Page area */
  body.agt-sidebar main.container { max-width: 1440px; }
  body.agt-sidebar .mobile-form-dock { left: var(--agt-sidebar-w); }
}

/* ── Collapse arrow (Oct 2026): ‹ shrinks the sidebar to icons, › pulls it back out ── */
.agt-collapse-btn { display: none; }
.agt-group-ico, .agt-new-plus { display: none; }
@media (min-width: 901px) {
  body.agt-sidebar .topnav-brand { position: relative; padding-right: 44px; }
  body.agt-sidebar .agt-collapse-btn {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 16px; right: 10px; width: 28px; height: 28px; padding: 0;
    border-radius: 8px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
    color: #fff; font-size: 18px; line-height: 1; cursor: pointer; min-height: 0;
  }
  body.agt-sidebar .agt-collapse-btn:hover { background: rgba(255,255,255,.16); }
  body.agt-sidebar .desktop-nav-group-new > summary .agt-new-plus { display: inline; }
  body.agt-sidebar .desktop-nav, body.agt-sidebar .topnav, body.agt-sidebar { transition: padding-left .18s ease, width .18s ease; }

  body.agt-sidebar.agt-collapsed { --agt-sidebar-w: 64px; }
  body.agt-sidebar.agt-collapsed .topnav-brand { padding: 14px 0 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
  body.agt-sidebar.agt-collapsed .topnav-brand .brand,
  body.agt-sidebar.agt-collapsed .topnav-brand .topnav-sub,
  body.agt-sidebar.agt-collapsed .topnav-brand-text { display: none; }
  body.agt-sidebar.agt-collapsed .topnav-logo { width: 32px; overflow: hidden; }
  body.agt-sidebar.agt-collapsed .topnav-logo img { height: 32px; width: auto; max-width: none; }
  body.agt-sidebar.agt-collapsed .agt-collapse-btn { position: static; width: 36px; height: 32px; }

  /* links: icon only, centred */
  body.agt-sidebar.agt-collapsed .desktop-nav-primary { padding: 10px 8px 4px; }
  :root[data-theme] body.agt-sidebar.agt-collapsed .desktop-nav-primary > a,
  body.agt-sidebar.agt-collapsed .desktop-nav-primary > a { justify-content: center; padding: 10px 0; }
  body.agt-sidebar.agt-collapsed .desktop-nav-primary > a > span:not(.desktop-nav-icon) { display: none; }
  body.agt-sidebar.agt-collapsed .desktop-nav-icon { width: auto; font-size: 18px; }

  /* groups: an icon; the links open as a pop-out beside the menu */
  body.agt-sidebar.agt-collapsed .desktop-nav-sections { padding: 4px 8px 14px; }
  body.agt-sidebar.agt-collapsed .agt-group-ico { display: inline; font-size: 18px; letter-spacing: 0; }
  body.agt-sidebar.agt-collapsed .desktop-nav-group > summary .agt-nav-text { display: none; }
  :root[data-theme] body.agt-sidebar.agt-collapsed .desktop-nav-group > summary,
  body.agt-sidebar.agt-collapsed .desktop-nav-group > summary { justify-content: center; padding: 10px 0; }
  body.agt-sidebar.agt-collapsed .desktop-nav-group > summary::after { display: none; }
  :root[data-theme] body.agt-sidebar.agt-collapsed .desktop-nav-group-new > summary { font-size: 20px; padding: 0; }
  :root[data-theme] body.agt-sidebar.agt-collapsed .desktop-nav-dropdown,
  body.agt-sidebar.agt-collapsed .desktop-nav-dropdown {
    position: fixed; left: 70px; right: auto !important; top: 80px; width: max-content !important; min-width: 220px; max-width: 300px; max-height: 80vh; overflow-y: auto;
    padding: 6px !important; z-index: 1200;
    background: #0f172a !important; border: 1px solid rgba(255,255,255,.12) !important;
    border-radius: 12px; box-shadow: 0 14px 34px rgba(0,0,0,.35);
  }
  body.agt-sidebar.agt-collapsed .desktop-nav-group:not([open]) > .desktop-nav-dropdown { display: none; }
  body.agt-sidebar.agt-collapsed .desktop-nav-dropdown a > span { display: inline !important; }

  /* settings, theme switch and account */
  :root[data-theme] body.agt-sidebar.agt-collapsed .desktop-nav-settings,
  body.agt-sidebar.agt-collapsed .desktop-nav-settings { justify-content: center; padding: 10px 0; }
  body.agt-sidebar.agt-collapsed .desktop-nav-settings > span:not(.desktop-nav-icon) { display: none; }
  :root[data-theme] body.agt-sidebar.agt-collapsed .agt-theme-toggle-desktop { align-self: center; margin: 8px 0 4px; }
  :root[data-theme] body.agt-sidebar.agt-collapsed .desktop-nav-group-account > summary { font-size: 0; justify-content: center; gap: 0; }
  body.agt-sidebar.agt-collapsed .desktop-nav-group-account > summary .nav-user-avatar { font-size: 12px; }
}

/* Phones & tablets: ☰ on the left, next to the business name */
@media (max-width: 900px) {
  body.agt-sidebar .topnav .menu-toggle { order: -1; margin: 0 10px 0 0 !important; }
  /* Drawer above the top bar so its own header and ✕ are visible */
  body.agt-sidebar .phone-drawer-overlay { z-index: 1100; }
  body.agt-sidebar .topnav-brand { border-right: 0; padding-right: 0; }
}

@media print {
  body.agt-sidebar { padding-left: 0 !important; }
}
