/* ═══════════════════════════════════════════════════════════════
   Praylum — Sidebar Flyout Navigation System
   YouTube-style spacing, JS-driven hover flyouts
   ═══════════════════════════════════════════════════════════════ */

/* ── Main Rail ─────────────────────────────────────────────── */
/* Override prl-app.css overflow:hidden which clips flyout panels */
body.prl-in:not(.prl-no-sidebar) .prl-sidebar,
body.prl-in:not(.prl-no-sidebar) ~ * .prl-sidebar,
.prl-sidebar {
  width: 240px !important;
  overflow: visible !important;
  overflow-y: visible !important;
  overflow-x: visible !important;
  z-index: 200 !important;
  position: fixed !important;
  left: 0 !important;
  top: var(--nav-height, 64px) !important;
  bottom: 0 !important;
  background: #0A0E27 !important;
  border-right: 1px solid rgba(255,255,255,0.06) !important;
  padding: 16px 0 0 !important;
  display: flex !important;
  flex-direction: column !important;
  font-family: var(--font-sans, 'Inter', ui-sans-serif, system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  scrollbar-width: none !important;
}

.prl-sidebar::-webkit-scrollbar {
  display: none !important;
}

/* Override page-content padding from prl-app.css and header.php inline */
body.prl-in:not(.prl-no-sidebar) .page-content {
  padding-left: 240px !important;
}

/* ── Logo ──────────────────────────────────────────────────── */
.prl-sidebar-logo {
  padding: 0 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.prl-sidebar-logo a {
  font-family: var(--font-display, 'Inter', sans-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: white;
  text-decoration: none;
}

/* ── Nav Container ─────────────────────────────────────────── */
.prl-sidebar-nav {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  padding: 8px 0 !important;
  overflow-y: auto !important;
  overflow-x: visible !important;
  scrollbar-width: none;
}
.prl-sidebar-nav::-webkit-scrollbar { display: none; }

/* ── Section Labels ────────────────────────────────────────── */
.prl-sidebar-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.4);
  padding: 16px 24px 8px;
  font-weight: 600;
}

/* ── Sidebar Divider ───────────────────────────────────────── */
.prl-sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 12px 16px;
}

/* ── Sidebar Items ─────────────────────────────────────────── */
.prl-sidebar-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  margin: 2px 8px;
  border-radius: 10px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  position: relative;
  cursor: pointer;
  transition: all 150ms ease;
  user-select: none;
  white-space: nowrap;
}

.prl-sidebar-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.prl-sidebar-item.active {
  background: rgba(255,190,11,0.12);
  color: #FFBE0B;
}

.prl-sidebar-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: #FFBE0B;
  border-radius: 0 3px 3px 0;
}

.prl-sidebar-item.active .prl-icon svg {
  stroke: #FFBE0B;
}

/* ── Icons ─────────────────────────────────────────────────── */
.prl-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.prl-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Chevron ───────────────────────────────────────────────── */
.prl-chevron {
  margin-left: auto;
  width: 16px;
  height: 16px;
  opacity: 0.5;
  transition: transform 150ms ease, opacity 150ms ease;
  display: flex;
  align-items: center;
}

.prl-sidebar-item.has-flyout:hover .prl-chevron {
  transform: translateX(2px);
  opacity: 1;
}

/* ── Badge ─────────────────────────────────────────────────── */
.prl-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: #EF4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
  line-height: 1;
}
.prl-badge-amber {
  background: rgba(255,190,11,0.15);
  color: #FFBE0B;
  border: 1px solid rgba(255,190,11,0.3);
}
.prl-badge-ai {
  background: rgba(255,190,11,0.15);
  color: #FFBE0B;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
}

/* ── Flyout (JS-driven via .is-open class) ─────────────────── */
.prl-sidebar-item.has-flyout {
  position: relative;
}

.prl-flyout {
  position: fixed !important;
  left: 240px !important;
  min-width: 220px !important;
  background: #0D1530 !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 48px rgba(0,0,0,0.7) !important;
  padding: 8px !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateX(-8px) !important;
  transition: opacity 150ms ease,
              transform 150ms ease,
              visibility 0s linear 150ms !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  max-height: 80vh;
  overflow-y: auto;
}

/* JS adds .is-open on mouseenter, removes on mouseleave */
.prl-flyout.is-open {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateX(0) !important;
  pointer-events: auto !important;
  transition: opacity 150ms ease,
              transform 150ms ease !important;
}

/* ── Flyout Items ──────────────────────────────────────────── */
.prl-flyout-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 2px 0;
  border-radius: 8px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 120ms ease;
  white-space: nowrap;
}

.prl-flyout-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.prl-flyout-item.active {
  background: rgba(255,190,11,0.15);
  color: #FFBE0B;
}

.prl-flyout-item .prl-badge {
  margin-left: auto;
}

/* ── Flyout Divider ────────────────────────────────────────── */
.prl-flyout-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 4px;
}

/* ── Flyout Section Label ──────────────────────────────────── */
.prl-flyout-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
}

