/* ==========================================================================
   NO-Portal UI — page frame: left menu, top bar, section links on top,
   impersonation bar, footer. Colours, fonts and sizes come from tokens.css.
   ========================================================================== */

.npui-app { display: flex; align-items: stretch; min-height: 100vh; }

/* ---------- Left menu ---------- */
.npui-sidebar {
  width: var(--np-sidebar-w); flex-shrink: 0; position: relative; z-index: 40;
  display: flex; flex-direction: column; background: var(--np-sidebar-bg); font-family: var(--np-font); transition: width .15s;
}
.npui-sidebar.collapsed { width: var(--np-sidebar-w-collapsed); }

/* Logo at the top of the menu (same height as the top bar), drawn white */
.npui-sidebar-brand { height: var(--np-topbar-h); box-sizing: border-box; flex-shrink: 0; display: flex; align-items: center; justify-content: center; padding: 0 14px; text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--np-on-dark) 30%, transparent); }
.npui-brand-full { display: flex; align-items: center; justify-content: center; width: 100%; height: 40px; }
.npui-brand-full img { max-height: 32px; max-width: 100%; width: auto; display: block; filter: brightness(0) invert(1); }
.npui-brand-mark { display: none; width: 36px; height: 36px; border-radius: var(--np-radius); }
.npui-sidebar.collapsed .npui-sidebar-brand { padding: 0; }
.npui-sidebar.collapsed .npui-brand-full { display: none; }
.npui-sidebar.collapsed .npui-brand-mark { display: block; }
.npui-sidebar-brand:focus-visible { outline: 2px solid var(--np-on-dark); outline-offset: -4px; }

.npui-nav { display: flex; flex-direction: column; width: 100%; flex: 1; }
.npui-nav-item { position: relative; width: 100%; }
.npui-nav-link {
  width: 100%; min-height: 46px; display: flex; align-items: center; padding: 0; position: relative; isolation: isolate;
  color: var(--np-sidebar-text); background: transparent; border: 0; border-left: 4px solid var(--icon-color);
  text-align: left; text-decoration: none; cursor: pointer; font: inherit;
}
.npui-nav-link:hover { color: var(--np-sidebar-text); text-decoration: none; }
.npui-nav-link::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--icon-color);
  transform: scaleX(0); transform-origin: 0 center; transition: transform .1s ease-in-out;
}
.npui-nav-item:hover > .npui-nav-link::before,
.npui-nav-item.open > .npui-nav-link::before,
.npui-nav-link:focus-visible::before,
.npui-nav-link.active::before { transform: scaleX(1); }
.npui-nav-link:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
/* Highlighted row: text and icon in the item's ink (white on a dark colour, dark text on a light one) */
.npui-nav-item:hover > .npui-nav-link,
.npui-nav-item.open > .npui-nav-link,
.npui-nav-link:focus-visible,
.npui-nav-link.active { color: var(--icon-ink, var(--np-sidebar-text)); }
.npui-icon-slot { width: 52px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.npui-label { font-size: var(--np-font-size); font-weight: 500; padding: 0 8px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.npui-chevron { font-size: 14px; margin-right: 12px; opacity: .7; }
.npui-badge {
  margin-right: 10px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; flex-shrink: 0;
  background: rgba(255,255,255,.22); color: var(--np-on-dark); font-size: 11px; font-weight: 600; line-height: 20px; text-align: center;
}
.npui-sidebar:not(.collapsed) .npui-nav-link:is(.active, :focus-visible) .npui-badge,
.npui-sidebar:not(.collapsed) .npui-nav-item:is(:hover, .open) > .npui-nav-link .npui-badge { background: color-mix(in srgb, currentColor 18%, transparent); color: inherit; }
.npui-sidebar.collapsed :is(.npui-label, .npui-chevron) { display: none; }
.npui-sidebar.collapsed .npui-badge { position: absolute; top: 6px; left: 28px; margin: 0; min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; background: var(--sales); }

/* Flyout with the section's links */
.npui-flyout {
  display: none; position: absolute; left: 100%; top: 0; z-index: 60; width: 248px; padding-bottom: 4px;
  background: var(--np-surface); border-radius: 0 var(--np-radius-sm) var(--np-radius-sm) var(--np-radius-sm); box-shadow: var(--np-shadow);
}
.npui-flyout-title { padding: 10px 16px 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--np-muted); border-bottom: 1px solid var(--np-border); }
.npui-flyout a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px;
  font-size: var(--np-font-size); line-height: 22px; color: var(--np-text); text-decoration: none; border-bottom: 1px solid var(--np-border-soft);
}
.npui-flyout a:last-child { border-bottom: 0; }
.npui-flyout a:is(:hover, :focus-visible) { background: var(--np-surface-2); color: var(--np-strong); text-decoration: none; }
.npui-flyout a.active { font-weight: 600; color: var(--np-strong); box-shadow: inset 3px 0 0 var(--icon-color); }
.npui-flyout-arrow {
  display: none; position: absolute; left: 100%; top: 15px; z-index: 61; width: 16px; height: 16px; pointer-events: none; background: var(--icon-color);
  clip-path: path("M 10.8284 5.17158 C 9.26633 6.73367 6.73367 6.73367 5.17157 5.17157 L 0 0 L 16 0 L 10.8284 5.17158 Z"); transform: rotate(-90deg);
}
.npui-has-flyout:is(:hover, .open) > :is(.npui-flyout, .npui-flyout-arrow) { display: block; }

