/* App shell: fixed top bar + left sidebar, injected by app-shell.js into
   #app-shell. Shared by wizard (trin-for-trin) and single-page. Also holds the
   standalone login page styles. Theme tokens come from shared.css. */

/* ----- layout offsets ----- */
body.has-shell { padding-top: var(--topbar-h); padding-left: var(--sidebar-w); }

/* ----- top bar ----- */
.app-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  z-index: 50; display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: var(--panel);
  /* KM's exact orange as a mark rather than as text - the one place --brand is
     used at full strength, where contrast is not a reading concern. */
  border-bottom: 2px solid var(--brand); box-shadow: var(--shadow);
}
/* The brand is a link home - the first thing anyone clicks when they feel lost. */
.app-topbar .tb-brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  text-decoration: none; color: inherit; border-radius: 6px;
  padding: 4px 6px; margin-left: -6px;
}
.app-topbar .tb-brand:hover { background: var(--panel-2); text-decoration: none; }
.app-topbar .tb-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.app-topbar .tb-logo { height: 30px; width: auto; display: block; border-radius: 5px; }
.app-topbar .tb-title { font-weight: 700; letter-spacing: 0.3px; color: var(--ink); white-space: nowrap; }
.app-topbar .tb-title small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.app-topbar .tb-spacer { flex: 1 1 auto; }
.app-topbar .tb-right { display: flex; align-items: center; gap: 10px; }

/* topbar action buttons - uniform pills, equal gaps, flush right edge */
.tb-sync, .tb-theme, .tb-logout {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; padding: 6px 12px; white-space: nowrap;
}
/* Quiet by default. A solid red Log ud was the loudest thing on the screen while being
   the least important and least used action - it read as a warning, not a control. It
   turns red on approach instead, which is where the signal is actually useful. */
.tb-logout { background: transparent; color: var(--muted); border-color: var(--line-2); }
.tb-logout:hover { background: var(--err); color: #fff; border-color: var(--err); }

/* inlined Lucide icons inherit text colour via currentColor */
.lucide { width: 18px; height: 18px; flex: none; display: block; }
.tb-sync .lucide, .tb-theme .lucide, .tb-logout .lucide { width: 15px; height: 15px; }
.tb-sync.syncing .lucide { animation: spin .8s linear infinite; }
.app-sidebar .nav-ico .lucide { width: 17px; height: 17px; }

/* ----- left sidebar ----- */
.app-sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w);
  z-index: 40; overflow-y: auto; padding: 16px 12px;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.app-sidebar .nav-group { margin-bottom: 18px; }
/* Section headings in KM's orange - the readable variant, since 10.5px uppercase
   is small text and the brand orange itself only clears 3:1 on white. */
.app-sidebar .nav-group-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--accent); font-weight: 700; padding: 0 8px; margin-bottom: 6px;
}
.app-sidebar .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 6px; color: var(--ink-2);
  font-size: 13.5px; font-weight: 500; margin-bottom: 2px;
}
.app-sidebar .nav-link:hover { background: var(--panel-2); text-decoration: none; }
.app-sidebar .nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.app-sidebar .nav-link .nav-ico { display: inline-flex; align-items: center; width: 18px; flex: none; }
.app-sidebar .nav-hint { font-size: 11.5px; color: var(--muted); padding: 2px 10px; line-height: 1.5; }
/* One line under each view. The names alone do not say what the difference is. */
.app-sidebar .nav-desc {
  font-size: 11px; color: var(--muted); line-height: 1.45;
  padding: 0 10px 8px 38px; margin-top: -2px;
}

/* ----- pending edits: a change is a proposal until Godkend is pressed here ----- */
.pending-edits { padding: 10px 8px 6px; border: 1px solid var(--brand); border-radius: 6px; background: var(--accent-soft); }
.pending-row { padding: 4px 2px 8px; }
.pending-row + .pending-row { border-top: 1px solid var(--line); padding-top: 8px; }
.pending-text { font-size: 12px; color: var(--ink); line-height: 1.4; }
.pending-text .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pending-note { font-size: 10.5px; color: var(--muted); margin: 2px 0 6px; }
.pending-actions { display: flex; gap: 6px; }
.pending-actions button { font-size: 11.5px; padding: 4px 9px; }

