/* ============================================================
   Premium Sidebar + Feature Studio Enhancements
   - fixes truncation and alignment in expanded mode
   - adds desktop collapse/expand states with saved preference
   - improves mobile drawer behavior and submenu animation visuals
   - adds shared showcase styles for new feature studio content
   ============================================================ */

:root {
  --premium-sidebar-expanded: 220px;
  --premium-sidebar-collapsed: 70px;
  --premium-sidebar-mobile: min(86vw, 320px);
  --premium-sidebar-gap: 12px;
  --premium-sidebar-pad-x: 14px;
  --premium-sidebar-pad-y: 12px;
  --premium-sidebar-radius: 14px;
  --premium-sidebar-ring: rgba(255, 255, 255, 0.08);
  --premium-sidebar-hover: rgba(255, 255, 255, 0.075);
  --premium-sidebar-active: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(59, 130, 246, 0.18));
  --premium-sidebar-border: rgba(255, 255, 255, 0.08);
  --premium-content-radius: 22px;
}

body.pw-admin-theme {
  --premium-sidebar-current: var(--premium-sidebar-expanded);
}

body.pw-admin-theme.sidebar-collapsed {
  --premium-sidebar-current: var(--premium-sidebar-collapsed);
}

body.pw-admin-theme .pw-sidebar-shell {
  width: var(--premium-sidebar-current) !important;
  min-width: var(--premium-sidebar-current) !important;
  max-width: var(--premium-sidebar-current) !important;
  transition: width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

body.pw-admin-theme .main-content,
body.pw-admin-theme .main-content.content-wrapper {
  margin-left: var(--premium-sidebar-current) !important;
  width: calc(100% - var(--premium-sidebar-current)) !important;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

body.pw-admin-theme .pw-sidebar-shell .sidebar-inner {
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.pw-admin-theme .pw-sidebar-shell .sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0 22px;
  scrollbar-gutter: stable both-edges;
}

body.pw-admin-theme .pw-sidebar-shell .nav.nav-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.pw-admin-theme .pw-sidebar-shell .pw-sidebar-brand-wrap {
  padding: 14px 14px 10px;
}

body.pw-admin-theme .pw-sidebar-shell .pw-brand-link {
  min-height: 48px !important;
  border-radius: 16px;
  padding: 8px 10px !important;
  transition: background 0.25s ease, transform 0.25s ease;
}

body.pw-admin-theme .pw-sidebar-shell .pw-brand-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

body.pw-admin-theme .pw-sidebar-shell .pw-brand-copy {
  min-width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, width 0.2s ease, margin 0.2s ease;
}

body.pw-admin-theme .pw-sidebar-shell .pw-brand-copy strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.pw-admin-theme .pw-sidebar-shell .sidebar-search-wrap {
  margin: 8px 10px 12px !important;
  transition: opacity 0.2s ease, max-height 0.2s ease, margin 0.2s ease;
}

body.pw-admin-theme .pw-sidebar-shell .sidebar-search-group {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--premium-sidebar-border);
  background: rgba(255, 255, 255, 0.05);
}

body.pw-admin-theme .pw-sidebar-shell .form-control-sidebar,
body.pw-admin-theme .pw-sidebar-shell .btn-sidebar {
  background: transparent !important;
  border: 0 !important;
}

body.pw-admin-theme .pw-sidebar-shell .form-control-sidebar {
  height: 42px;
}

body.pw-admin-theme .pw-sidebar-shell .btn-sidebar {
  width: 42px;
  min-width: 42px;
}

body.pw-admin-theme .pw-sidebar-shell .nav-header,
body.pw-admin-theme .pw-sidebar-shell .nav-section-title {
  margin: 10px 0 4px;
  padding: 8px 16px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease, max-height 0.2s ease, padding 0.2s ease, margin 0.2s ease;
}

body.pw-admin-theme .pw-sidebar-shell .nav-item {
  display: block;
}

body.pw-admin-theme .pw-sidebar-shell .nav-link,
body.pw-admin-theme .pw-sidebar-shell .nav-link-button,
body.pw-admin-theme .pw-sidebar-shell .pw-submenu-link {
  position: relative;
  display: flex !important;
  align-items: center !important;
  gap: var(--premium-sidebar-gap);
  min-height: 46px;
  padding: var(--premium-sidebar-pad-y) var(--premium-sidebar-pad-x) !important;
  margin: 0 10px 6px !important;
  border-radius: var(--premium-sidebar-radius) !important;
  border-left: 0 !important;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.24s ease, color 0.24s ease, transform 0.24s ease, box-shadow 0.24s ease;
}

body.pw-admin-theme .pw-sidebar-shell .nav-link:hover,
body.pw-admin-theme .pw-sidebar-shell .nav-link-button:hover,
body.pw-admin-theme .pw-sidebar-shell .pw-submenu-link:hover {
  background: var(--premium-sidebar-hover) !important;
  transform: translateX(2px);
}

body.pw-admin-theme .pw-sidebar-shell .nav-link.active,
body.pw-admin-theme .pw-sidebar-shell .nav-link-button.active,
body.pw-admin-theme .pw-sidebar-shell .pw-submenu-link.active {
  background: var(--premium-sidebar-active) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 22px rgba(15, 23, 42, 0.2);
  color: #ffffff !important;
}

body.pw-admin-theme .pw-sidebar-shell .nav-link p,
body.pw-admin-theme .pw-sidebar-shell .nav-link-button p,
body.pw-admin-theme .pw-sidebar-shell .pw-submenu-link p {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
}

body.pw-admin-theme .pw-sidebar-shell .pw-nav-label,
body.pw-admin-theme .pw-sidebar-shell .nav-link p,
body.pw-admin-theme .pw-sidebar-shell .nav-link-button p,
body.pw-admin-theme .pw-sidebar-shell .pw-submenu-link p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.pw-admin-theme .pw-sidebar-shell .nav-icon,
body.pw-admin-theme .pw-sidebar-shell .sidebar-nav .icon {
  width: 20px;
  min-width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
}

body.pw-admin-theme .pw-sidebar-shell .nav-group-arrow {
  margin-left: auto;
  flex: 0 0 auto;
  transition: transform 0.24s ease, opacity 0.2s ease;
}

body.pw-admin-theme .pw-sidebar-shell .nav-treeview {
  display: block;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.28s ease, opacity 0.24s ease;
  padding-bottom: 4px;
}

body.pw-admin-theme .pw-sidebar-shell .menu-open > .nav-treeview,
body.pw-admin-theme .pw-sidebar-shell .is-open > .nav-treeview {
  opacity: 1;
  pointer-events: auto;
}

body.pw-admin-theme .pw-sidebar-shell .nav-treeview .nav-item {
  padding-left: 8px;
}

body.pw-admin-theme .pw-sidebar-shell .pw-submenu-link {
  min-height: 40px;
  padding-left: 20px !important;
  margin-left: 22px !important;
  margin-right: 10px !important;
  border-radius: 12px !important;
  color: rgba(255, 255, 255, 0.78) !important;
}

body.pw-admin-theme .pw-sidebar-shell .pw-submenu-bullet {
  width: 8px;
  min-width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.04);
  font-size: 0;
}

