/* shell.css — the app frame shared by the dashboard and settings:
   layout, top navigation and the main area. */

/* ── App Layout ── */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  position: relative;
  white-space: nowrap;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.75; }
.nav-item:hover { background: var(--tint-hover); color: var(--text); }
.nav-item:active { background: var(--tint-active); }
.nav-item:focus { outline: none; }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); font-weight: 600; }
.nav-item.active svg { opacity: 1; }

/* ── Top navigation ──
   Desktop: top bar with dropdown panels. Mobile (<1024px): the same list is a
   bottom bar and the panels open as sheets above it. Colors use the theme
   tokens so every theme styles the navigation. */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--glass-border);
  padding-top: var(--safe-top);
}
.topnav-inner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: 52px;
  padding: 0 var(--space-md);
}
.topnav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  min-height: 44px;
}
.topnav-brand .logo-mark { flex: none; color: var(--accent); }
.topnav-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.topnav-list { list-style: none; margin: 0; padding: 0; }
.topnav-entry, .topnav-group { position: relative; }
.topnav-dest {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.topnav-dest.nav-item { width: auto; overflow: visible; }
.topnav-dest svg { width: 18px; height: 18px; flex-shrink: 0; }
.topnav-dest:hover { background: var(--tint-hover); color: var(--text); }
.topnav-dest:focus-visible, .topnav-icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topnav-dest.active, .topnav-dest[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
}
.topnav-caret { width: 14px !important; height: 14px !important; opacity: 0.7; transition: transform 0.15s ease-out; }
.topnav-toggle[aria-expanded="true"] .topnav-caret { transform: rotate(180deg); }
.topnav-dest .nav-badge { margin-left: 2px; }
.topnav-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topnav-countdown { font-size: var(--fs-min); color: var(--muted); font-variant-numeric: tabular-nums; }
.topnav-icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}
.topnav-icon-button:hover, .topnav-icon-button[aria-expanded="true"] { background: var(--tint-hover); color: var(--text); }
.topnav-icon-button.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.topnav-icon-button svg { width: 20px; height: 20px; }
/* Where room is short, the mark stands in for the name (still read out). */
@media (max-width: 479px), (min-width: 1024px) and (max-width: 1279px) {
  .topnav-brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
/* Small phones: every action keeps its touch size. */
@media (max-width: 479px) {
  .topnav-inner { gap: var(--space-sm); }
  .topnav-countdown { display: none; }
  .topnav-actions { gap: 2px; }
}
.topnav-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.topnav-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 120;
  min-width: 260px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.topnav-panel-end { left: auto; right: 0; }
.topnav-panel-title { display: none; }
.topnav-panel .nav-item { min-height: 40px; }
.topnav-panel-divider { height: 1px; margin: 6px 4px; background: var(--glass-border); }
.topnav-panel .dark-toggle { padding: 0 14px; margin: 0; }
.topnav-panel form { margin: 0; }
.topnav-version {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 40px;
  padding: 6px 14px;
  font-size: var(--fs-min);
  color: var(--muted);
  text-decoration: none;
}
.topnav-version:hover { color: var(--text); }
.update-badge {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-muted);
  color: var(--text);
  font-weight: 600;
}
/* Opens the command palette: a search field look on wide screens, an icon elsewhere. */
.topnav-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}
.topnav-search svg { width: 20px; height: 20px; flex-shrink: 0; }
.topnav-search:hover { background: var(--tint-hover); color: var(--text); }
.topnav-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topnav-search-label, .topnav-search-key { display: none; }
@media (min-width: 1280px) {
  .topnav-search {
    width: auto;
    height: 36px;
    padding: 0 6px 0 10px;
    border: 1px solid var(--input-border);
    font-size: 0.88rem;
  }
  .topnav-search svg { width: 16px; height: 16px; }
  .topnav-search-label { display: inline; min-width: 64px; text-align: left; }
  .topnav-search-key { display: inline-flex; }
}
.topnav-search-key, .command-palette-key {
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--input-border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text-secondary);
  font: 600 0.72rem/1 var(--font-sans);
}
.command-palette-key { display: inline-flex; }