/* Reference, not navigation: it floats in the middle of the free space rather than
   crowding the view switcher or hiding above the fold. auto on both sides centres it. */
.app-sidebar .nav-group-steps { margin-top: auto; margin-bottom: auto; padding: 12px 0; }
.app-sidebar .nav-steps { list-style: none; margin: 0; padding: 0 10px; }
.app-sidebar .nav-steps li {
  display: flex; flex-direction: column; gap: 1px;
  padding: 4px 0; line-height: 1.35;
}
.app-sidebar .nav-steps b { font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.app-sidebar .nav-steps span { font-size: 10.5px; color: var(--muted); }

/* ----- sidebar footer: the Monitor block + logged-in user -----
   Uplink, list freshness and the sync button live together: "is the connection up"
   and "is the list current" are different questions, and only the first was being
   answered. A green dot over a three-week-old list is a lie by omission. */
.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--line); }
.sidebar-foot .nav-group-title { margin-bottom: 5px; }
.sidebar-foot .tb-monitor {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-2); padding: 0 10px 4px;
}
.tb-fresh {
  font-size: 11px; color: var(--muted); padding: 0 10px 8px; line-height: 1.4;
}
/* Old enough to act on: the nudge is the colour, not a banner. */
.tb-fresh.stale { color: var(--warn); font-weight: 600; }
/* The one action in the sidebar, so it carries the brand edge. */
.sidebar-foot .tb-sync {
  display: flex; width: calc(100% - 20px); margin: 0 10px 6px;
  justify-content: center; gap: 7px; font-size: 12.5px; padding: 7px 10px;
  border: 2px solid var(--brand); font-weight: 600;
}
.sidebar-foot .tb-sync:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--brand); }
.sidebar-foot .tb-sync:disabled { opacity: .6; }
.tb-monitor .dot { width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 3px transparent; flex: none; }
.tb-monitor.up   .dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.tb-monitor.down .dot { background: var(--err); box-shadow: 0 0 0 3px var(--warn-soft); }
.tb-monitor.connecting .dot { background: var(--warn); animation: tb-pulse 1s ease-in-out infinite; }
@keyframes tb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.tb-sync-status { font-size: 11px; color: var(--muted); padding: 0 10px 8px; line-height: 1.4; }
.tb-sync-status:empty { display: none; }
/* A failed refresh must not read like a quiet "0 uændrede" - see app-shell.js. */
.tb-sync-status.sync-failed { color: var(--err); font-weight: 600; }
.sidebar-user {
  border-top: 1px solid var(--line); padding: 10px 10px 2px;
  font-size: 12.5px; color: var(--ink-2);
}
.sidebar-user b { color: var(--ink); font-weight: 700; }

/* ----- login page (standalone, no shell) ----- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 26px; text-align: center;
}
.login-card .login-logo { height: 56px; width: auto; margin: 0 auto 14px;
  display: block; border-radius: 8px; }
.login-card h1 { font-size: 18px; margin: 0 0 2px; }
.login-card .login-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 20px; }
.login-card label { display: block; text-align: left; font-size: 12px;
  color: var(--ink-2); margin: 0 0 4px; }
.login-card input[type="text"], .login-card input[type="password"] {
  width: 100%; font: inherit; padding: 9px 11px; margin-bottom: 14px;
  border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--panel); color: var(--ink);
}
.login-card input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft); }
.login-card button.primary { width: 100%; padding: 10px; font-weight: 600; }
.login-error {
  background: var(--warn-soft); color: var(--err); border: 1px solid var(--warn-line);
  border-radius: 6px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 14px;
  text-align: left;
}

/* ----- print: drop the chrome ----- */
@media print {
  .app-topbar, .app-sidebar { display: none !important; }
  body.has-shell { padding: 0 !important; }
}

/* ----- narrow screens: collapse the sidebar ----- */
@media (max-width: 720px) {
  body.has-shell { padding-left: 0; }
  .app-sidebar { transform: translateX(-100%); transition: transform .18s; }
  body.sidebar-open .app-sidebar { transform: none; box-shadow: var(--shadow); }
  .tb-title small, .tb-sync span, .tb-theme span, .tb-logout span { display: none; }
}
