/* ── Nisto Navigation: Rail + Submenu + Top bar + Command Palette ───────── */

/* ── Layout shell ──────────────────────────────────────────────────────── */
.nav-shell {
  display: flex;
  position: fixed;
  left: 0; top: 0;
  height: 100vh;
  z-index: 30;
}

/* ── Rail ──────────────────────────────────────────────────────────────── */
.nav-rail2 {
  width: 190px;
  background: #FBFBFA;
  border-right: 1px solid #EEEEEB;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 40;
  transition: width 0.2s ease;
  overflow: hidden;
}
.nav-rail2.collapsed {
  width: 62px;
}

/* Rail header (logo + workspace) */
.nav-rail2-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 14px 16px;
  min-height: 64px;
}
.nav-rail2.collapsed .nav-rail2-header {
  justify-content: center;
  padding: 20px 0 16px;
}
.nav-rail2.collapsed .nav-rail2-brandtext {
  display: none;
}

/* Rail items */
.nav-rail2-items {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-rail2-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: #54555A;
  cursor: pointer;
  position: relative;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-rail2-item:hover {
  background: #F2F2EF;
}
.nav-rail2-item.active {
  background: #EFEFEC;
  color: #0E0E10;
  font-weight: 600;
}
.nav-rail2-item i,
.nav-rail2-item svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}
.nav-rail2.collapsed .nav-rail2-item {
  justify-content: center;
  padding: 9px;
}
.nav-rail2.collapsed .nav-rail2-item-label {
  display: none;
}

/* Hub chevron indicator */
.nav-rail2-item-chevron {
  margin-left: auto;
  opacity: 0.4;
  width: 14px;
  height: 14px;
}
.nav-rail2.collapsed .nav-rail2-item-chevron {
  display: none;
}

