/* ============================================================
   NexaGrid — Navigation Layouts
   Sidebar left (default) / Horizontal top
   Single nav config → rendered by navigation.js
   ============================================================ */

/* ================= 1. Header brand (horizontal mode only) ================= */
.header-brand {
  display: none;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
  margin-right: 4px;
}

.header-brand .sidebar-logo {
  width: 48px;
  height: 48px;
}

.header-brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

html[data-nav-layout="horizontal"] .header-brand {
  display: flex;
}

/* ================= 2. Horizontal nav bar ================= */
.app-horizontal-nav {
  display: none;
  height: 48px;
  width: 100%;
  align-items: center;
  gap: 2px;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  background: var(--canvas);
  position: relative;
  z-index: 90;
  overflow: visible;
  flex-shrink: 0;
}

.app-horizontal-nav::-webkit-scrollbar { height: 0; }

html[data-nav-layout="horizontal"] .app-horizontal-nav {
  display: flex;
}

/* Header avatar host (only visible in horizontal mode) */
.hdr-profile-host {
  display: none;
}

.hdr-profile-host .sb-profile {
  width: auto;
}

html[data-nav-layout="horizontal"] .hdr-profile-host {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

html[data-nav-layout="horizontal"] .hdr-profile-host .sb-avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

/* --- Top-level trigger button --- */
.h-nav-trigger {
  height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.h-nav-trigger:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.h-nav-trigger.active {
  color: var(--accent);
  background: var(--accent-bg);
}

.h-nav-trigger[aria-expanded="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.h-nav-trigger svg {
  width: 16px;
  height: 16px;
  color: var(--muted-2);
  flex-shrink: 0;
}

.h-nav-trigger:hover svg,
.h-nav-trigger.active svg,
.h-nav-trigger[aria-expanded="true"] svg {
  color: var(--accent);
}

.h-nav-chev {
  width: 13px !important;
  height: 13px !important;
  color: var(--muted-2) !important;
  transition: transform 0.15s ease;
  margin-left: 2px;
}

.h-nav-trigger[aria-expanded="true"] .h-nav-chev {
  transform: rotate(90deg);
}

/* --- Top-level plain link --- */
.h-nav-link {
  height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.h-nav-link:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.h-nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
}

/* --- Horizontal top-level item (anchors the dropdown) --- */
.h-nav-item {
  position: relative;
  flex-shrink: 0;
}

/* --- Horizontal dropdown panel --- */
.h-nav-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 999999;
  min-width: 212px;
  max-width: 252px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 7px;
  box-shadow: 0 18px 40px -16px rgb(15 23 42 / 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px) scale(0.98);
  transition: opacity 0.14s, transform 0.14s, visibility 0s linear 0.14s;
  visibility: hidden;
}

.app-horizontal-nav .h-nav-item.open > .h-nav-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  visibility: visible;
  transition-delay: 0s;
}

/* ================= 3. Nested submenu system ================= */
.menu-branch {
  position: relative;
}

/* --- Trigger button (extends sb-drop-item) --- */
button.sb-drop-item,
button.menu-trigger {
  background: transparent;
  border: none;
  font: inherit;
  cursor: pointer;
  width: 100%;
}

.menu-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.14s, color 0.14s;
  width: 100%;
}

.menu-trigger:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.menu-trigger.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.menu-trigger svg {
  width: 15px;
  height: 15px;
  color: var(--muted-2);
  flex-shrink: 0;
}

.menu-trigger.active svg {
  color: var(--accent);
}

.menu-chev {
  width: 13px;
  height: 13px;
  margin-left: auto;
  color: var(--muted-2);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.menu-trigger[aria-expanded="true"] .menu-chev {
  transform: rotate(90deg);
}

/* --- Submenu panel (opens RIGHT by default) --- */
.menu-sub {
  position: absolute;
  top: 0;
  left: 100%;
  z-index: 999999;
  min-width: 200px;
  max-width: 252px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 7px;
  box-shadow: 0 18px 40px -16px rgb(15 23 42 / 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-4px);
  transition: opacity 0.14s, transform 0.14s;
}

.menu-sub.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.menu-sub.dir-left {
  left: auto;
  right: 100%;
}

/* Small dot icon for items without custom icon */
.mi-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
}

/* ================= 4. Quick Actions menu (header) ================= */
.qa-drop {
  width: 320px;
}

.qa-sub {
  margin: 0;
  padding: 2px 14px 8px;
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.4;
}

.qa-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px 7px 9px;
}

.qa-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.qa-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.qa-item-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.qa-item-copy b {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
}

.qa-item:hover .qa-item-copy b {
  color: var(--accent);
}

.qa-item-copy span {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-2);
  line-height: 1.2;
  white-space: nowrap;
}

.qa-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface-inset);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.14s, color 0.14s;
}

.qa-item:hover .qa-item-icon {
  background: var(--accent-bg);
  color: var(--accent);
}

.qa-item-icon svg {
  width: 15px;
  height: 15px;
}

.qa-item-label {
  line-height: 1.2;
}

/* ================= 5. Horizontal mode overrides ================= */
html[data-nav-layout="horizontal"] #app-sidebar {
  display: none;
}

html[data-nav-layout="horizontal"] #app-sidebar.open {
  display: block;
}

html[data-nav-layout="horizontal"] .sidebar-overlay {
  display: none;
}

html[data-nav-layout="horizontal"] #app-header {
  border-bottom: 1px solid var(--border);
}

/* ================= 6. Mobile overrides ================= */
@media (max-width: 1024px) {
  html[data-nav-layout="horizontal"] .app-horizontal-nav {
    display: none !important;
  }

  html[data-nav-layout="horizontal"] .header-brand {
    display: none;
  }

  html[data-nav-layout="horizontal"] .hdr-profile-host {
    display: none;
  }

  html[data-nav-layout="horizontal"] #app-sidebar {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), width 180ms ease;
    box-shadow: none;
  }

  html[data-nav-layout="horizontal"] #app-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 100vmax rgb(3 7 18 / 0.45);
    width: var(--sidebar-width-expanded);
  }
}

@media (max-width: 560px) {
  html[data-nav-layout="horizontal"] #sidebar-toggle {
    display: flex;
  }
}