body.pw-admin-theme .pw-sidebar-shell .pw-submenu-link.active .pw-submenu-bullet {
  background: #fbbf24;
  box-shadow: 0 0 0 5px rgba(251, 191, 36, 0.12);
}

body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .pw-brand-copy,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .sidebar-search-wrap,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-header,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-section-title,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-group-arrow,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-treeview,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .pw-submenu-bullet,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .pw-submenu-link {
  opacity: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-width: 0 !important;
}

body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .pw-brand-link {
  justify-content: center;
}

body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-link,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-link-button {
  justify-content: center;
  margin-left: 8px !important;
  margin-right: 8px !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-link p,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-link-button p {
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0 !important;
  margin: 0 !important;
}

body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-link:hover,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-link-button:hover {
  transform: none;
}

body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-link.active,
body.pw-admin-theme.sidebar-collapsed .pw-sidebar-shell .nav-link-button.active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

body.pw-admin-theme .topbar-trigger {
  position: relative;
}

body.pw-admin-theme .topbar-trigger::after {
  content: 'Ctrl + \\';
  position: absolute;
  right: -6px;
  bottom: -16px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
}

body.pw-admin-theme .topbar-trigger:hover::after {
  opacity: 1;
}

body.pw-admin-theme .ep-platform-showcase,
body.pw-admin-theme .feature-studio-card,
body.pw-admin-theme .feature-studio-hero,
body.pw-admin-theme .feature-studio-highlight,
body.pw-admin-theme .feature-studio-integration,
body.pw-admin-theme .feature-studio-stack {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--premium-content-radius);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

body.pw-admin-theme .ep-platform-showcase .ep-card-header {
  gap: 12px;
  flex-wrap: wrap;
}

body.pw-admin-theme .ep-enhancement-grid,
body.pw-admin-theme .feature-studio-grid,
body.pw-admin-theme .feature-studio-integrations {
  display: grid;
  gap: 16px;
}

body.pw-admin-theme .ep-enhancement-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.pw-admin-theme .feature-studio-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body.pw-admin-theme .feature-studio-integrations {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.pw-admin-theme .ep-enhancement-card,
body.pw-admin-theme .feature-studio-card,
body.pw-admin-theme .feature-studio-integration,
body.pw-admin-theme .feature-studio-stack {
  padding: 18px;
}

body.pw-admin-theme .ep-enhancement-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid rgba(96, 165, 250, 0.12);
  border-radius: 18px;
}

body.pw-admin-theme .ep-enhancement-icon,
body.pw-admin-theme .feature-studio-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(14, 165, 233, 0.18));
  color: #2563eb;
  font-size: 1rem;
  margin-bottom: 14px;
}

