/* Thin top bar, account menu and staff sidebar. Loaded after christeyns.css. */

.topbar.topbar-slim {
  --topbar-brand-height: 3rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 0.35rem 1rem;
}

.topbar-slim .topbar-left { gap: 0.6rem; }
.topbar-slim .topbar-center { justify-self: start; }

.topbar-slim .topbar-right {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
}

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}
.topbar-icon-btn:hover { background: rgba(255, 255, 255, 0.22); }
.topbar-icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar-slim .sidebar-open-btn,
.topbar-slim .nav-toggle { display: none; margin: 0; font-size: inherit; }

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search .nav-icon {
  position: absolute;
  left: 0.65rem;
  color: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}
.topbar-search input[type="search"] {
  width: 15rem;
  padding: 0.45rem 0.8rem 0.45rem 2.1rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
}
.topbar-search input[type="search"]::placeholder { color: rgba(255, 255, 255, 0.72); }
.topbar-search input[type="search"]:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.22);
}

.topbar-slim .topbar-nav { flex-wrap: nowrap; }

/* Account menu */
.account-menu { position: relative; }

.account-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.55rem 0.2rem 0.2rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.account-menu-btn:hover { background: rgba(255, 255, 255, 0.2); }
.account-menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.account-menu-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.account-menu-caret { font-size: 0.7rem; opacity: 0.85; }

.account-menu-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 250;
  min-width: 16rem;
  padding: 0.4rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
}
.account-menu.is-open .account-menu-panel { display: block; }
html[data-theme="dark"] .account-menu-panel { background: var(--surface); }

.account-menu-who {
  display: flex;
  flex-direction: column;
  margin: 0 0 0.3rem;
  padding: 0.5rem 0.65rem 0.6rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.3;
}
.account-menu-who strong { color: var(--heading); font-size: 0.92rem; overflow-wrap: anywhere; }
.account-menu-who span { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }

.account-menu-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}
.account-menu-link:hover { background: var(--hover-bg); color: var(--heading); }
.account-menu-logout { color: var(--danger); }
.account-menu-logout:hover { color: var(--danger); }

.account-menu-theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.account-menu-panel .theme-toggle {
  margin: 0;
  border-color: color-mix(in srgb, var(--primary) 16%, var(--border));
  background: var(--surface);
}
html[data-theme="dark"] .account-menu-panel .theme-toggle { background: var(--surface-muted); }
.account-menu-panel .theme-toggle button { color: var(--text); }
.account-menu-panel .theme-toggle button:hover { color: var(--heading); background: var(--hover-bg); }
.account-menu-panel .theme-toggle button.is-active { background: var(--primary); color: #fff; }

/* Staff sidebar */
.app-shell {
  --sidebar-w: 14.5rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}
html[data-sidebar="collapsed"] .app-shell { --sidebar-w: 4.25rem; }

.app-shell > main.container {
  width: 100%;
  min-width: 0;
}

.app-sidebar {
  position: sticky;
  top: var(--topbar-h, 3.6rem);
  height: calc(100vh - var(--topbar-h, 3.6rem));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 0.6rem 0.7rem;
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--primary) 76%, #ffffff 24%) 0%,
    color-mix(in srgb, var(--primary) 92%, #001018 8%) 100%
  );
  color: #fff;
  border-right: 0;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
  z-index: 50;
}

main.container.is-switching { opacity: 0.72; }

.app-sidebar-search { display: none; }

.app-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1 1 auto;
}

.app-sidebar-group {
  margin: 0.95rem 0 0.28rem;
  padding: 0 0.7rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
}
.app-sidebar-group:first-child { margin-top: 0; }

