/* ═══════════════════════════════════════════════════════════════════════════
   DriveNexus Office — Feature layer: sidebar, palette, charts, toasts, empty
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar search (opens command palette) ─────────────────────────────── */
.sidebar-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 0 12px 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm, 8px);
  background: var(--sidebar-hover, rgba(148, 163, 184, 0.08));
  border: 1px solid var(--sidebar-line, rgba(148, 163, 184, 0.2));
  color: var(--sidebar-ink-3, #94a3b8);
  font-size: 12px;
  font-family: var(--sans, inherit);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.sidebar-search-btn:hover {
  background: var(--sidebar-hover, rgba(13, 148, 136, 0.12));
  border-color: rgba(13, 148, 136, 0.35);
  color: var(--sidebar-ink-2, #cbd5e1);
}
.sidebar-search-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.85;
  flex-shrink: 0;
}
.sidebar-search-label {
  flex: 1;
  min-width: 0;
}
.sidebar-search-kbd {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--sidebar-line, rgba(148, 163, 184, 0.25));
  background: rgba(0, 0, 0, 0.15);
  color: var(--sidebar-ink-3, #94a3b8);
  line-height: 1.2;
}
.layout.sidebar-collapsed .sidebar-search-btn {
  width: calc(100% - 16px);
  margin: 0 8px 8px;
  padding: 10px 8px;
  justify-content: center;
}
.layout.sidebar-collapsed .sidebar-search-label,
.layout.sidebar-collapsed .sidebar-search-kbd {
  display: none;
}

/* ── Recent pages (bottom of nav — does not shift primary links) ─────────── */
.nav-recents {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: auto;
  margin-bottom: 4px;
  padding-top: 4px;
  /* Reserve a stable band once populated so list tweaks don’t shove footers */
  min-height: 0;
  flex-shrink: 0;
}
.nav-recents.nav-recents-ready {
  /* label (~28px) + up to 5 nav rows (~38px) */
  min-height: calc(28px + 5 * 38px);
}
.nav-recents[hidden] {
  display: none !important;
  min-height: 0 !important;
}
.nav-link-recent {
  opacity: 0.88;
  font-size: 12px;
}
.nav-link-recent.is-here {
  opacity: 0.55;
  pointer-events: none;
}
.layout.sidebar-collapsed .nav-recents {
  display: none !important;
}

/* ── Collapsible sidebar ─────────────────────────────────────────────────── */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--sidebar-line);
  color: var(--sidebar-ink);
  font-size: 11px;
  font-family: var(--sans);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-collapse-btn:hover {
  background: var(--sidebar-hover);
  border-color: rgba(13, 148, 136, 0.3);
  color: var(--sidebar-ink-2);
}
.sidebar-collapse-btn .collapse-label { transition: opacity 0.2s; }

.layout.sidebar-collapsed {
  grid-template-columns: 68px 1fr;
}
.layout.sidebar-collapsed .cc-preview-ribbon { left: 68px; }
.layout.sidebar-collapsed .main::before { left: 68px; }

.layout.sidebar-collapsed .brand {
  justify-content: center;
  padding-left: 12px;
  padding-right: 12px;
}
.layout.sidebar-collapsed .brand-text,
.layout.sidebar-collapsed .nav-section-label,
.layout.sidebar-collapsed .nav-subgroup-label,
.layout.sidebar-collapsed .nav-group-toggle,
.layout.sidebar-collapsed .sidebar-user-meta,
.layout.sidebar-collapsed .pill,
.layout.sidebar-collapsed .sidebar-signout,
.layout.sidebar-collapsed .theme-toggle .theme-label,
.layout.sidebar-collapsed .sidebar-collapse-btn .collapse-label {
  display: none;
}
.layout.sidebar-collapsed .sidebar-collapse-btn {
  padding: 8px;
}
.layout.sidebar-collapsed .nav {
  padding-left: 8px;
  padding-right: 8px;
}
.layout.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 10px 8px;
  font-size: 0;
  gap: 0;
}
.layout.sidebar-collapsed .nav-link .nav-dot {
  width: 8px;
  height: 8px;
  margin: 0;
}
.layout.sidebar-collapsed .nav-link.active::after { display: none; }
.layout.sidebar-collapsed .nav-link[title] { position: relative; }
.layout.sidebar-collapsed .nav-group.collapsed .nav-group-items,
.layout.sidebar-collapsed .nav-group-items {
  display: flex !important;
  padding-left: 0;
}

