/* Shared platform top navigation — desktop dropdowns + mobile slide-in drawer */
:root {
  --platform-nav-height: 48px;
  --pnd-width: 280px;
}

/* ── Nav bar ─────────────────────────────────────────────────────────────── */
#platformNav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  height: var(--platform-nav-height);
  display: none;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  background: rgba(11, 17, 32, 0.97);
  border-bottom: 1px solid #253044;
  backdrop-filter: blur(8px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* overflow MUST be visible so dropdowns aren't clipped */
  overflow: visible;
}

html.auth-ok #platformNav,
html.auth-local #platformNav {
  display: flex;
}

html.auth-ok body.has-platform-nav,
html.auth-local body.has-platform-nav {
  padding-top: var(--platform-nav-height);
}

/* ── Logo ────────────────────────────────────────────────────────────────── */
.platform-nav-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 16px;
  text-decoration: none;
}

.platform-nav-logo img {
  height: 28px;
  width: auto;
  display: block;
}

/* ── Tabs container — overflow VISIBLE so dropdowns show ─────────────────── */
.platform-nav-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  /* No overflow-x:auto — grouped menus fit; dropdowns must not be clipped */
  overflow: visible;
}

/* ── Standalone tab ──────────────────────────────────────────────────────── */
.platform-nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.platform-nav-tab .tab-icon {
  font-size: 15px;
  line-height: 1;
}

.platform-nav-tab:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.05);
}

.platform-nav-tab.active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  font-weight: 600;
}

/* ── User area ───────────────────────────────────────────────────────────── */
.platform-nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
  font-size: 13px;
  color: #94a3b8;
}

.platform-nav-user img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #253044;
  object-fit: cover;
}

.platform-nav-user-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#platformNavSignOut {
  background: none;
  border: 1px solid #253044;
  color: #94a3b8;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}

#platformNavSignOut:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* ── Hamburger button (mobile only) ─────────────────────────────────────── */
.platform-nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  border: 1px solid #2a3a54;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  padding: 0;
  transition: border-color 0.15s, background 0.15s;
}

.platform-nav-hamburger:hover {
  border-color: #4a6a94;
  background: rgba(255, 255, 255, 0.05);
}

.platform-nav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: #94a3b8;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s, background 0.15s;
}

.platform-nav-hamburger.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
  background: #f59e0b;
}
.platform-nav-hamburger.open span:nth-child(2) {
  opacity: 0;
}
.platform-nav-hamburger.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
  background: #f59e0b;
}

/* ── Desktop: dropdown group button ─────────────────────────────────────── */
.platform-nav-group {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  /* allow child dropdown to overflow */
  overflow: visible;
}

.platform-nav-group-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.platform-nav-group-btn:hover,
.platform-nav-group.open > .platform-nav-group-btn {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.05);
}

.platform-nav-group-btn.active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  font-weight: 600;
}

.group-chevron {
  font-size: 11px;
  opacity: 0.55;
  margin-left: 1px;
  display: inline-block;
  transition: transform 0.18s ease;
  line-height: 1;
}

.platform-nav-group.open > .platform-nav-group-btn > .group-chevron {
  transform: rotate(90deg);
  opacity: 0.85;
}

/* ── Desktop: dropdown panel ─────────────────────────────────────────────── */
.platform-nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 172px;
  background: rgba(10, 16, 30, 0.98);
  border: 1px solid #2a3a54;
  border-radius: 10px;
  padding: 5px;
  z-index: 9200;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  flex-direction: column;
  gap: 1px;
  animation: navDropIn 0.13s ease;
}

@keyframes navDropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.platform-nav-group.open > .platform-nav-dropdown {
  display: flex;
}

.platform-nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}

.platform-nav-dropdown-item:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.06);
}

.platform-nav-dropdown-item.active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  font-weight: 600;
}

