/* The top bar, shared by the app and the Django admin. Self-contained: its own colour
   variables (the admin defines --accent and others differently) and px/em sizes (the
   admin's root font size differs from the app's). Logical properties for RTL. */
.topbar {
  --tb-bg: #ffffff;
  --tb-text: #1c2430;
  --tb-muted: #5d6b7e;
  --tb-line: #dde2e9;
  --tb-accent: #1f5fbf;
  --tb-teal: #0a8f95;
  --tb-mark-filter: none;
  display: flex; align-items: center; gap: 1.5em; flex-wrap: wrap;
  padding: .6em 1.25em;
  background: var(--tb-bg); color: var(--tb-text);
  border-block-end: 1px solid var(--tb-line);
  font-family: "Segoe UI", "Arial Hebrew", Arial, "Noto Sans Hebrew", system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
  box-sizing: border-box;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .topbar { --tb-bg: #1b2129; --tb-text: #e6eaf0; --tb-muted: #9aa6b6; --tb-line: #2d3540; --tb-accent: #5b9bf0; --tb-teal: #14b4ba; --tb-mark-filter: brightness(1.7) saturate(1.1); }
}
/* The theme switch (static/js/theme.js, html[data-theme]) wins over the system setting. */
html[data-theme="light"] .topbar { --tb-bg: #ffffff; --tb-text: #1c2430; --tb-muted: #5d6b7e; --tb-line: #dde2e9; --tb-accent: #1f5fbf; --tb-teal: #0a8f95; --tb-mark-filter: none; }
html[data-theme="dark"] .topbar { --tb-bg: #1b2129; --tb-text: #e6eaf0; --tb-muted: #9aa6b6; --tb-line: #2d3540; --tb-accent: #5b9bf0; --tb-teal: #14b4ba; --tb-mark-filter: brightness(1.7) saturate(1.1); }

.topbar a, .topbar a:link, .topbar a:visited, .topbar a:hover { text-decoration: none; }
.topbar .brand { display: inline-flex; align-items: center; gap: .45em; font-size: 1.15em; color: var(--tb-text); }
.topbar .brand img { display: block; filter: var(--tb-mark-filter); }
.topbar .wordmark { font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
.topbar .wordmark b { font-weight: 800; }
.topbar .wordmark span { color: var(--tb-teal); }
/* The main menu: one link per section; hovering or tabbing into it opens its dropdown (core/menu.py). */
.topbar .mainnav { display: flex; gap: 1.4em; flex-wrap: wrap; }
.topbar .navgroup { position: relative; }
.topbar .navtop { display: inline-block; color: var(--tb-muted); padding: .25em 0; border-block-end: 2px solid transparent; }
.topbar .navtop:hover, .topbar .navgroup:hover .navtop { color: var(--tb-text); }
.topbar .navtop[aria-current="page"] { color: var(--tb-text); border-block-end-color: var(--tb-accent); }
.topbar .dropdown {
  display: none; position: absolute; z-index: 50; inset-block-start: 100%; inset-inline-start: -.75em;
  min-width: 15em; padding: .35em 0; background: var(--tb-bg); border: 1px solid var(--tb-line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.topbar .navgroup:hover > .dropdown, .topbar .navgroup:focus-within > .dropdown { display: block; }
.topbar .dropdown a { display: block; padding: .4em .9em; color: var(--tb-text); white-space: nowrap; }
.topbar .dropdown a:hover { background: color-mix(in srgb, var(--tb-accent) 10%, transparent); }
.topbar .dropdown a[aria-current="page"] { color: var(--tb-accent); font-weight: 600; }
.topbar .navtoggle-button { display: none; }

.topbar .topbar-end { margin-inline-start: auto; display: flex; align-items: center; gap: .9em; }
.topbar .topbar-end form { margin: 0; }
.topbar .who { color: var(--tb-muted); }

/* The user menu: setup, scheduler, admin, theme, language and sign out. */
.topbar .usermenu { position: relative; }
.topbar .usermenu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .3em; }
.topbar .usermenu summary::-webkit-details-marker { display: none; }
.topbar .usermenu summary svg { width: 14px; height: 14px; color: var(--tb-muted); }
.topbar .usermenu summary:hover .who, .topbar .usermenu summary[aria-current="page"] .who { color: var(--tb-text); }
.topbar .usermenu[open] > .dropdown { display: block; inset-inline-start: auto; inset-inline-end: 0; min-width: 12em; }
.topbar .usermenu .menu-row { display: block; padding: .4em .9em; border-block-start: 1px solid var(--tb-line); }

/* Narrow screens: the menu becomes a list behind the menu button, each section with its pages. */
@media (max-width: 760px) {
  .topbar { gap: .75em 1em; }
  .topbar .navtoggle-button { display: inline-grid; place-items: center; order: -1; width: 32px; height: 32px; color: var(--tb-text); cursor: pointer; border: 1px solid var(--tb-line); border-radius: 8px; }
  .topbar .navtoggle-button svg { width: 20px; height: 20px; }
  .topbar .mainnav { display: none; order: 10; flex-basis: 100%; flex-direction: column; gap: .5em; padding-block: .5em; }
  .topbar .navtoggle:checked ~ .mainnav { display: flex; }
  .topbar .navgroup > .dropdown, .topbar .navgroup:hover > .dropdown, .topbar .navgroup:focus-within > .dropdown {
    display: flex; flex-wrap: wrap; gap: .1em 1em; position: static; min-width: 0; padding: 0 0 .25em; border: 0; box-shadow: none; background: none;
  }
  .topbar .navgroup .dropdown a { padding: .2em 0; color: var(--tb-muted); }
  .topbar .navtop { font-weight: 600; color: var(--tb-text); }
}
.topbar button.link { font: inherit; background: none; border: 0; padding: 0; margin: 0; color: var(--tb-accent); cursor: pointer; }
.topbar button.link:hover { text-decoration: underline; }

/* Theme switch: automatic / light / dark. Hidden until theme.js shows it (it needs JavaScript). */
.topbar .theme-switch { display: inline-flex; border: 1px solid var(--tb-line); border-radius: 999px; padding: 2px; gap: 2px; }
.topbar .theme-switch[hidden] { display: none; }
.topbar .theme-switch button {
  display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; margin: 0;
  border: 0; border-radius: 999px; background: none; color: var(--tb-muted); cursor: pointer;
}
.topbar .theme-switch button:hover { color: var(--tb-text); }
.topbar .theme-switch button[aria-pressed="true"] { background: var(--tb-accent); color: var(--tb-bg); }
.topbar .theme-switch button:focus-visible { outline: 2px solid var(--tb-accent); outline-offset: 1px; }
.topbar .theme-switch svg { display: block; width: 16px; height: 16px; }

/* Help: "?" opens the User Guide at the part about this page; "Help" opens its contents. */
.topbar .help-links { display: inline-flex; align-items: center; gap: .45em; }
.topbar .help-links a { color: var(--tb-muted); }
.topbar .help-links a:hover, .topbar .help-links a[aria-current="page"] { color: var(--tb-text); }
.topbar .help-q {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 999px;
  border: 1px solid var(--tb-line); font-weight: 700; font-size: .85em; line-height: 1;
}
.topbar .help-q:hover { border-color: var(--tb-accent); color: var(--tb-accent) !important; }
.topbar .help-q:focus-visible { outline: 2px solid var(--tb-accent); outline-offset: 1px; }
