/* BW PM Suite — shared app shell.
   Loaded by EVERY page (including Project Schedule and Cashflow, which do
   not use css/style.css), so the header, the password dialog and keyboard
   focus look identical everywhere. All rules are scoped to .app-header /
   .pw-* so they cannot collide with a page's own stylesheet.

   Brand Guideline (15.10.25): Open Sans; black & white as primary colours,
   purple #663399 as accent; primary logo = white logo on black. */

:root {
  --shell-bg: #000;
  --shell-surface: #171717;
  --shell-surface-alt: #262626;
  --shell-border: #262626;
  --shell-border-strong: #404040;
  --shell-text: #f5f5f5;
  --shell-muted: #a3a3a3;
  --shell-dim: #737373;
  --shell-primary: #663399;
  --shell-primary-dark: #52277a;
  --shell-primary-soft: rgba(102, 51, 153, 0.22);
  --shell-focus: #a77bd6;          /* lighter purple: readable ring on black */
  --shell-danger: #f87171;
  --shell-danger-soft: rgba(239, 68, 68, 0.16);
  --shell-radius: 8px;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  /* Three columns: logo (+ Project Overview) | nav, always centred | user.
     The left column starts at the same x on every page, so the Project
     Overview button never moves. */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 12px 32px;
  background: var(--shell-bg);
  border-bottom: 1px solid var(--shell-border);
  font-family: 'Open Sans', -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
/* Primary BeWunder logo (white), never recoloured or redrawn. The clear
   space (half the height of the logo's capital B) is kept by the gap before
   the divider; 24px height is well above the minimum size (Open Sans 8 pt). */
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--shell-text);
  text-decoration: none;
}
.app-header .brand-logo { display: block; height: 24px; width: auto; }
.app-header .brand-name {
  padding-left: 14px;
  border-left: 1px solid var(--shell-border-strong);
  font-weight: 600;
  font-size: 15px;
  line-height: 24px;
  white-space: nowrap;
}
.app-header > .brand { grid-column: 1; justify-self: start; }
/* On project pages the logo and the Project Overview button share the left
   column: logo in the corner, the button directly after it (the logo's clear
   space is the gap between them). The product name gives way to the button. */
.app-header.has-project { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); }
.app-header.has-project > .brand { grid-column: 1; }
.app-header.has-project .brand-name { display: none; }
.app-header.has-project .project-overview { grid-column: 2; }
.app-header.has-project nav { grid-column: 3; }
.app-header.has-project .user-menu { grid-column: 4; }
.app-header nav { grid-column: 2; display: flex; gap: 4px; }
.app-header .user-menu { grid-column: 3; justify-self: end; }

/* ---------- Project Overview (project sub-pages only) ----------
   Top-left corner of every module page (Areas, LED, Power, Logistics,
   Schedule, Cashflow, Deadlines): one filled brand-purple button, always in
   the same place, back to the project page. */
.app-header .project-overview {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.app-header .project-overview-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  height: 36px;
  padding: 0 16px 0 12px;
  border-radius: var(--shell-radius);
  border: 1px solid var(--shell-primary);
  background: var(--shell-primary);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: 0 0 0 3px var(--shell-primary-soft);
  transition: background-color 0.15s, border-color 0.15s;
}
.app-header .project-overview-btn:hover { background: var(--shell-primary-dark); border-color: var(--shell-primary-dark); }
.app-header .project-overview-btn svg { flex-shrink: 0; }
.app-header .project-overview-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--shell-muted);
}
.app-header nav a {
  padding: 8px 12px;
  border-radius: var(--shell-radius);
  color: var(--shell-muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.app-header nav a.active, .app-header nav a:hover { background: var(--shell-primary-soft); color: var(--shell-text); }
.app-header .user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--shell-muted);
}
.app-header .user-menu span { margin-right: 4px; }

/* The two header buttons, and every button in the password dialog, use the
   suite's one button style (same values as .btn / .btn-sm in style.css). */
.app-header .btn,
.pw-dialog .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--shell-radius);
  border: 1px solid var(--shell-border);
  background: transparent;
  color: var(--shell-muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.app-header .btn:hover,
.pw-dialog .btn:hover { background: var(--shell-surface-alt); color: var(--shell-text); border-color: var(--shell-border-strong); }
.app-header .btn-sm { padding: 6px 11px; font-size: 12px; }
.pw-dialog .btn-primary { background: var(--shell-primary); border-color: var(--shell-primary); color: #fff; }
.pw-dialog .btn-primary:hover { background: var(--shell-primary-dark); border-color: var(--shell-primary-dark); color: #fff; }
.pw-dialog .btn:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 720px) {
  .app-header { padding: 10px 16px; }
  .app-header .brand-name { display: none; }
  .app-header .project-overview-label { display: none; }
  .app-header .project-overview-btn span { display: none; }
  .app-header .project-overview-btn { padding: 0 10px; }
  .app-header nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; background: var(--shell-surface); border-top: 1px solid var(--shell-border); justify-content: space-around; padding: 6px 4px; }
  .app-header nav a { flex: 1; text-align: center; font-size: 11px; padding: 8px 4px; }
  .app-header .user-menu span { display: none; }
  body { padding-bottom: 56px; }
}

/* ---------- Password dialog (js/app.js openPasswordDialog) ---------- */
.pw-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  overscroll-behavior: contain;
}
.pw-dialog {
  width: 100%;
  max-width: 400px;
  background: var(--shell-surface);
  color: var(--shell-text);
  border: 1px solid var(--shell-border);
  border-radius: var(--shell-radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
  padding: 24px;
  font-family: 'Open Sans', -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
}
.pw-dialog h2 { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
.pw-dialog .pw-sub { margin: -8px 0 16px; font-size: 13px; color: var(--shell-muted); }
.pw-dialog .pw-field { margin-bottom: 14px; }
.pw-dialog label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--shell-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pw-dialog input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--shell-border);
  border-radius: var(--shell-radius);
  background: var(--shell-bg);
  color: var(--shell-text);
  font: inherit;
}
.pw-dialog input:focus { outline: none; border-color: var(--shell-primary); box-shadow: 0 0 0 3px var(--shell-primary-soft); }
.pw-dialog .pw-hint { margin: 4px 0 0; font-size: 12px; color: var(--shell-dim); }
.pw-dialog .pw-error-msg {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--shell-radius);
  background: var(--shell-danger-soft);
  color: #fca5a5;
  font-size: 13px;
}
.pw-dialog .pw-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Keyboard focus ----------
   Every interactive element shows a visible ring when reached with the
   keyboard, never on a mouse click. Components with their own
   :focus-visible style keep it (higher specificity than :where()). */
:where(a, button, [role="button"], [role="tab"], summary, input[type="checkbox"], input[type="radio"], [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--shell-focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