.layout.sidebar-collapsed .sidebar-foot {
  padding-left: 10px;
  padding-right: 10px;
}
.layout.sidebar-collapsed .sidebar-user-row {
  justify-content: center;
}
.layout.sidebar-collapsed .theme-toggle {
  justify-content: center;
  padding: 8px;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .layout .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 88vw);
    z-index: 1200;
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    box-shadow: none;
    /* app.css's older (max-width: 900px) rule (predating this drawer)
       also flips .sidebar itself to a row layout -- undoing that here
       is what actually lets .nav's own column fix below take effect,
       since a row-direction parent was the real reason .nav's width
       collapsed to 0 despite .nav being column internally. */
    flex-direction: column;
    flex-wrap: nowrap;
  }
  .layout.nav-drawer-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }
  .layout .sidebar-collapse-btn { display: none; }
  .layout .cc-preview-ribbon { left: 0; }
  /* app.css's older (max-width: 900px) rule still forces .nav into a
     horizontal row -- leftover from before this off-canvas drawer existed,
     when the sidebar collapsed into a row across the top of the page
     instead. Left unchecked, every nav link collapses into a 0-width
     column (a flex item in row-wrap with no explicit width and overflow
     auto shrinks to 0 instead of its content size) and the whole drawer
     renders blank. Restore the vertical list this drawer actually needs;
     .layout .nav beats app.css's bare .nav on specificity regardless of
     stylesheet load order. */
  .layout .nav {
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
    padding: 8px 0 16px;
  }
  .layout .nav-link { padding: 10px 16px; font-size: 13px; }
  .nav-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: rgba(15, 23, 42, 0.45);
  }
  .layout.nav-drawer-open .nav-drawer-backdrop { display: block; }
  .mobile-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    margin-right: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
  }
}
@media (min-width: 901px) {
  .mobile-nav-btn { display: none !important; }
  .nav-drawer-backdrop { display: none !important; }
}

/* Confirm dialog — must sit above Edit/office modals (z-index 15000–20000) */
.dn-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 50000;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dn-confirm-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.dn-confirm-box h3 {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--ink);
}
.dn-confirm-box p {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.5;
}
.dn-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.dn-confirm-actions .btn { min-height: 44px; min-width: 88px; }

/* Touch targets */
.btn, .btn-sm, .nav-link, .nav-group-toggle {
  min-height: 44px;
}
.table .btn, td .btn {
  min-height: 44px;
  padding: 10px 14px;
  font-size: 12px;
}
.tl-cell {
  min-height: 28px;
  min-width: 28px;
  font-size: 9px;
}

.skip-to-content {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 2000;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}
.skip-to-content:focus {
  left: 12px;
}

/* Command palette trigger hint */
.cmd-kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cmd-kbd-hint:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}
.cmd-kbd-hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ── Command palette ─────────────────────────────────────────────────────── */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
  animation: cmdFadeIn 0.18s var(--ease-out);
}
[data-theme="light"] .cmd-palette-backdrop {
  background: rgba(15, 23, 42, 0.35);
}
.cmd-palette-backdrop.cmd-closing {
  animation: cmdFadeOut 0.15s ease forwards;
}
@keyframes cmdFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes cmdFadeOut {
  to { opacity: 0; }
}

.cmd-palette {
  width: min(100%, 560px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cmdSlide 0.22s var(--ease-out);
}
@keyframes cmdSlide {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cmd-palette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.cmd-palette-search-icon {
  color: var(--ink-3);
  font-size: 16px;
  flex-shrink: 0;
}
.cmd-palette-input {
  flex: 1;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  font-size: 15px !important;
  font-weight: 500;
  color: var(--ink) !important;
}
.cmd-palette-input:focus { outline: none; }
.cmd-palette-esc {
  font-size: 10px;
  color: var(--ink-3);
  padding: 3px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.cmd-palette-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}
.cmd-palette-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 8px 10px 4px;
}
.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.cmd-palette-item:hover,
.cmd-palette-item.active {
  background: var(--accent-light);
}
.cmd-palette-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.cmd-palette-item.active .cmd-palette-item-icon {
  background: var(--accent-light);
  border-color: var(--accent);
}
.cmd-palette-item-text { flex: 1; min-width: 0; }
.cmd-palette-item-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-palette-item-sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 1px;
}
.cmd-palette-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* ── Chart containers ────────────────────────────────────────────────────── */
.echarts-wrap,
[id^="chart-"] {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-sm) !important;
}
html:not([data-theme='dark']) .echarts-wrap.chart-active {
  background: var(--panel) !important;
}