body.pw-admin-theme .ep-enhancement-title,
body.pw-admin-theme .feature-studio-title {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 8px;
}

body.pw-admin-theme .ep-enhancement-copy,
body.pw-admin-theme .feature-studio-copy,
body.pw-admin-theme .feature-studio-meta,
body.pw-admin-theme .feature-studio-list {
  color: #64748b;
  font-size: 0.86rem;
  line-height: 1.6;
}

body.pw-admin-theme .feature-studio-list {
  margin: 12px 0 0;
  padding-left: 18px;
}

body.pw-admin-theme .feature-studio-list li + li {
  margin-top: 6px;
}

body.pw-admin-theme .feature-studio-hero {
  overflow: hidden;
  position: relative;
  padding: 26px;
  background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 28%), linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
}

body.pw-admin-theme .feature-studio-hero::after {
  content: '';
  position: absolute;
  inset: auto -120px -140px auto;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.18), transparent 70%);
}

body.pw-admin-theme .feature-studio-hero-grid,
body.pw-admin-theme .feature-studio-stat-grid,
body.pw-admin-theme .feature-studio-stack-grid {
  display: grid;
  gap: 16px;
}

body.pw-admin-theme .feature-studio-hero-grid {
  grid-template-columns: 1.4fr 0.9fr;
  align-items: center;
}

body.pw-admin-theme .feature-studio-stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
}

