/*
 * OHE Admin Dashboard v2 — Shell CSS
 *
 * Topbar + sidebar + main content scaffold. Ported from atelier-os mock.
 * Loaded after tokens.css (vars + fonts) and before style.css.
 *
 * Class names are namespaced (`tb-`, `app-`, `nav-`) so they don't collide
 * with the legacy style.css selectors. Phase 1 (DASHBOARD-005b) will fold
 * component styles into one file.
 */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body.app-shell {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--type-ui);
  font-weight: 400;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11", "tnum";
  overflow: hidden;
}
body.app-shell a { color: inherit; text-decoration: none; }

/* ============ TOPBAR ============ */
.tb {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.tb-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}
.tb-crest {
  height: 32px;
  width: auto;
  display: block;
  border-radius: 3px;
}
.tb-sub {
  font-size: 9.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--tertiary);
  font-weight: 700;
  padding-left: 12px;
  border-left: 1px solid var(--divider-soft);
}

.tb-search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--secondary);
  cursor: pointer;
  user-select: none;
  text-align: left;
}
.tb-search:hover { border-color: var(--tertiary); background: var(--surface); }
.tb-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tb-search .ico { font-size: 11px; opacity: .6; }
.tb-search .kbd {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--tertiary);
  background: var(--surface);
  border: 1px solid var(--divider);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.tb-pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--secondary);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.tb-pulse::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 0 3px rgba(31, 122, 58, .18);
  animation: tb-pulse 2.4s infinite;
}
.tb-pulse.degraded::before { background: var(--warning); box-shadow: 0 0 0 3px rgba(180, 83, 9, .18); }
.tb-pulse.down::before { background: var(--negative); box-shadow: 0 0 0 3px rgba(192, 57, 43, .18); }
@keyframes tb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

.tb-pe {
  text-align: right;
  font-size: 10.5px;
  color: var(--secondary);
  line-height: 1.25;
}
.tb-pe strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}
.tb-logout {
  font-size: 10.5px;
  color: var(--tertiary);
  font-weight: 500;
  margin-left: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.tb-logout:hover { color: var(--ink); border-color: var(--divider-soft); background: var(--surface-2); }

/* ============ APP SHELL ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100vh - var(--topbar-h));
}

/* ============ SIDEBAR ============ */
.app-aside {
  background: var(--surface);
  border-right: 1px solid var(--divider);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-section {
  font-size: 9.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--tertiary);
  font-weight: 700;
  padding: 14px 10px 4px;
}
.nav-section:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 10px;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--ink); color: var(--surface); }
.nav-item .ico {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  opacity: .7;
}
.nav-item.active .ico { opacity: 1; }
.nav-item .badge {
  margin-left: auto;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 8px;
}
.nav-item.active .badge {
  background: rgba(255, 255, 255, .15);
  color: var(--surface);
}
.nav-item.disabled {
  color: var(--tertiary);
  cursor: not-allowed;
  opacity: .55;
}
.nav-item.disabled:hover { background: transparent; color: var(--tertiary); }

.app-aside-foot {
  margin-top: auto;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--divider-soft);
  font-size: 10px;
  color: var(--secondary);
}
.app-aside-foot .verse {
  font-family: var(--type-display);
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  font-size: 11px;
  text-align: center;
  padding: 6px 4px;
  line-height: 1.35;
}
.app-aside-foot .verse .cite {
  display: block;
  font-style: normal;
  font-size: 9.5px;
  color: var(--tertiary);
  letter-spacing: .04em;
  margin-top: 3px;
}
.app-aside-foot .est { text-align: center; font-size: 9.5px; color: var(--tertiary); }

/* ============ MAIN CONTENT ============ */
.app-main {
  background: var(--bg);
  position: relative;
  overflow-y: auto;
}
.app-main.no-scroll {
  overflow: hidden;
}
.app-main > .view {
  padding: 18px 24px 18px;
}

/* Flash / toast container */
#flash-container {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0 24px;
}
#toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

/* Scrollbar */
.app-aside::-webkit-scrollbar,
.app-main::-webkit-scrollbar { width: 8px; height: 8px; }
.app-aside::-webkit-scrollbar-track,
.app-main::-webkit-scrollbar-track { background: transparent; }
.app-aside::-webkit-scrollbar-thumb,
.app-main::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 4px; }
.app-aside::-webkit-scrollbar-thumb:hover,
.app-main::-webkit-scrollbar-thumb:hover { background: var(--tertiary); }