/* Badge on rail items */
.nav-rail2-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.nav-rail2-badge.amber { background: #E0915A; }
.nav-rail2-badge.red { background: #C7443B; }
.nav-rail2.collapsed .nav-rail2-badge { display: none; }

/* Badge dot (collapsed) */
.nav-rail2-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: none;
}
.nav-rail2-dot.amber { background: #E0915A; }
.nav-rail2-dot.red { background: #C7443B; }
.nav-rail2.collapsed .nav-rail2-dot { display: block; }

/* Config item (anchored bottom) */
.nav-rail2-bottom {
  border-top: 1px solid #F0F0EE;
  padding: 8px;
}

/* Tooltip (collapsed rail) */
.nav-rail2-tooltip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0E0E10;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.15s;
}
.nav-rail2.collapsed .nav-rail2-item:hover .nav-rail2-tooltip {
  opacity: 1;
}
.nav-rail2:not(.collapsed) .nav-rail2-tooltip { display: none; }

/* ── Submenu ───────────────────────────────────────────────────────────── */
.nav-sub2 {
  width: 252px;
  background: #fff;
  border-right: 1px solid #EEEEEB;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.15s ease, opacity 0.15s;
}
.nav-sub2.nav-sub2-hidden {
  width: 0;
  overflow: hidden;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}
.nav-sub2-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 12px;
}
.nav-sub2-header-title {
  font-size: 15px;
  font-weight: 600;
  color: #0E0E10;
  flex: 1;
}
.nav-sub2-header-icon {
  width: 19px;
  height: 19px;
  color: #54555A;
}
.nav-sub2-collapse {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: none;
  color: #A6A7AC;
  cursor: pointer;
}
.nav-sub2-collapse:hover { background: #F2F2EF; color: #54555A; }

/* Category headers */
.nav-sub2-category {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #A6A7AC;
  padding: 16px 16px 6px;
}

/* Sub-items */
.nav-sub2-items { padding: 0 8px; }
.nav-sub2-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: #54555A;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-sub2-item:hover { background: #F2F2EF; }
.nav-sub2-item.active {
  background: #EFEFEC;
  color: #0E0E10;
  font-weight: 600;
}
.nav-sub2-item i,
.nav-sub2-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}
.nav-sub2-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-sub2-badge.amber { background: #E0915A; }
.nav-sub2-badge.red { background: #C7443B; }

/* ── Top bar ───────────────────────────────────────────────────────────── */
.nav-topbar2 {
  flex-shrink: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid #F0F0EE;
  min-height: 52px;
}
.nav-topbar2-toggles {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-topbar2-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: none;
  color: #76777C;
  cursor: pointer;
}
.nav-topbar2-btn:hover { background: #F2F2EF; color: #0E0E10; }
.nav-topbar2-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #76777C;
  flex: 1;
  min-width: 0;
}
.nav-topbar2-breadcrumb-active {
  color: #0E0E10;
  font-weight: 600;
}
.nav-topbar2-breadcrumb-sep {
  color: #CDCDCA;
  font-size: 11px;
}
.nav-topbar2-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.nav-topbar2-kbd {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #E8E8E6;
  font-size: 11px;
  color: #A6A7AC;
  cursor: pointer;
  background: #fff;
}
.nav-topbar2-kbd:hover { border-color: #CDCDCA; color: #54555A; }
.nav-topbar2-lang {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #E8E8E6;
  font-size: 11px;
  font-weight: 600;
  color: #54555A;
  cursor: pointer;
  background: #fff;
  text-transform: uppercase;
}
.nav-topbar2-lang:hover { border-color: #CDCDCA; }
.nav-topbar2-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--accent, #0E0E10);
  border: none;
  padding: 0;
  cursor: pointer;
  flex: none;
}
.nav-topbar2-avatar:hover { opacity: 0.88; }
.nav-user-menu {
  position: fixed;
  z-index: 90;
  background: #fff;
  border: 1px solid #E8E8E6;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
  min-width: 220px;
  max-width: 280px;
  padding: 6px;
}
.nav-user-menu-head {
  padding: 10px 11px 8px;
  min-width: 0;
}
.nav-user-menu-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #0E0E10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-user-menu-email {
  font-size: 12px;
  color: #76777C;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.nav-user-menu-sep {
  height: 1px;
  background: #F0F0EE;
  margin: 4px;
}
.nav-user-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #0E0E10;
  cursor: pointer;
  text-align: left;
}
.nav-user-menu-item:hover { background: #F7F7F6; }
.nav-user-menu-item i,
.nav-user-menu-item svg { width: 15px; height: 15px; flex: none; }

/* ── Command Palette ───────────────────────────────────────────────────── */
.nav-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}
.nav-palette {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
}
.nav-palette-input {
  width: 100%;
  padding: 16px 20px;
  border: none;
  outline: none;
  font-size: 15px;
  color: #0E0E10;
  background: transparent;
  border-bottom: 1px solid #F0F0EE;
}
.nav-palette-input::placeholder { color: #A6A7AC; }
.nav-palette-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
}
.nav-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.nav-palette-item:hover { background: #F2F2EF; }
.nav-palette-item i,
.nav-palette-item svg {
  width: 17px;
  height: 17px;
  color: #54555A;
  flex-shrink: 0;
}
.nav-palette-item-label {
  font-size: 13.5px;
  font-weight: 500;
  color: #0E0E10;
  flex: 1;
}
.nav-palette-item-area {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #A6A7AC;
  text-transform: uppercase;
}
.nav-palette-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: #A6A7AC;
}

/* ── Main content offset ───────────────────────────────────────────────── */
#nisto-main {
  transition: margin-left 0.2s ease;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.nav-topbar2 + *:not(.nav-user-menu),
#nisto-main > div[x-show]:not(.nav-user-menu),
#nisto-main > div[x-cloak]:not(.nav-user-menu) {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
#nisto-main .h-screen {
  height: 100% !important;
}
#nisto-main [style*="100vh"] {
  height: 100% !important;
}

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-shell { display: none; }
  .nav-topbar2 { display: none; }
  #nisto-main { margin-left: 0 !important; }

  /* Mobile bottom nav */
  .nav-mobile-bar {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    z-index: 50;
    background: #fff;
    border-top: 1px solid #EEEEEB;
    display: flex;
    align-items: stretch;
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .nav-mobile-bar.hidden { display: none; }
  .nav-mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: #A6A7AC;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    padding: 0;
  }
  .nav-mobile-tab.active { color: #0E0E10; font-weight: 600; }
  .nav-mobile-tab svg { width: 22px; height: 22px; }
  .nav-mobile-tab-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 16px);
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: #C7443B;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Mobile menu sheet */
  .nav-mobile-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 60;
  }
  .nav-mobile-sheet {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    z-index: 61;
    background: #fff;
    border-radius: 20px 20px 0 0;
    max-height: 80vh;
    overflow-y: auto;
    padding: 12px 16px 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0));
  }
  .nav-mobile-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #E8E8E6;
    margin: 0 auto 16px;
  }
  .nav-mobile-sheet-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #E8E8E6;
    border-radius: 12px;
    font-size: 14px;
    color: #0E0E10;
    background: #F7F7F6;
    outline: none;
    margin-bottom: 12px;
  }
  .nav-mobile-sheet-search::placeholder { color: #A6A7AC; }
  .nav-mobile-sheet-section {
    margin-bottom: 4px;
  }
  .nav-mobile-sheet-hub {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 8px;
    font-size: 14px;
    font-weight: 600;
    color: #0E0E10;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    border-radius: 10px;
  }
  .nav-mobile-sheet-hub:hover { background: #F2F2EF; }
  .nav-mobile-sheet-hub i,
  .nav-mobile-sheet-hub svg { width: 19px; height: 19px; color: #54555A; }
  .nav-mobile-sheet-hub-chevron { margin-left: auto; width: 16px; height: 16px; color: #A6A7AC; transition: transform 0.2s; }
  .nav-mobile-sheet-hub-chevron.open { transform: rotate(90deg); }
  .nav-mobile-sheet-leaf {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px 10px 38px;
    font-size: 13.5px;
    font-weight: 500;
    color: #54555A;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    border-radius: 8px;
  }
  .nav-mobile-sheet-leaf:hover { background: #F2F2EF; }
  .nav-mobile-sheet-leaf.active { background: #EFEFEC; color: #0E0E10; font-weight: 600; }
  .nav-mobile-sheet-leaf i,
  .nav-mobile-sheet-leaf svg { width: 17px; height: 17px; }
  .nav-mobile-sheet-user {
    border-top: 1px solid #F0F0EE;
    margin-top: 8px;
    padding-top: 8px;
  }
  .nav-mobile-sheet-user-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 10px;
    min-width: 0;
  }
  .nav-mobile-sheet-user-head .nav-topbar2-avatar {
    width: 36px;
    height: 36px;
    font-size: 12px;
    cursor: default;
  }
  .nav-mobile-sheet-user-head .nav-topbar2-avatar:hover { opacity: 1; }
}

/* Desktop: hide mobile nav */
@media (min-width: 769px) {
  .nav-mobile-bar { display: none !important; }
  .nav-mobile-sheet-overlay { display: none !important; }
  .nav-mobile-sheet { display: none !important; }
}
