/* portal-shell.css: shared chrome for the dealer portal.
 * Used by every portal page: the dashboard, the order form, Account and the
 * sign-in / forgot / reset pages. Anything page-specific (gun-strip,
 * order-group, po-summary, ...) stays in its view.
 * Every colour is a main.css token, so the portal follows the same light and
 * dark values as the staff app (it used to carry its own #111 / #555 / #9A9A9A
 * palette, a second dark mode beside the staff one).
 */

/* ── Portal Nav ─────────────────────────────────────── */
.portal-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 2rem;
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
}

.portal-brand-home,
.portal-brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  transition: opacity var(--duration-base) var(--ease-out);
}
.portal-brand-home {
  justify-self: start;
  min-width: 0;
}
.portal-brand-link {
  justify-self: center;
}
.portal-brand-home:hover,
.portal-brand-home:focus-visible,
.portal-brand-link:hover,
.portal-brand-link:focus-visible { opacity: 0.7; outline: none; }
.portal-brand-logo {
  height: 32px;
  width: auto;
  color: var(--ink);
  flex-shrink: 0;
}

.portal-brand {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--ink);
}
.portal-brand-light { font-weight: 400; color: var(--ink-muted); }

.portal-user {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.9rem;
  justify-self: end;
}

/* Theme toggle wrapper (re-used "completed-toggle" class for layout). */
.portal-theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.portal-theme-toggle input { cursor: pointer; }
.portal-theme-toggle .portal-theme-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* User dropdown — dealer name acts as menu trigger. */
.portal-user-menu { position: relative; }
.portal-user-btn {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-subtle);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color var(--duration-base) var(--ease-out);
}
.portal-user-btn:hover,
.portal-user-btn[aria-expanded="true"] { color: var(--accent-strong); }
.portal-user-btn .chevron {
  font-size: 0.7rem;
  transition: transform 0.15s;
}
.portal-user-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.portal-user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.4rem;
  min-width: 180px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  z-index: var(--z-dropdown);
  overflow: hidden;
  display: none;
}
.portal-user-dropdown.open { display: block; }
.portal-user-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background var(--duration-fast) var(--ease-out);
}
.portal-user-dropdown-item:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
html.theme-dark .portal-user-dropdown-item:hover { background: var(--paper-hover); }
.portal-user-dropdown-signout {
  color: var(--error-text);
  border-top: 1px solid var(--line);
}
.portal-user-dropdown-signout:hover,
html.theme-dark .portal-user-dropdown-signout:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

/* ── Sign-in, forgot and reset pages (the shared .login-card) ── */
.portal-auth-logo { text-align: center; margin-bottom: var(--space-md); color: var(--ink); }
.portal-auth-logo svg { height: 40px; width: auto; }
.portal-auth-links { text-align: center; margin-top: var(--space-lg); }
/* Was an inline #555, which read 2.4:1 on the dark card. */
.portal-auth-link {
  display: inline-block;
  padding: var(--space-xs) 0;
  color: var(--ink-subtle);
  font-size: var(--fs-md);
  text-decoration: none;
  text-underline-offset: 3px;
}
.portal-auth-link:hover { color: var(--accent-strong); text-decoration: underline; }

/* ── Mobile (<769px) ───────────────────────────────────── */
@media (max-width: 768px) {
  .portal-nav { padding: 0 0.75rem; height: 56px; gap: 0.5rem; }
  .portal-brand-logo { height: 26px; }
  .portal-brand { font-size: 0.85rem; letter-spacing: 0.04em; }
  .portal-brand-light { display: none; }
  .portal-user { gap: 0.6rem; font-size: 0.8rem; }
  .portal-theme-toggle .portal-theme-label { display: none; }
  /* The 44px touch target, as the staff user button has (it was 28.2px). */
  .portal-user-btn { min-width: 0; min-height: var(--control-h-lg); max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .portal-user-dropdown-item { min-height: var(--control-h-lg); }
  .portal-user .portal-dealer-name { display: none; }
}

/* Portal buttons: the portal's own violet family (owner's ruling, design
 * review round 3). Every button a dealer presses is a .po-btn of one kind, in
 * sentence case, so the portal no longer mixes these with the staff app's
 * black uppercase .btn-primary / .btn-secondary.
 *
 *   .po-btn-primary    violet fill: the one action a page or panel exists for
 *   .po-btn-secondary  violet outline (also the look of a bare .po-btn)
 *   .po-btn-danger     error outline: Discard, Remove
 *
 * One 1px border on every kind. Sizes are the shared control heights, built
 * from an 18px line + padding + border, with the token as the floor so the
 * md and xs steps grow to 44px at <=768px with the rest of the app:
 *   .po-btn-xs  28px  4px pad   list-row actions
 *   .po-btn     36px  8px pad   page header, panel actions (default)
 *   .po-btn-lg  44px  12px pad  form footers (.po-actions), sign-in pages
 */
.po-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--control-h);
  min-width: var(--control-h);
  padding: 8px var(--control-pad-x);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 18px;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  border: 1px solid var(--accent);
  border-radius: var(--radius-none);
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  transition: background var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out),
              color var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out);
}
.po-btn:hover { background: var(--accent-soft); border-color: var(--accent-strong); color: var(--accent-strong); }
.po-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.po-btn.btn-full { display: flex; width: 100%; }

.po-btn-xs {
  min-height: var(--control-h-xs);
  min-width: var(--control-h-xs);
  padding: 4px var(--control-pad-x-xs);
  font-size: var(--fs-sm);
}
.po-btn-lg {
  min-height: var(--control-h-lg);
  min-width: var(--control-h-lg);
  padding: 12px var(--control-pad-x-lg);
}

/* White on --accent reads 7.1:1; in dark mode the fill is the lighter
   #A855F7, where white read 3.96:1, so the label is --paper there (4.9:1). */
.po-btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.po-btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #FFFFFF; }
html.theme-dark .po-btn-primary:not(:disabled):not([aria-disabled="true"]) { color: var(--paper); }

.po-btn-danger { border-color: var(--error-text); color: var(--error-text); }
.po-btn-danger:hover { background: var(--error-bg); border-color: var(--error-text); color: var(--error-text); }

/* A disabled action never renders at full accent (the 2026-09-11 ruling). */
.po-btn:disabled,
.po-btn[aria-disabled="true"] {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-disabled);
  cursor: not-allowed;
  box-shadow: none;
}
/* Submit order / Save changes disable themselves while the post is on its way. */
.po-btn-primary:disabled { cursor: wait; }