/* ── Command palette ── */
.command-palette {
  position: fixed;
  inset: 12vh 0 auto;
  display: none;
  flex-direction: column;
  width: min(640px, calc(100vw - 32px));
  max-height: min(76vh, 600px);
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border, var(--input-border));
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.command-palette[open] { display: flex; }
.command-palette::backdrop { background: var(--overlay); }
.command-palette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
  color: var(--muted);
}
.command-palette-search svg { width: 18px; height: 18px; flex-shrink: 0; }
.command-palette-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
.command-palette-input::placeholder { color: var(--muted); }
/* The palette's only field: the caret and the selected result show where the keyboard is. */
.command-palette-input:focus { outline: none; }
.command-palette-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 8px; }
.command-palette-group + .command-palette-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--glass-border); }
.command-palette-group-title {
  margin: 0;
  padding: 10px 10px 4px;
  font-size: var(--fs-min);
  font-weight: 600;
  color: var(--muted);
}
.command-palette-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.command-palette-option svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-secondary); }
.command-palette-option[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.command-palette-option mark { background: none; color: inherit; font-weight: 700; }
.command-palette-option-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-palette-option-detail { color: var(--muted); }
.command-palette-option-detail::before { content: " · "; }
.command-palette-option-keys { display: inline-flex; gap: 3px; }
.command-palette-empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--muted); }
.command-palette-help { overflow-y: auto; padding: 4px 16px 16px; }
.command-palette-help .command-palette-group-title { padding-left: 0; }
.command-palette-shortcuts { display: grid; gap: 6px; margin: 4px 0 0; }
.command-palette-shortcuts > div { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 12px; }
.command-palette-shortcuts dt { display: inline-flex; gap: 4px; }
.command-palette-shortcuts dd { margin: 0; }
.command-palette-help-note { margin: 12px 0 0; font-size: var(--fs-min); color: var(--muted); }
.command-palette-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  padding: 8px 12px 8px 16px;
  border-top: 1px solid var(--glass-border);
  font-size: var(--fs-min);
  color: var(--muted);
}
.command-palette-foot > span { display: inline-flex; align-items: center; gap: 4px; }
.command-palette-help-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  margin-left: auto;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}
.command-palette-help-toggle:hover, .command-palette-help-toggle[aria-expanded="true"] { background: var(--tint-hover); color: var(--text); }
.command-palette-help-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 639px) {
  .command-palette { inset: 8px 0 auto; width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .command-palette-foot { display: none; }
}

/* Below the sticky header (z-index 100), which contains the open sheet */
.topnav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: var(--overlay, rgba(0, 0, 0, 0.5));
}
body.nav-sheet-open { overflow: hidden; }

@media (max-width: 1023px) {
  .topnav-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 110;
    background: var(--card);
    border-top: 1px solid var(--glass-border);
    padding-bottom: var(--safe-bottom);
  }
  .topnav-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    height: var(--bottom-nav-h);
  }
  .topnav-entry, .topnav-group { position: static; }
  .topnav-dest {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 100%;
    height: 100%;
    padding: 4px 2px;
    border-radius: 0;
    font-size: var(--fs-min);
  }
  .topnav-dest.nav-item { width: 100%; }
  .topnav-dest svg { width: 22px; height: 22px; }
  .topnav-dest.active, .topnav-dest[aria-expanded="true"] { background: none; color: var(--accent); }
  .topnav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .topnav-caret { display: none; }
  .topnav-dest { position: relative; }
  .topnav-dest .nav-badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; }
  .topnav-panel, .topnav-panel-end {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 8px);
    min-width: 0;
    max-height: min(70vh, 560px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .topnav-panel-title {
    display: block;
    padding: 8px 14px 4px;
    font-size: var(--fs-min);
    font-weight: 600;
    color: var(--muted);
  }
  .topnav-panel .nav-item { min-height: 48px; white-space: normal; line-height: 1.35; }
  .app-layout .app-main { padding-bottom: calc(var(--space-lg) + var(--bottom-nav-h) + var(--safe-bottom)); }
}
@media (min-width: 1024px) {
  .topnav-inner { min-height: 60px; padding: 0 var(--space-xl); gap: var(--space-lg); }
  .topnav-nav { flex: 1; display: flex; justify-content: center; }
  .topnav-list { display: flex; align-items: center; gap: 4px; }
  .topnav-countdown, .topnav-refresh { display: none; }
}
/* Narrow desktops: long labels (French, Romanian) need the room the wide layout spends on
   spacing and on the menu carets; the toggles still announce their menus. */