/* General Settings (last row) — set apart with a divider */
.npui-settings-row { border-top: 1px solid rgba(255,255,255,.12); margin-top: 4px; }
.npui-collapse {
  position: absolute; right: -7px; bottom: 56px; z-index: 2; width: 14px; height: 26px; padding: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  background: var(--np-muted); color: var(--np-on-dark); border: 0; border-radius: 4px; cursor: pointer;
}
.npui-collapse .np-i { transition: transform .15s; }
.npui-sidebar.collapsed .npui-collapse .np-i { transform: rotate(180deg); }

/* ---------- Main column ---------- */
.npui-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.npui-topbar {
  position: sticky; top: 0; z-index: 30; height: var(--np-topbar-h); padding: 0 var(--np-page-pad-x);
  display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--accent-tint); font-family: var(--np-font);
}
.npui-title { margin: 0; font-family: var(--np-display); font-size: var(--np-topbar-title-size); font-weight: 600; color: var(--np-topbar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; }
.npui-user { position: relative; flex-shrink: 0; }
.npui-user-btn { width: 38px; height: 38px; padding: 0; overflow: hidden; border-radius: 50%; border: 2px solid rgba(255,255,255,.8); background: var(--np-surface); cursor: pointer; }
.npui-user-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.npui-user-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 10px); z-index: 100; width: 280px; overflow: hidden;
  background: var(--np-surface); border: 1px solid var(--np-border); border-radius: var(--np-radius-lg); box-shadow: var(--np-shadow);
}
.npui-user.open .npui-user-menu { display: block; }
.npui-user-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--np-border); }
.npui-user-head img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.npui-user-head b { display: block; color: var(--np-strong); font-weight: 600; }
.npui-user-head span { display: block; color: var(--np-muted); font-size: var(--np-font-size-sm); }
.npui-user-menu :is(a, button) { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 18px; border: 0; background: none; font: inherit; color: var(--np-text); text-align: left; text-decoration: none; cursor: pointer; }
.npui-user-menu :is(a, button):is(:hover, :focus-visible) { background: var(--np-surface-2); color: var(--np-strong); text-decoration: none; }
.npui-user-menu form { margin: 0; }

/* Section links on top */
.npui-subtabs { position: sticky; top: var(--np-topbar-h); z-index: 29; padding: 0 var(--np-page-pad-x); background: var(--np-surface); border-bottom: 1px solid var(--np-border); }
.npui-subtabs-links { display: flex; gap: 24px; overflow-x: auto; scrollbar-width: thin; }
.npui-subtabs-links a {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 13px 2px 11px;
  color: var(--np-text); text-decoration: none; border-bottom: 2px solid transparent;
}
.npui-subtabs-links a:hover { border-bottom-color: var(--np-border); text-decoration: none; color: var(--np-strong); }
.npui-subtabs-links a.active { color: var(--np-strong); font-weight: 600; border-bottom-color: var(--accent); }

.npui-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.npui-content > .np-page { flex: 1; }

/* Footer (version line) */
.npui-footer { padding: 14px var(--np-page-pad-x); border-top: 1px solid var(--np-border); text-align: center; font-size: var(--np-font-size-xs); color: var(--np-muted); }
.npui-footer p { margin: 0; }
.npui-footer a { color: var(--np-text); }

/* "Signed in as … — Return to admin" bar (super admin impersonation) */
.npui-impersonation { position: sticky; top: 0; z-index: 2000; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; padding: 8px 18px; background: var(--np-danger); color: var(--np-on-dark); font-size: var(--np-font-size); }
.npui-impersonation form { margin: 0; }
.npui-impersonation .np-btn { background: var(--np-surface); border-color: var(--np-surface); color: var(--np-danger); }