/* ── Toast stack ─────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 40px));
}
.toast-stack .toast {
  position: relative;
  bottom: auto;
  right: auto;
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.28s var(--ease-out), transform 0.28s var(--ease-out);
}
.toast-stack .toast.show {
  opacity: 1;
  transform: translateX(0);
}
.toast-stack .toast.toast--leave {
  opacity: 0;
  transform: translateX(24px);
}
.toast-icon { font-size: 16px; line-height: 1.2; flex-shrink: 0; }
.toast-msg { flex: 1; }
.toast--success { border-left: 3px solid var(--green); }
.toast--warning { border-left: 3px solid var(--amber); }
.toast--error { border-left: 3px solid var(--red); }
.toast--info { border-left: 3px solid var(--accent); }

/* Legacy single toast hide */
body > .toast:not(.toast-stack .toast) { display: none; }

/* ── Branded empty states ────────────────────────────────────────────────── */
.cc-empty-state {
  text-align: center;
  padding: 40px 24px;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  background: var(--panel-2);
}
.cc-empty-state-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: var(--accent-light);
  border: 1px solid rgba(13, 148, 136, 0.2);
}
.cc-empty-state-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.cc-empty-state-sub {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.45;
  max-width: 280px;
  margin: 0 auto;
}
.empty-state {
  padding: 40px 24px !important;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  background: var(--panel-2);
}
.empty-state .icon {
  width: 52px !important;
  height: 52px;
  margin: 0 auto 14px !important;
  border-radius: 14px !important;
  display: grid !important;
  place-items: center;
  font-size: 24px !important;
  background: var(--accent-light);
  border: 1px solid rgba(13, 148, 136, 0.2);
}
.empty {
  padding: 40px 20px;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  background: var(--panel-2);
}
.empty .big {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

/* ── Phase B: hub pages + in-page subnav ─────────────────────────────────── */
.nav-hub-sub {
  font-size: 13px;
  color: var(--ink-2);
  margin: 0 0 18px;
  max-width: 560px;
  line-height: 1.5;
}
.nav-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.nav-hub-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  min-height: 112px;
}
.nav-hub-card:hover {
  border-color: rgba(13, 148, 136, 0.45);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}
.nav-hub-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.nav-hub-card-desc {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.45;
  flex: 1;
}
.nav-hub-card-go {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.2px;
  margin-top: 4px;
}

/* Fixed slot so hub subnav appearing/disappearing doesn’t shove page content */
.hub-subnav-slot {
  min-height: 46px;
  margin: 0 0 8px;
  box-sizing: border-box;
}
.hub-subnav-slot:empty {
  border-bottom: 1px solid transparent;
}

/* Sticky sibling strip under the topbar when inside a hub page */
.hub-subnav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 0 10px;
  margin: 0;
  border-bottom: 1px solid var(--line-soft, var(--line));
  min-height: 46px;
  box-sizing: border-box;
}
.pin-page-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
}
.pin-page-btn .pin-page-icon {
  font-size: 14px;
  line-height: 1;
  color: var(--ink-3);
}
.pin-page-btn.is-pinned .pin-page-icon {
  color: #f59e0b;
}
.nav-pins {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 2px;
  flex-shrink: 0;
}
.nav-pins[hidden] {
  display: none !important;
}
.nav-link-pin {
  font-size: 12px;
}
.layout.sidebar-collapsed .nav-pins,
.layout.sidebar-collapsed .pin-page-label {
  display: none !important;
}
.nav-hub-ext {
  font-size: 11px;
  opacity: 0.7;
  font-weight: 600;
}
.hub-subnav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: 4px;
  flex-shrink: 0;
}
.hub-subnav-all {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.hub-subnav-all:hover {
  background: rgba(13, 148, 136, 0.08);
  border-color: rgba(13, 148, 136, 0.25);
}
.hub-subnav-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.hub-subnav-link:hover {
  border-color: rgba(13, 148, 136, 0.4);
  color: var(--ink);
}
.hub-subnav-link.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(13, 148, 136, 0.08);
}

@media (max-width: 640px) {
  .hub-subnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
  }
  .nav-hub-grid {
    grid-template-columns: 1fr;
  }
}