@media (min-width: 1024px) and (max-width: 1279px) {
  .topnav-inner { padding: 0 var(--space-lg); gap: var(--space-md); }
  .topnav-dest { padding: 8px 10px; }
  .topnav-caret { display: none; }
}

.nav-badge {
  margin-left: auto;
  background: var(--crit-strong);
  color: #fff;
  font-size: var(--fs-min);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
}

/* Dark mode toggle */
.dark-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-sm);
  min-height: 44px;
}
.dark-toggle-label {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.dark-toggle-label svg { width: 14px; height: 14px; }


/* ── Main Content (mobile-first) ── */
.app-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-md);
  padding-bottom: calc(var(--space-md) + var(--safe-bottom));
  max-width: 1200px;
  width: 100%;
}
@media (min-width: 640px) {
  .app-main { padding: var(--space-lg); padding-bottom: calc(var(--space-lg) + var(--safe-bottom)); }
}
@media (min-width: 1024px) {
  .app-main {
    margin: 0 auto;
    padding: var(--space-xl);
    padding-bottom: var(--space-xl);
  }
}

/* ── Notice center: bell with unread count and its panel ── */
.topnav-notices .topnav-toggle { position: relative; }
.topnav-notices .nav-badge {
  position: absolute;
  top: 3px;
  right: 1px;
  margin: 0;
  padding: 1px 5px;
  min-width: 16px;
  line-height: 1.2;
}
.notice-center { width: min(380px, calc(100vw - 2 * var(--space-md))); padding: 0; }
.notice-center-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 10px 12px 8px 16px;
  border-bottom: 1px solid var(--glass-border);
}
.notice-center-title { color: var(--text); font-size: 0.95rem; font-weight: 600; }
.notice-center-list { margin: 0; padding: 0; list-style: none; max-height: min(60vh, 480px); overflow: auto; }
.notice-center-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 8px 12px 16px;
  border-bottom: 1px solid var(--glass-border);
}
.notice-center-item:not(.read) { background: var(--tint-hover); }
.notice-center-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.notice-center-item.notice-warning .notice-center-dot { background: var(--warn); }
.notice-center-item.notice-critical .notice-center-dot { background: var(--crit); }
.notice-center-item.read .notice-center-dot { background: transparent; }
.notice-center-copy { flex: 1; min-width: 0; }
.notice-center-copy strong { display: block; color: var(--text); font-size: 0.88rem; font-weight: 600; }
.notice-center-item.read .notice-center-copy strong { color: var(--text-secondary); font-weight: 500; }
.notice-center-copy p { margin: 2px 0 4px; color: var(--text-secondary); font-size: 0.82rem; line-height: 1.45; }
.notice-center-copy a { color: var(--accent); font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.notice-center-copy a:hover { text-decoration: underline; }
.notice-center-empty { padding: 16px; color: var(--muted); font-size: 0.85rem; }
.notice-center-foot { margin: 0; padding: 10px 16px; color: var(--muted); font-size: var(--fs-min); }
