/* ============================================================================
   RDR LAYOUT — App Shell (Sidebar + Topbar + Content)
   ============================================================================
   White + Blue theme — Light sidebar with blue gradient header,
   clean typography, premium feel.
   ============================================================================ */

/* ── App Layout ── */

.app-layout {
  display: flex;
  min-height: 100vh;
  background: #F0F4F8;
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR — White with Blue Gradient Header
   ══════════════════════════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  transition: width var(--duration-normal) var(--ease-out),
              min-width var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
  overflow: hidden;
  border-right: 1px solid #E8ECF1;
  box-shadow: 1px 0 8px rgba(0, 0, 0, 0.03);
}

/* ── Sidebar Header — Clean with Blue Logo ── */

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  background: #FFFFFF;
  border-bottom: 1px solid #E8ECF1;
  min-height: 64px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand h2 {
  font-size: 16px;
  font-weight: var(--weight-bold);
  color: #1E293B;
  letter-spacing: -0.2px;
  line-height: 1.2;
  margin: 0;
}

.sidebar-brand span {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  color: #64748B;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Navigation ── */

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-3) var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
  gap: 2px;
}

/* Scrollbar */
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #D5DAE0; border-radius: 10px; }

/* Section labels */
.nav-section-label {
  font-size: 10px;
  font-weight: var(--weight-bold);
  color: #9CA3AF;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: var(--space-4) var(--space-3) var(--space-2);
  user-select: none;
}

/* Nav items — Light theme */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px 12px;
  border-radius: 8px;
  color: #64748B;
  font-size: 13.5px;
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  color: #1E3A5F;
  background: #F1F5F9;
}

.nav-item.active {
  color: #2563EB;
  background: #EFF6FF;
  font-weight: var(--weight-semibold);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: #2563EB;
  border-radius: 0 3px 3px 0;
}

/* Nav icons */
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Toggle icon (accordion) */
.nav-toggle-icon {
  width: 14px;
  height: 14px;
  margin-left: auto;
  opacity: 0.35;
  transition: transform var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
}

.nav-toggle-icon svg {
  width: 14px;
  height: 14px;
}

/* Nav group accordion */
.nav-group.expanded > .nav-item .nav-toggle-icon {
  transform: rotate(90deg);
  opacity: 0.6;
}

.nav-subitems {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-normal) var(--ease-out);
}

.nav-group.expanded .nav-subitems {
  max-height: 600px;
}

.nav-subitem {
  padding-left: 44px;
  font-size: 13px;
}

.nav-subitem::before {
  display: none;
}

/* Subcategory labels within nav groups */
.nav-sublabel {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 700;
  color: #94A3B8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px 4px 44px;
  user-select: none;
}

.nav-sublabel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94A3B8;
  flex-shrink: 0;
}

/* Badge (for "Soon") */
.nav-item .badge {
  margin-left: auto;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #F1F5F9;
  color: #94A3B8;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  border: 1px solid #E2E8F0;
}

/* ── Sidebar Footer ── */

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid #E8ECF1;
  background: #FAFBFC;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.sidebar-user:hover {
  background: #F1F5F9;
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563EB, #3B82F6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: var(--weight-bold);
  color: #FFFFFF;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: var(--weight-semibold);
  color: #1E293B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: #94A3B8;
  font-weight: var(--weight-medium);
}

/* ── Sidebar Collapse Button ── */

.sidebar-collapse-btn {
  position: absolute;
  top: 80px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  color: #64748B;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.sidebar-collapse-btn svg {
  width: 14px;
  height: 14px;
}

.sidebar:hover .sidebar-collapse-btn {
  opacity: 1;
}

.sidebar-collapse-btn:hover {
  background: #2563EB;
  color: #FFFFFF;
  border-color: #2563EB;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* Collapsed state */
.sidebar.collapsed {
  width: 64px;
  min-width: 64px;
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-toggle-icon,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .nav-subitems,
.sidebar.collapsed .badge {
  display: none;
}

.sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: var(--space-5) var(--space-3);
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}


/* ══════════════════════════════════════════════════════════════
   TOPBAR — Clean white with subtle shadow
   ══════════════════════════════════════════════════════════════ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 var(--space-6);
  background: #FFFFFF;
  border-bottom: 1px solid #E8ECF1;
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-title {
  font-size: 15px;
  font-weight: var(--weight-semibold);
  color: #1E293B;
  letter-spacing: -0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Mobile menu button */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: #64748B;
  border-radius: 8px;
}

.menu-toggle:hover {
  background: #F1F5F9;
}

/* Topbar avatar */
.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563EB, #3B82F6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: var(--weight-bold);
  color: #FFFFFF;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: box-shadow var(--duration-fast) var(--ease-out);
}

.topbar-avatar:hover {
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
}

/* Topbar icon buttons */
.topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #94A3B8;
  transition: all var(--duration-fast) var(--ease-out);
}

.topbar-btn:hover {
  background: #F1F5F9;
  color: #475569;
}

.topbar-btn svg {
  width: 18px;
  height: 18px;
}


/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════════ */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--duration-normal) var(--ease-out);
  background: #F0F4F8;
  overflow-x: auto;
}

.sidebar.collapsed ~ .main-content {
  margin-left: 64px;
}

.page-content {
  flex: 1;
  padding: var(--space-8) var(--space-6);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  overflow-x: auto;
}

/* ── Sidebar Overlay (mobile) ── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: var(--z-sidebar);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  }

  .sidebar .sidebar-collapse-btn {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .sidebar.collapsed ~ .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: var(--space-4);
  }

  .topbar {
    padding: 0 var(--space-4);
  }
}

/* ══════════════════════════════════════════════════════════════
   PAGE TRANSITIONS — Smooth fade between modules
   ══════════════════════════════════════════════════════════════ */

/* The content fades in smoothly when a page loads */
.main-content {
  animation: pageContentFadeIn 0.3s ease-out both;
}

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

/* Full-screen overlay that covers only the main content area.
   It sits above the content but below the sidebar, so the sidebar
   never disappears during a transition. */
.page-transition-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--sidebar-width);
  background: #F0F4F8;
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-in;
}

.page-transition-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* On mobile, overlay covers the entire screen */
@media (max-width: 1024px) {
  .page-transition-overlay {
    left: 0;
  }
}

/* The sidebar collapses to 68px; match the overlay */
.sidebar.collapsed ~ .page-transition-overlay {
  left: 68px;
}