/* ── Footer ────────────────────────────────────────────────── */
.prl-sidebar-footer {
  padding: 16px 8px !important;
  border-top: 1px solid rgba(255,255,255,0.06) !important;
  flex-shrink: 0 !important;
}
.prl-sidebar-footer .prl-sidebar-item {
  margin: 1px 0;
}
.prl-sidebar-footer .prl-sidebar-item.danger {
  color: rgba(252,165,165,0.8);
}
.prl-sidebar-footer .prl-sidebar-item.danger:hover {
  background: rgba(239,68,68,0.08);
  color: #fca5a5;
}

/* ── CTA ───────────────────────────────────────────────────── */
.prl-sidebar-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 8px 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255,190,11,0.1) 0%, rgba(30,58,138,0.15) 100%);
  border: 1px solid rgba(255,190,11,0.2);
  text-decoration: none;
  transition: all .2s;
  color: white;
  font-size: 14px;
  font-weight: 700;
}
.prl-sidebar-cta:hover {
  background: linear-gradient(135deg, rgba(255,190,11,0.16) 0%, rgba(30,58,138,0.22) 100%);
  border-color: rgba(255,190,11,0.35);
  transform: translateY(-1px);
}
.prl-sidebar-cta .prl-icon {
  color: #FFBE0B;
}

/* ── Highlight (e.g. Autopilot) ────────────────────────────── */
.prl-flyout-item.highlighted {
  background: rgba(255,190,11,0.06);
  border: 1px solid rgba(255,190,11,0.15);
  font-weight: 700;
}
.prl-flyout-item.highlighted:hover {
  background: rgba(255,190,11,0.12);
}

/* ── Agency Coach Switcher ─────────────────────────────────── */
.prl-ag-switcher {
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: relative;
  flex-shrink: 0;
}
.prl-ag-switcher-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,190,11,0.06);
  border: 1px solid rgba(255,190,11,0.2);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s;
}
.prl-ag-switcher-btn:hover { background: rgba(255,190,11,0.12); }
.prl-ag-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,190,11,0.2);
  color: #FFBE0B;
  font-weight: 900;
  font-size: 13px;
}
.prl-ag-avatar img { width: 100%; height: 100%; object-fit: cover; }
.prl-ag-switcher-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prl-ag-switcher-chev { flex-shrink: 0; color: rgba(255,255,255,0.4); transition: transform .2s; }
.prl-ag-switcher-btn[aria-expanded="true"] .prl-ag-switcher-chev { transform: rotate(180deg); }

.prl-ag-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 14px;
  right: 14px;
  background: #111827;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 6px;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  max-height: 320px;
  overflow-y: auto;
}
.prl-ag-dropdown.open { display: block; }
.prl-ag-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: rgba(203,213,225,0.85);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s;
}
.prl-ag-dropdown-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.prl-ag-dropdown-item.active { background: rgba(255,255,255,0.06); color: #fff; }
.prl-ag-dropdown-item.portfolio { font-weight: 700; color: #FFBE0B; }
.prl-ag-dropdown-item.add { color: rgba(148,163,184,0.6); }
.prl-ag-dropdown-item.add:hover { color: #fff; }
.prl-ag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.prl-ag-dropdown-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 4px 0; }

/* ── Agency Coach Context Header ───────────────────────────── */
.prl-ag-context {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.prl-ag-back {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #FFBE0B;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 8px;
}
.prl-ag-back:hover { text-decoration: underline; }
.prl-ag-coach-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: white;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  body.prl-in:not(.prl-no-sidebar) .prl-sidebar,
  .prl-sidebar {
    transform: translateX(-100%) !important;
    width: 240px !important;
    transition: transform 200ms ease !important;
    z-index: 1100 !important;
  }
  .prl-sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  body.prl-in:not(.prl-no-sidebar) .page-content {
    padding-left: 0 !important;
  }
  .prl-flyout {
    left: 240px !important;
  }
}

/* ── Mobile backdrop ───────────────────────────────────────── */
.prl-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  transition: opacity .25s;
}
.prl-sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* ── Nuclear override — kills all 260px references ─────────── */
body.prl-in:not(.prl-no-sidebar) {
  --sb-width: 240px;
  --sidebar-width: 240px;
}

/* Override nav inner padding */
body.prl-in:not(.prl-no-sidebar) .prl-nav__inner,
body.prl-in:not(.prl-no-sidebar) .prl-topnav-inner,
body.prl-in:not(.prl-no-sidebar) nav .inner,
body.prl-in:not(.prl-no-sidebar) .nav-inner {
  padding-left: calc(240px + 16px) !important;
}

/* Kill any remaining 260px padding references */
/* Use > main to avoid hitting nested <main> elements (e.g. .comm-center) */
body.prl-in:not(.prl-no-sidebar) .page-content,
body.prl-in:not(.prl-no-sidebar) > main,
body.prl-in:not(.prl-no-sidebar) .main-content,
body.prl-in:not(.prl-no-sidebar) #main-content {
  padding-left: 240px !important;
  margin-left: 0 !important;
}

@media (max-width: 900px) {
  body.prl-in:not(.prl-no-sidebar) .prl-nav__inner {
    padding-left: 16px !important;
  }
  body.prl-in:not(.prl-no-sidebar) .page-content,
  body.prl-in:not(.prl-no-sidebar) > main,
  body.prl-in:not(.prl-no-sidebar) .main-content,
  body.prl-in:not(.prl-no-sidebar) #main-content {
    padding-left: 0 !important;
  }
}
