/* Shared app menu — a hamburger button in the top bar that opens a PowerDoc-style
   dropdown card with cross-page navigation + logout. Loaded on every admin page
   (designer, requests, api-docs). The single source of truth for the items is the
   MENU array in menu.js — add a page there once and it shows up everywhere.

   The button uses currentColor so it adapts to both bar themes (white-on-dark on the
   designer/requests bars, ink-on-paper on the api-docs bar). The dropdown panel is
   always a light card, regardless of which bar opened it. */

/* NOTE: only --brand / --brand-hover / --line are used as tokens here, because the menu
   loads on the not-yet-migrated designer & new-request pages too, and those define only
   that subset. The remaining literals (#EFEDE7, #C0473F, #A33A33, #75726c, #1a1a1a) become
   tokens once every page links design-system.css. */
.app-menu { display: inline-flex; align-items: center; flex: none; }

.menu-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: inherit; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.menu-btn:hover { background: rgba(128, 128, 128, .16); }
.menu-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.menu-btn svg { width: 22px; height: 22px; display: block; }
.menu-btn.open { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Invisible click-catcher: closing the menu when you click anywhere outside it. */
.menu-overlay { position: fixed; inset: 0; z-index: 90; background: transparent; }

.menu-panel {
  position: fixed; z-index: 100; width: 280px; max-width: calc(100vw - 16px);
  background: #fff; color: #1a1a1a;
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 18px 50px rgba(20, 18, 14, .22);
  padding: 8px; overflow: hidden;
  font-family: 'Assistant', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transform-origin: top; opacity: 0; transform: translateY(-6px);
  transition: opacity .14s ease, transform .14s ease;
}
.menu-panel.show { opacity: 1; transform: none; }

/* Identity header (avatar + name + org), mirroring the PowerDoc account block. */
.menu-id {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 12px; margin-bottom: 6px; border-bottom: 1px solid #EFEDE7;
}
.menu-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--brand); color: #fff; font-weight: 600; font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
}
.menu-id-text { min-width: 0; }
.menu-id-name { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-id-sub { color: #75726c; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 12px; border: none; border-radius: 10px; background: none;
  color: #1a1a1a; font: inherit; font-size: .95rem; text-align: start;
  text-decoration: none; cursor: pointer; position: relative;
}
.menu-item svg { width: 19px; height: 19px; flex: none; color: #75726c; }
.menu-item:hover { background: rgba(26, 122, 78, .08); color: var(--brand-hover); }
.menu-item:hover svg { color: var(--brand-hover); }

/* Active page — brand color + a PowerDoc-style indicator bar on the inline-start edge. */
.menu-item.active { color: var(--brand); font-weight: 600; }
.menu-item.active svg { color: var(--brand); }
.menu-item.active::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 50%;
  transform: translateY(-50%); width: 4px; height: 22px; border-radius: 0 4px 4px 0;
  background: var(--brand);
}

.menu-sep { height: 1px; background: #EFEDE7; margin: 6px 8px; }

.menu-item.danger { color: #C0473F; }
.menu-item.danger svg { color: #C0473F; }
.menu-item.danger:hover { background: rgba(192, 71, 63, .10); color: #A33A33; }
.menu-item.danger:hover svg { color: #A33A33; }

/* Per-row overflow (kebab) menu — pinned to <body>, positioned in JS by openRowMenu()
   (menu.js). Shared by the designer templates list and the signing-requests list. Tokens
   carry literal fallbacks because this file also loads on pages that define only a subset. */
.row-menu { position: fixed; z-index: 50; background: var(--surface, #fff); border: 1px solid var(--line); border-radius: var(--radius-md, 9px); box-shadow: 0 8px 28px rgba(0, 0, 0, .18); padding: 4px; min-width: 200px; }
.row-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: start; background: none; border: none; border-radius: var(--radius-sm, 5px); padding: 8px 10px; font: inherit; color: var(--ink, #1A1A18); cursor: pointer; }
.row-menu-item:hover { background: var(--line-muted, #EFEDE7); }
.row-menu-item.danger { color: var(--danger, #C0473F); }
.row-menu-item:disabled { opacity: .45; cursor: default; }
.row-menu-item:disabled:hover { background: none; }
.row-menu-item svg { width: 14px; height: 14px; flex: none; }