/* ---------- Small screens: icon-only menu, flyouts on tap ---------- */
@media (max-width: 900px) {
  .npui-sidebar { width: var(--np-sidebar-w-collapsed); }
  .npui-sidebar :is(.npui-label, .npui-chevron), .npui-collapse { display: none; }
  .npui-sidebar .npui-badge { position: absolute; top: 6px; left: 28px; margin: 0; min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; background: var(--sales); }
  .npui-has-flyout:hover > :is(.npui-flyout, .npui-flyout-arrow) { display: none; }
  .npui-has-flyout.open > :is(.npui-flyout, .npui-flyout-arrow) { display: block; }
  .npui-topbar, .npui-subtabs, .npui-footer { padding-left: 16px; padding-right: 16px; }
  .npui-sidebar .npui-sidebar-brand { padding: 0; }
  .npui-sidebar .npui-brand-full { display: none; }
  .npui-sidebar .npui-brand-mark { display: block; }
  .npui-title { font-size: 17px; }
  .np-page { padding: 18px 16px 30px; }
}

@media print {
  .npui-sidebar, .npui-topbar, .npui-subtabs, .npui-footer, .npui-impersonation { display: none !important; }
}

/* ==========================================================================
   Signed-out pages (login, forgot / reset / confirm password)
   ========================================================================== */
.npui-auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.npui-auth-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 40px 56px; background: var(--np-sidebar-bg); color: var(--np-on-dark); }
.npui-auth-hero::before, .npui-error::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: linear-gradient(var(--dashboard) 0 12.5%, var(--invoicing) 0 25%, var(--hrm) 0 37.5%, var(--crm) 0 50%, var(--sales) 0 62.5%, var(--projects) 0 75%, var(--hours) 0 87.5%, var(--settings) 0); }
.npui-auth-logo { display: inline-flex; align-items: center; gap: 12px; }
.npui-auth-logo img { height: 36px; width: auto; filter: brightness(0) invert(1); }
.npui-auth-logo span { font-size: var(--np-font-size-sm); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: rgba(255,255,255,.7); }
.npui-auth-hero-body { margin: auto 0; max-width: 520px; padding: 40px 0; }
.npui-auth-hero h2 { margin: 0 0 16px; font-size: 40px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; color: var(--np-on-dark); }
.npui-auth-hero p { margin: 0 0 28px; font-size: 16px; line-height: 1.6; color: rgba(255,255,255,.75); }
.npui-auth-mods { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.npui-auth-mods span { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--np-radius-pill); background: rgba(255,255,255,.08); font-size: var(--np-font-size-sm); }
.npui-auth-quote { border-left: 3px solid var(--dashboard); padding: 4px 0 4px 16px; }
.npui-auth-quote b { display: block; margin-bottom: 6px; font-size: var(--np-font-size-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--dashboard-tint); }
.npui-auth-quote div { min-height: 70px; font-size: 14.5px; line-height: 1.6; color: rgba(255,255,255,.85); transition: opacity .4s; }
.npui-auth-quote div.is-hidden { opacity: 0; }
.npui-auth-foot { font-size: var(--np-font-size-xs); color: rgba(255,255,255,.55); }
.npui-auth-pane { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--np-surface-2); }
.npui-auth-card { width: 100%; max-width: 400px; }
.npui-auth-card h1 { margin: 0 0 28px; font-size: 28px; font-weight: 700; color: var(--np-strong); }
.npui-auth-card .np-field { margin-bottom: 18px; }
.npui-auth-card .form-control { min-height: 44px; }
.npui-auth-greeting { margin-bottom: 4px; color: var(--np-muted); }
.npui-auth-lead { margin: -18px 0 24px; color: var(--np-muted); line-height: 1.5; }
.npui-auth-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 24px; }
.npui-auth-row .form-check { margin: 0; }
.npui-auth-back { display: inline-flex; align-items: center; gap: 6px; margin-top: 18px; font-weight: 500; }
.npui-auth-mobile-logo { display: none; margin-bottom: 28px; }
.npui-auth-mobile-logo img { height: 40px; width: auto; }
@media (max-width: 991.98px) {
  .npui-auth { grid-template-columns: 1fr; }
  .npui-auth-hero { display: none; }
  .npui-auth-mobile-logo { display: block; }
  .npui-auth-pane { align-items: flex-start; padding-top: 56px; }
}

/* ==========================================================================
   Error pages (403, 404, 419, 429, 500, 503 …)
   ========================================================================== */
.npui-error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.npui-error { position: relative; overflow: hidden; width: 100%; max-width: 440px; padding: 36px 32px; text-align: center; background: var(--np-surface); border: 1px solid var(--np-border); border-radius: var(--np-radius-lg); }
.npui-error::before { right: 0; bottom: auto; width: auto; height: 4px; background: linear-gradient(90deg, var(--dashboard) 0 12.5%, var(--invoicing) 0 25%, var(--hrm) 0 37.5%, var(--crm) 0 50%, var(--sales) 0 62.5%, var(--projects) 0 75%, var(--hours) 0 87.5%, var(--settings) 0); }
.npui-error-code { margin: 0 0 12px; font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -.03em; color: var(--np-strong); }
.npui-error h1 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.npui-error p { margin: 0 0 24px; color: var(--np-muted); line-height: 1.5; }