.app-sidebar-link,
.app-sidebar-collapse {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 2.4rem;
  padding: 0.45rem 0.7rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.app-sidebar-link .nav-icon,
.app-sidebar-collapse .nav-icon {
  flex: none;
  color: rgba(255, 255, 255, 0.72);
}
.app-sidebar-link:hover,
.app-sidebar-collapse:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.app-sidebar-link:hover .nav-icon,
.app-sidebar-collapse:hover .nav-icon { color: #fff; }
.app-sidebar-link:focus-visible,
.app-sidebar-collapse:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.app-sidebar-link.is-active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-weight: 650;
  box-shadow: inset 3px 0 0 var(--accent);
}
.app-sidebar-link.is-active .nav-icon { color: var(--accent); }

.app-sidebar-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar .nav-badge {
  flex: none;
  min-width: 1.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #fbbf24;
  color: #78350f;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.app-sidebar-collapse {
  flex: none;
  margin-top: auto;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0;
}

html[data-sidebar="collapsed"] .app-sidebar { padding-left: 0.45rem; padding-right: 0.45rem; }
html[data-sidebar="collapsed"] .app-sidebar-label { display: none; }
html[data-sidebar="collapsed"] .app-sidebar-group {
  height: 1px;
  margin: 0.6rem 0.4rem;
  padding: 0;
  overflow: hidden;
  font-size: 0;
  background: rgba(255, 255, 255, 0.22);
}
html[data-sidebar="collapsed"] .app-sidebar-group:first-child { display: none; }
html[data-sidebar="collapsed"] .app-sidebar-link,
html[data-sidebar="collapsed"] .app-sidebar-collapse { justify-content: center; padding-left: 0; padding-right: 0; }
html[data-sidebar="collapsed"] .app-sidebar .nav-badge {
  position: absolute;
  top: 0.15rem;
  right: 0.2rem;
  min-width: 1.05rem;
  padding: 0 0.25rem;
  font-size: 0.62rem;
}
html[data-sidebar="collapsed"] .app-sidebar-collapse .nav-icon { transform: scaleX(-1); }

.app-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(0, 20, 40, 0.45);
}
.app-sidebar-backdrop[hidden] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .app-sidebar-link,
  .app-sidebar-collapse,
  .account-menu-btn,
  .topbar-icon-btn { transition: background var(--transition-fast), color var(--transition-fast); }
  .app-shell { transition: grid-template-columns var(--transition-mid); }
}

@media (max-width: 1024px) {
  .topbar-search input[type="search"] { width: 11rem; }
}

@media (max-width: 768px) {
  .topbar.topbar-slim {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    padding: 0.35rem 0.75rem;
  }
  .topbar-slim .topbar-left { grid-column: 1; grid-row: 1; }
  .topbar-slim .topbar-center { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .topbar-slim .topbar-right {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: row;
    width: auto;
    padding-top: 0;
    border-top: 0;
    justify-self: end;
  }
  .topbar-slim .topbar-home-label { display: none; }
  .topbar.topbar-slim { --topbar-brand-height: 2.4rem; }
  .topbar-slim .brand-logo-wrap--logo { max-width: 46vw; }
  .topbar-slim .brand-logo--logo { min-width: 0; }
  .topbar-slim .sidebar-open-btn,
  .topbar-slim .nav-toggle { display: inline-flex; }
  .topbar-search { display: none; }
  .account-menu-btn .role-badge { display: none; }

  .topbar-slim .topbar-nav[data-topbar-nav] {
    display: none;
    position: absolute;
    top: 100%;
    left: 0.5rem;
    right: 0.5rem;
    z-index: 240;
    flex-direction: column;
    align-items: stretch;
    padding: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
  }
  .topbar-slim .topbar-nav[data-topbar-nav].is-open { display: flex; }
  .topbar-slim .topbar-nav[data-topbar-nav] a { color: var(--text); padding: 0.6rem 0.75rem; }
  .topbar-slim .topbar-nav[data-topbar-nav] a:hover { background: var(--hover-bg); color: var(--heading); }
  .topbar-slim .topbar-nav[data-topbar-nav] a.nav-active {
    background: color-mix(in srgb, var(--accent) 13%, var(--surface));
    color: var(--heading);
  }

  .app-shell { display: block; }
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(17rem, 85vw);
    height: auto;
    z-index: 300;
    padding-top: 1rem;
    transform: translateX(-102%);
    box-shadow: var(--shadow-lift);
    visibility: hidden;
  }
  .app-sidebar.is-open { transform: none; visibility: visible; }
  .app-sidebar-search { display: block; }
  .app-sidebar-search input[type="search"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font: inherit;
  }
  .app-sidebar-search input[type="search"]::placeholder { color: rgba(255, 255, 255, 0.72); }
  .app-sidebar-search input[type="search"]:focus { outline: 2px solid var(--accent); border-color: var(--accent); background: rgba(255, 255, 255, 0.22); }
  .app-sidebar-collapse { display: none; }
  html[data-sidebar="collapsed"] .app-sidebar-label { display: inline; }
  html[data-sidebar="collapsed"] .app-sidebar-group {
    height: auto;
    margin: 0.85rem 0 0.3rem;
    padding: 0 0.7rem;
    font-size: 0.7rem;
    background: none;
  }
  html[data-sidebar="collapsed"] .app-sidebar-group:first-child { display: block; margin-top: 0; }
  html[data-sidebar="collapsed"] .app-sidebar-link { justify-content: flex-start; padding: 0.45rem 0.7rem; }
  html[data-sidebar="collapsed"] .app-sidebar .nav-badge { position: static; }
}

@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
  .app-sidebar { transition: transform var(--transition-mid), visibility var(--transition-mid); }
}

html[data-theme="dark"] .app-sidebar {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--primary) 74%, #000000 26%) 0%,
    color-mix(in srgb, var(--primary) 46%, #000000 54%) 100%
  );
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}
