/* ==========================================================================
   CMW — Create My Website: Right-Side Menu & Rail Architecture
   ========================================================================== */

/* --------------------------------------------------------------------------
   BACKDROP OVERLAY
   -------------------------------------------------------------------------- */
.cmw-sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cmw-sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   DESKTOP RAIL (Always visible on desktop screens >= 992px)
   -------------------------------------------------------------------------- */
.cmw-sidebar-rail {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: var(--cmw-rail-width, 64px);
  height: 100vh;
  background-color: var(--cmw-white);
  border-left: 1px solid var(--cmw-slate-200);
  z-index: 990;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
}

@media (min-width: 992px) {
  .cmw-sidebar-rail {
    display: flex;
  }
}

.cmw-rail-top {
  margin-bottom: 1.5rem;
}

.cmw-rail-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--cmw-radius-sm);
  background: var(--cmw-slate-50);
  border: 1px solid var(--cmw-slate-200);
  color: var(--cmw-slate-700);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--cmw-transition-fast);
}

.cmw-rail-btn:hover {
  background: var(--cmw-primary-light);
  color: var(--cmw-primary);
  border-color: #bfdbfe;
}

.cmw-rail-nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  align-items: center;
  flex-grow: 1;
}

.cmw-rail-link {
  width: 44px;
  height: 44px;
  border-radius: var(--cmw-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cmw-slate-500);
  transition: all var(--cmw-transition-fast);
}

.cmw-rail-link:hover,
.cmw-rail-link.active {
  color: var(--cmw-primary);
  background-color: var(--cmw-primary-light);
}

.cmw-rail-bottom {
  margin-top: auto;
}

.cmw-rail-avatar-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* --------------------------------------------------------------------------
   EXPANDED SIDEBAR DRAWER (Desktop & Mobile)
   -------------------------------------------------------------------------- */
.cmw-sidebar-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 90vw;
  height: 100vh;
  background-color: var(--cmw-white);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.32s;
  overflow-y: auto;
}

.cmw-sidebar-drawer.open {
  transform: translateX(0);
  visibility: visible;
}

/* Drawer Header */
.cmw-drawer-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--cmw-slate-200);
}

.cmw-drawer-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cmw-drawer-logo {
  border-radius: var(--cmw-radius-sm);
  object-fit: cover;
  border: 1px solid var(--cmw-slate-200);
}

.cmw-drawer-title-group {
  display: flex;
  flex-direction: column;
}

.cmw-drawer-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--cmw-slate-900);
}

.cmw-drawer-sub {
  font-size: 0.72rem;
  color: var(--cmw-slate-500);
}

.cmw-drawer-close-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--cmw-radius-sm);
  background: var(--cmw-slate-100);
  border: 1px solid var(--cmw-slate-200);
  color: var(--cmw-slate-600);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--cmw-transition-fast);
}

.cmw-drawer-close-btn:hover {
  background: var(--cmw-slate-200);
  color: var(--cmw-slate-900);
}

/* Drawer Body */
.cmw-drawer-body {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Profile Section */
.cmw-profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--cmw-slate-50);
  border: 1px solid var(--cmw-slate-200);
  border-radius: var(--cmw-radius-md);
}

.cmw-avatar-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e0e7ff;
  color: var(--cmw-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.15rem;
  overflow: hidden;
  border: 2px solid var(--cmw-white);
  box-shadow: var(--cmw-shadow-sm);
  flex-shrink: 0;
}

.cmw-avatar-circle.small {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
}

.cmw-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cmw-profile-details {
  overflow: hidden;
}

.cmw-user-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--cmw-slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmw-user-email {
  font-size: 0.78rem;
  color: var(--cmw-slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Navigation Items */
.cmw-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cmw-drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--cmw-radius-sm);
  color: var(--cmw-slate-700);
  font-weight: 500;
  font-size: 0.92rem;
  transition: all var(--cmw-transition-fast);
}

.cmw-drawer-nav-item:hover,
.cmw-drawer-nav-item.active {
  background-color: var(--cmw-primary-light);
  color: var(--cmw-primary);
}

.cmw-drawer-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.cmw-drawer-divider {
  height: 1px;
  background-color: var(--cmw-slate-200);
  margin: 0.5rem 0;
}

/* Drawer Footer */
.cmw-drawer-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--cmw-slate-200);
  background: var(--cmw-white);
}

.cmw-auth-state-box {
  width: 100%;
}

/* Mobile Specific (Drawer width: 85vw to 92vw) */
@media (max-width: 991px) {
  .cmw-sidebar-drawer {
    width: 88vw;
    max-width: 380px;
  }
}