.platform-nav-dropdown-item .tab-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE SLIDE-IN DRAWER
   ═══════════════════════════════════════════════════════════════════════════ */

/* Drawer wrapper — covers viewport when open */
#platformNavDrawer {
  position: fixed;
  inset: 0;
  z-index: 9400;
  display: none;
  pointer-events: none;
}

#platformNavDrawer.open {
  display: block;
  pointer-events: auto;
}

/* Dim overlay */
.pnd-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

#platformNavDrawer.open .pnd-overlay {
  opacity: 1;
}

/* Slide-in panel */
.pnd-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--pnd-width);
  max-width: 88vw;
  height: 100dvh;
  background: #0b1120;
  border-left: 1px solid #253044;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -12px 0 48px rgba(0, 0, 0, 0.5);
}

#platformNavDrawer.open .pnd-panel {
  transform: translateX(0);
}

/* Panel header */
.pnd-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #1e2d44;
  flex-shrink: 0;
}

.pnd-header-logo {
  height: 24px;
  width: auto;
}

.pnd-header-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  letter-spacing: 0.01em;
}

.pnd-close {
  background: none;
  border: 1px solid #253044;
  color: #94a3b8;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
  font-family: inherit;
}

.pnd-close:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Scrollable nav area */
.pnd-nav {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Standalone link in drawer */
.pnd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
}

.pnd-item:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.06);
}

.pnd-item.active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  font-weight: 600;
}

.pnd-item-icon {
  font-size: 16px;
  line-height: 1;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* Group section in drawer */
.pnd-section {
  display: flex;
  flex-direction: column;
}

.pnd-section-divider {
  height: 1px;
  background: #1e2d44;
  margin: 6px 4px;
}

/* Group header button */
.pnd-section-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: color 0.12s, background 0.12s;
}

.pnd-section-btn:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.05);
}

.pnd-section-btn.active {
  color: #f59e0b;
}

.pnd-section-icon {
  font-size: 16px;
  line-height: 1;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.pnd-section-label {
  flex: 1;
}

.pnd-section-chevron {
  font-size: 12px;
  opacity: 0.5;
  transition: transform 0.2s ease;
  line-height: 1;
}

.pnd-section-btn.open .pnd-section-chevron {
  transform: rotate(90deg);
  opacity: 0.8;
}

/* Sub-items container */
.pnd-sub-items {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 4px 16px;
}

.pnd-sub-items.open {
  display: flex;
}

/* Sub-item link */
.pnd-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
}

.pnd-sub-item:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.05);
}

.pnd-sub-item.active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  font-weight: 600;
}

.pnd-sub-icon {
  font-size: 14px;
  line-height: 1;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.75;
}

/* Drawer sign-out */
.pnd-signout-wrap {
  padding: 12px 8px 8px;
  border-top: 1px solid #1e2d44;
  flex-shrink: 0;
}

.pnd-signout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px;
  border-radius: 9px;
  border: 1px solid #253044;
  background: none;
  color: #94a3b8;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.pnd-signout:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* ── Responsive breakpoints ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Hide desktop tabs, show hamburger */
  .platform-nav-tabs {
    display: none;
  }

  .platform-nav-hamburger {
    display: flex;
  }

  /* Keep sign-out button hidden on mobile (it's in the drawer) */
  #platformNavSignOut {
    display: none;
  }
}

@media (min-width: 769px) {
  /* Always hide drawer on desktop */
  #platformNavDrawer {
    display: none !important;
  }

  .platform-nav-hamburger {
    display: none !important;
  }
}

/* Small desktop: hide tab labels */
@media (max-width: 900px) and (min-width: 769px) {
  .platform-nav-tab span.tab-label,
  .platform-nav-group-btn .tab-label {
    display: none;
  }

  .platform-nav-user-name {
    display: none;
  }

  .platform-nav-tab {
    padding: 6px 8px;
  }

  .platform-nav-group-btn {
    padding: 6px 8px;
  }
}