body.pw-admin-theme .feature-studio-stat {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

body.pw-admin-theme .feature-studio-stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

body.pw-admin-theme .feature-studio-stat-label {
  margin-top: 6px;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body.pw-admin-theme .feature-pill,
body.pw-admin-theme .feature-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body.pw-admin-theme .feature-pill {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}

body.pw-admin-theme .feature-status-pill.status-ready {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

body.pw-admin-theme .feature-status-pill.status-beta {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

body.pw-admin-theme .feature-status-pill.status-planned {
  background: rgba(99, 102, 241, 0.14);
  color: #4338ca;
}

body.pw-admin-theme .feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

body.pw-admin-theme .feature-studio-card-head,
body.pw-admin-theme .feature-studio-stack-head,
body.pw-admin-theme .feature-studio-integration-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

body.pw-admin-theme .feature-studio-stack-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.pw-admin-theme .feature-studio-highlight {
  padding: 18px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(59, 130, 246, 0.05));
}

body.pw-admin-theme .feature-studio-highlight h3,
body.pw-admin-theme .feature-studio-stack h3,
body.pw-admin-theme .feature-studio-integration h3 {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 8px;
}

body.pw-admin-theme .feature-studio-highlight p,
body.pw-admin-theme .feature-studio-stack p,
body.pw-admin-theme .feature-studio-integration p {
  color: #64748b;
  font-size: 0.88rem;
  line-height: 1.65;
}

body.pw-admin-theme .feature-studio-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

body.pw-admin-theme .feature-studio-mini-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

body.pw-admin-theme .feature-studio-mini-card strong {
  display: block;
  color: #0f172a;
  margin-bottom: 4px;
}

body.pw-admin-theme .feature-studio-mini-card span {
  color: #64748b;
  font-size: 0.8rem;
}

body.pw-admin-theme .feature-studio-route-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-weight: 700;
}

body.pw-admin-theme .feature-studio-caption {
  color: #64748b;
  font-size: 0.92rem;
  line-height: 1.7;
}

body.pw-admin-theme .feature-studio-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

body.pw-admin-theme .feature-studio-heading h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: #0f172a;
}

body.pw-admin-theme .feature-studio-heading p {
  margin: 0;
  color: #64748b;
}

body.pw-admin-theme .feature-studio-page .page-content {
  padding-bottom: 36px !important;
}

body.pw-admin-theme .feature-studio-section + .feature-studio-section {
  margin-top: 22px;
}

body.pw-admin-theme .sidebar-mobile-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 39;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

body.pw-admin-theme.sidebar-mobile-open .sidebar-mobile-scrim {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 1199.98px) {
  body.pw-admin-theme .feature-studio-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.pw-admin-theme .feature-studio-hero-grid,
  body.pw-admin-theme .feature-studio-integrations,
  body.pw-admin-theme .ep-enhancement-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  body.pw-admin-theme {
    --premium-sidebar-current: 0px;
  }

  body.pw-admin-theme .pw-sidebar-shell {
    width: var(--premium-sidebar-mobile) !important;
    min-width: var(--premium-sidebar-mobile) !important;
    max-width: var(--premium-sidebar-mobile) !important;
    transform: translateX(-104%);
    z-index: 60;
  }

  body.pw-admin-theme.sidebar-mobile-open .pw-sidebar-shell,
  body.pw-admin-theme .pw-sidebar-shell.open {
    transform: translateX(0);
  }

  body.pw-admin-theme .main-content,
  body.pw-admin-theme .main-content.content-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
  }

  body.pw-admin-theme .topbar-trigger::after {
    display: none;
  }

  body.pw-admin-theme .feature-studio-grid,
  body.pw-admin-theme .feature-studio-integrations,
  body.pw-admin-theme .feature-studio-stat-grid,
  body.pw-admin-theme .feature-studio-stack-grid,
  body.pw-admin-theme .ep-enhancement-grid,
  body.pw-admin-theme .feature-studio-hero-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767.98px) {
  body.pw-admin-theme .page-content {
    padding: 14px 14px 24px !important;
  }

  body.pw-admin-theme .pw-sidebar-shell .nav-link,
  body.pw-admin-theme .pw-sidebar-shell .nav-link-button,
  body.pw-admin-theme .pw-sidebar-shell .pw-submenu-link {
    min-height: 44px;
    padding: 11px 14px !important;
  }

  body.pw-admin-theme .feature-studio-hero,
  body.pw-admin-theme .feature-studio-card,
  body.pw-admin-theme .feature-studio-integration,
  body.pw-admin-theme .feature-studio-stack,
  body.pw-admin-theme .ep-enhancement-card {
    padding: 16px;
    border-radius: 18px;
  }

  body.pw-admin-theme .feature-studio-mini-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body.pw-admin-theme .pw-sidebar-shell,
  body.pw-admin-theme .topbar,
  body.pw-admin-theme .sidebar-mobile-scrim {
    display: none !important;
  }

  body.pw-admin-theme .main-content,
  body.pw-admin-theme .main-content.content-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
  }
}
