/* ============================================================================
  public/src/components/side-menu/side-menu.css
  CSS variables at themes.css
  SIDEBAR — Persistent Collapsible Icon-Rail
  Desktop: 64px collapsed → 240px expanded (left-fixed, full-height)
  Mobile (≤768px): hidden off-screen, slides in from left with backdrop
   ============================================================================ */
/* ── Sidebar Panel ────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  height: 100%;
  width: var(--sidebar-collapsed-width);
  background: var(--sidebar-color);
  border-left: 1px solid var(--color-border);
  z-index: var(--z-overlay, 500);
  display: flex;
  flex-direction: column;
  transition: width 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded {
  width: var(--sidebar-expanded-width);
}

/* Drag handle only exists for the mobile bottom-sheet; not part of the
   desktop rail layout at all. */
.sidebar-drag-handle {
  display: none;
}

/* ── Pinned Bottom Actions ────────────────────────────────────────────────
   Lives as the LAST CHILD INSIDE <nav> (not a sibling of it) so that on
   mobile — where .sidebar itself must stay locked/non-scrolling and <nav>
   is the single scroll owner (see the mobile media query) — it naturally
   flows and scrolls as part of nav's own content instead of requiring a
   second, separate scroll region.
   On desktop this would normally mean it scrolls away with the rest of
   nav's content, which breaks the "always reachable without scrolling"
   design intent — position: sticky + bottom: 0 (further down, desktop-only)
   keeps it glued to the bottom of nav's own scrollport while remaining a
   real nav child, giving both breakpoints what they need from one DOM
   structure. */
.sidebar-pinned-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-top: 1px solid var(--color-border);
  background: var(--sidebar-color);
}

/* Some legacy page templates still place this block inside the nav scroll
   container. Make that placement occupy the sidebar track rather than the
   nav's 8px padded content track; templates with a direct-sidebar placement
   are unaffected. */
.sidebar nav>.sidebar-pinned-actions {
  width: calc(100% + 16px);
  margin-left: -8px;
  margin-right: -8px;
}

/* Desktop only: stick to the bottom of nav's own scrollport instead of
   scrolling away with the rest of the nav content, reproducing the old
   "sibling of nav, always visible" behavior while staying a real nav
   child (required for the mobile single-scroll fix below). */
@media (min-width: 769px) {
  .sidebar-pinned-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: auto;
  }
}

/* ============================================================================
   BOTTOM NAVIGATION BAR — Play Store style (mobile only, ≤768px)
   Hidden entirely on desktop; desktop sidebar is untouched.
   ============================================================================ */
.bottom-nav {
  display: none;
}

[data-theme="dark-slate"] #breadcrumb,
[data-theme="dark"] #breadcrumb {
  background: var(--color-surface);
  border-color: var(--color-border);
}

/* Solution for showing the side bar at the right, and the rest normally rtl */
.side-menu nav {
  direction: ltr;
}

.side-menu nav>* {
  direction: rtl;
}

/* Side menu scrollbar */
.side-menu nav::-webkit-scrollbar {
  width: 6px;
}

.side-menu nav::-webkit-scrollbar-track {
  background: var(--color-background-secondary);
}

.side-menu nav::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.side-menu nav::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ── Backdrop (mobile overlay) ───────────────────────────────────────────── */
.side-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: calc(var(--z-overlay, 500) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.side-menu-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Nav Scroll Container ────────────────────────────────────────────────── */
.sidebar nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: clip;
  padding: 8px 8px 24px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  direction: ltr;
}

.sidebar nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar nav::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

/* ── Sidebar Header (Expanded Mode) ──────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition:
    max-width 250ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 150ms ease,
    min-height 250ms cubic-bezier(0.4, 0, 0.2, 1),
    padding 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded .sidebar-header {
  max-width: 100%;
  opacity: 1;
  overflow: visible;
  pointer-events: auto;
  padding: 14px 10px 8px 14px;
  min-height: 52px;
  transition:
    max-width 250ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 150ms ease 100ms,
    min-height 250ms cubic-bezier(0.4, 0, 0.2, 1),
    padding 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.sidebar-brand-text {
  opacity: 0;
  transition: opacity 150ms ease;
  font-family: Tajawal, Arial, sans-serif;
  font-size: 14px;
  font-weight: bold;
  color: currentColor;
  white-space: nowrap;
}

.sidebar.expanded .sidebar-brand-text {
  opacity: 1;
  transition: opacity 150ms ease 100ms;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  pointer-events: none;
  gap: 5px;
}

.sidebar-logo .sidebar-favicon-img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
}

/* In-header collapse button when sidebar is expanded */
.sidebar-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--border-radius-md, 8px);
  cursor: pointer;
  position: relative;
  color: var(--color-text-secondary, #94a3b8);
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover,
.sidebar-collapse-btn:focus-visible {
  background: var(--color-background-secondary, rgba(255, 255, 255, 0.08));
  color: var(--color-primary, #6366f1);
  outline: none;
}

.sidebar-collapse-btn svg {
  width: 20px;
  height: 20px;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapse-btn .icon-default {
  opacity: 1;
  transform: scale(1);
}

.sidebar-collapse-btn .icon-hover {
  position: absolute;
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

.sidebar-collapse-btn:hover .icon-default,
.sidebar-collapse-btn:focus-visible .icon-default {
  opacity: 0;
  transform: scale(0.85);
}

.sidebar-collapse-btn:hover .icon-hover,
.sidebar-collapse-btn:focus-visible .icon-hover {
  opacity: 1;
  transform: scale(1);
}

/* ── Sidebar Favicon (Collapsed Rail Mode) ────────────────────────────────── */
.sidebar-favicon {
  display: none;
}

.sidebar:not(.expanded) .sidebar-favicon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 10px auto 4px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  color: var(--color-text);
  transition: background-color 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.sidebar:not(.expanded) .sidebar-favicon:hover,
.sidebar:not(.expanded) .sidebar-favicon:focus-visible {
  background: var(--color-background-secondary, rgba(255, 255, 255, 0.08));
  outline: none;
}

.sidebar-favicon .sidebar-favicon-img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: contain;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  transform: scale(1);
}

.sidebar-favicon .sidebar-expand-icon {
  position: absolute;
  width: 22px;
  height: 22px;
  color: var(--color-primary, #6366f1);
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.sidebar-favicon:hover .sidebar-favicon-img,
.sidebar-favicon:focus-visible .sidebar-favicon-img {
  opacity: 0;
  transform: scale(0.8);
}

.sidebar-favicon:hover .sidebar-expand-icon,
.sidebar-favicon:focus-visible .sidebar-expand-icon {
  opacity: 1;
  transform: scale(1);
}

.sidebar.expanded .sidebar-favicon {
  display: none !important;
}

.sidebar:not(.expanded) .sidebar-logo {
  display: none;
}

/**/
.sidebar:not(.expanded) .menu-section-title,
.sidebar:not(.expanded) .animation-toggle-container,
.sidebar:not(.expanded) .animation-toggle-label,
.sidebar:not(.expanded) .theme-section-header,
.sidebar:not(.expanded) .theme-selector-grid,
.sidebar:not(.expanded) .menu-divider.sidebar-expanded-only,
.sidebar:not(.expanded) .toggle-switch,
.sidebar:not(.expanded) .theme-controls-toggle {
  display: none;
}

/* ── Profile Avatar Dropdown (desktop sidebar only) ──────────────────────── */
.menu-item-dropdown-wrap {
  position: relative;
}

/* The standalone "تغيير الإسم" menu-item stays for the mobile bottom-sheet
   (which keeps the old plain-link/no-dropdown pattern) but is redundant on
   desktop now that it's reachable from inside the profile dropdown. */
@media (min-width: 769px) {
  .mobile-only-menu-item {
    display: none !important;
  }
}

/* The desktop-style profile dropdown (avatar cover, email row, sign-out,
   etc.) is not meant for mobile — the bottom nav already has its own
   direct "الحساب" tab/link to profile.html. Hide the trigger + popover
   entirely in the mobile bottom-sheet so it isn't duplicated. */
@media (max-width: 768px) {
  .menu-item-dropdown-wrap {
    display: none !important;
  }
}

.side-menu-profile-dropdown {
  display: none;
  position: fixed;
  width: 240px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.18));
  padding: 0 0 6px;
  z-index: 1000;
  direction: rtl;
  overflow: hidden;
}

.side-menu-profile-dropdown.open {
  display: block;
  animation: sideMenuDropdownIn 0.15s ease;
}

@keyframes sideMenuDropdownIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.side-menu-profile-dropdown-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 0 14px;
  text-align: center;
  position: relative;
}

/* Cover strip — mirrors #identityThumbnail's resolved state (background-image
   + has-thumbnail/is-default-thumbnail classes), copied in by side-menu.js
   each time the dropdown opens. Scaled down for the 240px popover; the
   avatar overlaps its bottom edge the same way .avatar-wrapper does on the
   full identity band. */
.side-menu-profile-dropdown-cover {
  width: 100%;
  height: 64px;
  border-radius: 12px 12px 0 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.side-menu-profile-dropdown-cover.has-thumbnail {
  background-color: var(--color-background-secondary);
}

.side-menu-profile-dropdown-cover.has-thumbnail::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
      transparent 55%,
      color-mix(in srgb, var(--color-surface) 55%, transparent) 100%);
}

.side-menu-profile-dropdown-cover.is-default-thumbnail::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(135deg,
      rgba(255, 255, 255, 0.08) 0px,
      rgba(255, 255, 255, 0.08) 2px,
      transparent 2px,
      transparent 14px);
}

.side-menu-profile-dropdown-avatar-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: -36px;
  border: 3px solid var(--color-surface, #fff);
  background: var(--color-surface, #fff);
  position: relative;
  z-index: 1;
}

.side-menu-profile-dropdown-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.side-menu-profile-dropdown-default-icon {
  width: 100%;
  height: 100%;
  padding: 14px;
  border-radius: 50%;
  background: var(--color-background-secondary, #f5f5f5);
  color: var(--color-text-secondary);
  box-sizing: border-box;
  display: block;
}

.side-menu-profile-dropdown-labels {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  width: 100%;
  padding: 0 12px;
  box-sizing: border-box;
}

.side-menu-profile-dropdown-name {
  unicode-bidi: plaintext; /* truncate by the name's own direction */
  text-align: start;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.side-menu-profile-dropdown-email-row {
  display: flex;
  justify-content: center;
  width: 100%;
}

.side-menu-profile-dropdown-email {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  direction: ltr;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.side-menu-profile-dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 4px;
}

.side-menu-profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 96%;
  margin-left: 2%;
  margin-right: 2%;
  padding: 9px 8px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-decoration: none;
  cursor: pointer;
  text-align: right;
  direction: rtl;
}

.side-menu-profile-dropdown-item svg {
  flex-shrink: 0;
  color: inherit;
}

.side-menu-profile-dropdown-item-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.side-menu-profile-dropdown-item:hover:not(:disabled) {
  background: var(--color-background-secondary, #f5f5f5);
}

.side-menu-profile-dropdown-item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.side-menu-profile-dropdown-item:disabled,
.side-menu-profile-dropdown-item-muted {
  color: var(--color-text-tertiary, #999);
  cursor: default;
}

.side-menu-profile-dropdown-item-soon {
  margin-inline-start: auto;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-text-tertiary, #999);
  background: var(--color-background-secondary, #f5f5f5);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Sign In Item */
.side-menu-profile-dropdown-item-signin {
  color: var(--color-text-primary, #111827);
  background: var(--color-background-secondary, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
  font-weight: 600;
  margin-top: 4px;
  margin-bottom: 2px;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
}

.side-menu-profile-dropdown-item-signin:hover:not(:disabled) {
  background: var(--color-hover-overlay, rgba(99, 102, 241, 0.06));
  border-color: var(--color-primary, #6366f1);
  
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.side-menu-profile-dropdown-item-signin:active:not(:disabled) {
  transform: translateY(0);
}

.side-menu-dropdown-google-icon {
  flex-shrink: 0;
  display: block;
}

/* Danger / Sign Out Item */
.side-menu-profile-dropdown-item-danger {
  color: #ef4444;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.side-menu-profile-dropdown-item-danger:hover {
  background: #dc2626 !important;
  color: #ffffff !important;
}

.side-menu-profile-dropdown-item-danger:hover svg {
  stroke: #ffffff !important;
}

@media (max-width: 768px) {

  /* Dropdown is desktop-only — mobile bottom-nav profile tab stays a plain
     link and never renders this trigger/popover. */
  .side-menu-profile-dropdown {
    display: none !important;
  }
}

/* ── Menu Items ──────────────────────────────────────────────────────────── */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  text-decoration: none;
  border-radius: 10px;
  margin-bottom: 2px;
  background: none;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  text-align: right;
  direction: rtl;
  white-space: nowrap;
  position: relative;
  transition:
    background-color var(--duration-base, 240ms) var(--ease-out-expo, ease),
    color var(--duration-base, 240ms) var(--ease-out-expo, ease);
}

/*
 * Install button visibility is toggled by side-menu.js via the
 * `.is-installable` class. Default stays hidden (including when already
 * installed / standalone). When beforeinstallprompt fires, JS adds
 * `.is-installable` and this rule shows it as flex so the collapsed sidebar
 * icon still centers correctly.
 */
.menu-item.install-app {
  display: none !important;
}

.menu-item.install-app.is-installable {
  display: flex !important;
}

.menu-item svg {
  flex-shrink: 0;
  min-width: 22px;
  transition:
    transform var(--duration-base, 240ms) var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)),
    opacity var(--duration-fast, 120ms) ease;
  transform: scale(1) translateY(0);
}

.menu-item:active svg {
  transform: scale(0.94) translateY(0);
  transition-duration: var(--duration-fast, 120ms);
}

/* ── Icon line-draw animation ───────────────────────────────────────────── */
.menu-icon-line {
  --menu-icon-draw-length: 1;
  stroke-dasharray: var(--menu-icon-draw-length, 1);
  stroke-dashoffset: 0;
}

.menu-item:hover .menu-icon-line,
.menu-item:focus-visible .menu-icon-line,
.menu-item:active .menu-icon-line,
.bottom-nav-item:active .menu-icon-line {
  animation: menu-item-draw 1.2s cubic-bezier(0.45, 0, 0.55, 1) both;
}

/* Sub-shapes trail each other slightly so an icon redraws stroke by stroke
   instead of snapping back as one flat block. `both` fill-mode holds each
   shape at the 0% frame (fully drawn) through its delay, so the stagger never
   causes a flash of missing strokes. */
.menu-item:hover .menu-icon-line:nth-child(2),
.menu-item:focus-visible .menu-icon-line:nth-child(2),
.menu-item:active .menu-icon-line:nth-child(2),
.bottom-nav-item:active .menu-icon-line:nth-child(2) {
  animation-delay: 55ms;
}

.menu-item:hover .menu-icon-line:nth-child(3),
.menu-item:focus-visible .menu-icon-line:nth-child(3),
.menu-item:active .menu-icon-line:nth-child(3),
.bottom-nav-item:active .menu-icon-line:nth-child(3) {
  animation-delay: 110ms;
}

.menu-item:hover .menu-icon-line:nth-child(n + 4),
.menu-item:focus-visible .menu-icon-line:nth-child(n + 4),
.menu-item:active .menu-icon-line:nth-child(n + 4),
.bottom-nav-item:active .menu-icon-line:nth-child(n + 4) {
  animation-delay: 165ms;
}

@keyframes menu-item-draw {
  0% {
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dashoffset: var(--menu-icon-draw-length, 1);
  }

  100% {
    stroke-dashoffset: 0;
  }
}

/* Collapsed: center icons perfectly.
 * CRITICAL — gap must be 0 here: the .menu-label still exists in the DOM with
 * max-width: 0, but the flex gap (10px) between icon and label still pushes
 * the icon ~5px off-center. Setting gap: 0 when collapsed ensures pixel-perfect
 * centering of every icon within the 64px rail. */
.sidebar:not(.expanded) .menu-item {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}

.menu-section-title {
  text-align: center;
}

/* Labels: hidden when collapsed */
.menu-label {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transition:
    opacity 0s,
    max-width 0s;
  pointer-events: none;
  flex: 1;
}

.sidebar.expanded .menu-label {
  opacity: 1;
  max-width: 180px;
  pointer-events: auto;
  transition:
    opacity 120ms ease 80ms,
    max-width 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
}

.menu-item:hover {
  background: var(--color-background-secondary, #f5f5f5);
}

.menu-item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  border-radius: 10px;
}

.menu-item:active {
  background: var(--color-hover-overlay, var(--color-background-secondary));
  transition-duration: var(--duration-fast, 120ms);
}

.menu-item.active {
  background: var(--color-primary-light, #e8f0fe);
  color: var(--color-primary);
}

[data-theme="dark-slate"] .menu-item.active {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
}

[data-theme="dark"] .menu-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

/* ── Tooltips (collapsed state, desktop only) ────────────────────────────── */

.sidebar-hover-tooltip {
  position: fixed;
  background: var(--color-surface, #fff);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: var(--shadow-md);
  transition: opacity 0.15s ease 0.35s;
  z-index: 1000;
  direction: rtl;
}

.sidebar-hover-tooltip.visible {
  opacity: 1;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
.menu-divider {
  height: 1px;
  background: var(--color-border);
  margin-block: 8px;
  margin-inline: 4px;
  flex-shrink: 0;
}

/* ── Docs ("المستندات") section — added via documents-shell.js only,
   so it only ever renders on the doc pages, never on the main app pages. */
.docs-menu-heading {
  padding: 4px 12px 6px;
  color: var(--color-text-secondary, #6b7280);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.docs-menu-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.docs-menu-soon-badge {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--color-text-secondary, #6b7280);
  white-space: nowrap;
}

.docs-menu-search-wrap {
  padding: 0 12px 8px;
}

.docs-menu-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--color-text-primary, #111827);
  background: var(--color-background-secondary, #f5f5f5);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 8px;
}

.docs-menu-search:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.docs-menu-search::-webkit-search-cancel-button {
  cursor: pointer;
}

.docs-menu-empty {
  margin: 4px 12px;
  padding: 6px 0;
  color: var(--color-text-secondary, #6b7280);
  font-size: 0.78rem;
}

/* A matched doc-search result carries a snippet of the actual matching
   text underneath its label (see documents-shell.js's runSearch) —
   .menu-item is normally a rigid single-line row (white-space: nowrap,
   align-items: center), which would clip or misalign a second line, so a
   link that currently holds a snippet opts into a two-line layout locally
   rather than changing the shared .menu-item rule every other sidebar
   entry also uses. */
.docs-menu-link:has(.docs-menu-link-snippet) {
  align-items: flex-start;
  white-space: normal;
  padding-block: 8px;
}

.docs-menu-link-snippet {
  display: block;
  margin-top: 2px;
  color: var(--color-text-secondary, #6b7280);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
}

/* ── Section header labels: must NOT stretch (flex:1 is for menu-items only) */
.theme-section-header .menu-label {
  flex: none;
}

/* ── Theme Controls Section ──────────────────────────────────────────────── */
.theme-controls-section {
  margin-top: 4px;
}

/* Collapsed: collapse all margins in the theme/animation sections to remove dead space */
.sidebar:not(.expanded) .theme-controls-section {
  margin-top: 0;
  margin-bottom: 0;
}

.theme-section-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-tertiary, #888);
  white-space: nowrap;
  position: relative;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color var(--duration-fast, 120ms) ease;
}

.theme-section-header:hover {
  background: var(--color-background-secondary, #f5f5f5);
}

.theme-section-header:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* Match the sizing of the surrounding collapsed-rail .menu-item icons:
   same vertical padding (10px, not the expanded state's 8px) and an
   explicit full width so this button's hit area/footprint lines up with
   every other icon in the 64px rail instead of sizing to its own content. */
.sidebar:not(.expanded) .theme-section-header {
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px 0;
  gap: 0;
}

/* ── Items visible only when expanded ────────────────────────────────────── */
.sidebar-expanded-only {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
  margin: 0;
  transition:
    opacity 0s,
    max-height 0s;
}

.sidebar.expanded .sidebar-expanded-only {
  opacity: 1;
  max-height: 600px;
  overflow: visible;
  pointer-events: auto;
  transition:
    opacity 150ms ease 100ms,
    max-height 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
}

/* ── Items visible only when collapsed (inverse of the above) ───────────── */
.sidebar-collapsed-only {
  display: none;
}

.sidebar:not(.expanded) .sidebar-collapsed-only {
  display: flex;
}

/* ── Retractable / Accordion Section (theme + animation controls) ─────────── */
.theme-controls-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--color-text-tertiary, #888);
  font: inherit;
  text-align: right;
  direction: rtl;
  transition: background-color var(--duration-fast, 120ms) ease;
}

.theme-controls-toggle:hover {
  background: var(--color-background-secondary, #f5f5f5);
}

.theme-controls-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  border-radius: 8px;
}

.theme-controls-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.theme-controls-toggle-label .menu-label {
  flex: none;
  opacity: 1;
  max-width: none;
  pointer-events: auto;
}

.theme-controls-toggle-chevron {
  flex-shrink: 0;
  transition: transform var(--duration-base, 240ms) var(--ease-out-expo, ease);
}

/* Chevron points down when open (default markup state, aria-expanded="true"),
   rotates to point up (toward the content, since it collapses upward) when
   closed. */
.theme-controls-toggle[aria-expanded="false"] .theme-controls-toggle-chevron {
  transform: rotate(-90deg);
}

.theme-controls-panel {
  overflow: hidden;
  max-height: 600px;
  opacity: 1;
  transition:
    max-height var(--duration-slow, 400ms) var(--ease-out-expo, ease),
    opacity var(--duration-base, 240ms) ease;
}

.theme-controls-panel.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── Theme Selector Grid ─────────────────────────────────────────────────── */
.theme-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-block: 4px 6px;
  margin-inline: 4px;
  padding-top: 4px;
  overflow: visible;
}

/*
 * Theme picker buttons — each renders a tiny non-interactive preview of the
 * HOME PAGE (header/search bar + a couple of card-list rows) painted in that
 * theme's own fixed palette, so the button doubles as an accurate swatch —
 * not just an icon. Colors below are intentionally hardcoded per theme
 * (not var(--color-*)) since a swatch must always show ITS theme's colors,
 * regardless of which theme is currently active.
 */
.theme-selector-btn {
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 0 0 6px;
  cursor: pointer;
  background: none;
  overflow: hidden;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  position: relative;
}

.theme-selector-btn:hover {
  
  box-shadow: var(--shadow-sm);
}

.theme-selector-btn[aria-pressed="true"] {
  border-color: var(--color-primary);
  border-width: 2.5px;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ── Mini home-page preview ──────────────────────────────────────────────── */
.theme-btn-preview {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  height: 44px;
  padding: 5px;
  box-sizing: border-box;
  border-radius: 8px 8px 0 0;
  pointer-events: none;
}

/* Header row: search-bar pill + a small accent dot (mirrors the home
   page's search area) */
.theme-btn-preview-header {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 8px;
  flex-shrink: 0;
}

.theme-btn-preview-header::before {
  content: "";
  flex: 1;
  height: 100%;
  border-radius: 4px;
}

.theme-btn-preview-header::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Card-list silhouette: two stacked rows, each an icon-circle + text lines —
   mirrors .category-card's mobile list-row (.icon + .card-text) */
.theme-btn-preview-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.theme-btn-preview-row {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 11px;
  border-radius: 3px;
  padding-inline: 3px;
}

.theme-btn-preview-row::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.theme-btn-preview-row::after {
  content: "";
  flex: 1;
  height: 4px;
  border-radius: 2px;
}

/* ── Per-theme fixed palettes ─────────────────────────────────────────────
   Each swatch always renders in its OWN theme's colors, independent of the
   currently-applied site theme (data-theme on <html>). */
.theme-selector-btn[data-theme="light"] .theme-btn-preview {
  background: #fafbfc;
}

.theme-selector-btn[data-theme="light"] .theme-btn-preview-header::before {
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.theme-selector-btn[data-theme="light"] .theme-btn-preview-header::after {
  background: #6366f1;
}

.theme-selector-btn[data-theme="light"] .theme-btn-preview-row {
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.theme-selector-btn[data-theme="light"] .theme-btn-preview-row::before {
  background: #6366f1;
}

.theme-selector-btn[data-theme="light"] .theme-btn-preview-row::after {
  background: #e5e7eb;
}

.theme-selector-btn[data-theme="dark-slate"] .theme-btn-preview {
  background: #0f172a;
}

.theme-selector-btn[data-theme="dark-slate"] .theme-btn-preview-header::before {
  background: #1e293b;
  border: 1px solid #334155;
}

.theme-selector-btn[data-theme="dark-slate"] .theme-btn-preview-header::after {
  background: #818cf8;
}

.theme-selector-btn[data-theme="dark-slate"] .theme-btn-preview-row {
  background: #1e293b;
  border: 1px solid #334155;
}

.theme-selector-btn[data-theme="dark-slate"] .theme-btn-preview-row::before {
  background: #818cf8;
}

.theme-selector-btn[data-theme="dark-slate"] .theme-btn-preview-row::after {
  background: #334155;
}

.theme-selector-btn[data-theme="dark"] .theme-btn-preview {
  background: #121212;
}

.theme-selector-btn[data-theme="dark"] .theme-btn-preview-header::before {
  background: #1e1e1e;
  border: 1px solid #333333;
}

.theme-selector-btn[data-theme="dark"] .theme-btn-preview-header::after {
  background: #60a5fa;
}

.theme-selector-btn[data-theme="dark"] .theme-btn-preview-row {
  background: #1e1e1e;
  border: 1px solid #333333;
}

.theme-selector-btn[data-theme="dark"] .theme-btn-preview-row::before {
  background: #60a5fa;
}

.theme-selector-btn[data-theme="dark"] .theme-btn-preview-row::after {
  background: #333333;
}

/* Selected-state check badge (mirrors the reference design's ✓ pill) */
.theme-btn-check {
  position: absolute;
  bottom: 20px;
  inset-inline-end: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.theme-btn-check svg {
  width: 9px;
  height: 9px;
  stroke: currentColor;
  stroke-width: 3;
  fill: none;
}

.theme-selector-btn[aria-pressed="true"] .theme-btn-check {
  opacity: 1;
  transform: scale(1);
}

.theme-btn-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: center;
  padding-top: 5px;
}

.theme-selector-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Animation Toggle ────────────────────────────────────────────────────── */
.animation-toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  margin-block-end: 8px;
  margin-inline: 4px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  user-select: none;
}

.animation-toggle-container:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-primary);
}

.animation-toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 100px;
  background: var(--color-border, #ccc);
  transition: background 0.3s ease;
  flex-shrink: 0;
}

.toggle-switch.active {
  background: var(--color-primary);
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.toggle-input:checked~.toggle-switch {
  background: var(--color-primary, #4f6ef7);
}

.toggle-input:checked~.toggle-switch::after {
  left: 23px;
}

.toggle-input:focus-visible~.toggle-switch {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Responsive: Mobile (≤768px) ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
  }

  /* Slide up from BOTTOM — full-width bottom sheet */
  .sidebar {
    top: auto;
    bottom: calc(var(--bottom-nav-height, 54px) + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    width: 100% !important;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--color-border);
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(85dvh - var(--bottom-nav-height, 54px) - env(safe-area-inset-bottom, 0px));
  }

  .sidebar.expanded {
    transform: translateY(0);
    /* slide up into view */
    box-shadow: var(--shadow-xl);
    bottom: calc(var(--bottom-nav-height, 54px) + env(safe-area-inset-bottom, 0px));
  }

  /* Drag handle — real element, grabbable and draggable (see side-menu.js). */
  .sidebar-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 28px;
    flex-shrink: 0;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-drag-handle:active,
  .sidebar.dragging .sidebar-drag-handle {
    cursor: grabbing;
  }

  .sidebar-drag-handle-bar {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border);
    transition: background-color var(--duration-fast, 120ms) ease,
      width var(--duration-fast, 120ms) ease;
  }

  .sidebar-drag-handle:hover .sidebar-drag-handle-bar,
  .sidebar-drag-handle.dragging .sidebar-drag-handle-bar,
  .sidebar.dragging .sidebar-drag-handle-bar {
    background: var(--color-text-tertiary);
    width: 48px;
  }

  /* While the user is actively dragging, kill the transform transition so
     the sheet tracks the finger 1:1 with zero lag. Restored the instant the
     gesture ends (side-menu.js removes this class on pointerup). */
  .sidebar.dragging {
    transition: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    will-change: transform;
  }

  /* Sidebar header on mobile: sits above the nav, full-width, sticky with
     separator, and always visible — grabbable and draggable along with
     .sidebar-drag-handle for an expanded drag zone. */
  .sidebar .sidebar-header,
  .sidebar-header {
    display: flex !important;
    max-width: 100% !important;
    opacity: 1 !important;
    overflow: visible !important;
    pointer-events: auto !important;
    transition: none !important;
    justify-content: center;
    border-top: none;
    height: auto;
    padding: 6px 16px 10px;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 3;
    flex-shrink: 0;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar .sidebar-header:active,
  .sidebar.dragging .sidebar-header {
    cursor: grabbing;
  }

  .sidebar .sidebar-header * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  /* Always show logo in mobile sheet (expanded-only override already covers this) */
  .sidebar .sidebar-logo {
    display: flex !important;
    align-items: center;
  }

  /* Favicon and collapse button hidden on mobile — full logo always shows */
  .sidebar .sidebar-favicon,
  .sidebar-collapse-btn {
    display: none !important;
  }

  /* Full labels always visible on mobile */
  .sidebar .menu-item {
    justify-content: flex-start !important;
    padding: 11px 14px !important;
  }

  .sidebar .menu-label {
    opacity: 1 !important;
    max-width: 200px !important;
    overflow: visible !important;
    pointer-events: auto !important;
    transition: none !important;
  }

  .sidebar-expanded-only {
    opacity: 1 !important;
    max-height: 600px !important;
    overflow: visible !important;
    pointer-events: auto !important;
    transition: none !important;
  }

  .sidebar-brand-text {
    opacity: 1 !important;
    transition: none !important;
  }

  .theme-section-header {
    justify-content: center !important;
    padding: 8px 14px !important;
  }

  /* Nav: no extra top padding — logo lives in .sidebar-header now.
     nav is the single scroll owner on mobile — .sidebar itself stays
     locked (overflow: hidden, see .sidebar rule above) so its own edge
     never grows a native scrollbar. flex: 1 lets nav absorb all the
     remaining height in .sidebar's column and scroll internally, with
     .sidebar-pinned-actions flowing as nav's own last child (moved there
     in the HTML) instead of needing a second scroll region. */
  .sidebar nav {
    padding-top: 8px;
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
  }

  /* Suppress desktop tooltips on mobile */
  .sidebar-hover-tooltip {
    display: none !important;
  }

  /* The sheet opened by "المزيد" reuses the desktop sidebar's <nav>, so hide
     the 5 links that are now duplicated as their own bottom-nav tabs
     (الرئيسية / امتحان / درس / الحساب / الإعدادات). Only the leftover links
     (change name, theme, animations, contact dev, install app) remain. */
  .sidebar nav>a[href="/"],
  .sidebar nav>a[href="profile"],
  .sidebar nav>a[href="create-quiz"],
  .sidebar nav>a[href="create-lesson"],
  .sidebar nav>a[href="settings"] {
    display: none;
  }

  /* ── Bottom Navigation Bar ────────────────────────────────────────────── */
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bottom-nav-color);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    z-index: calc(var(--z-overlay, 500) + 1);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  }

  [data-theme="dark-slate"] .bottom-nav,
  [data-theme="dark"] .bottom-nav {
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 2px 0;
    background: none;
    border: none;
    text-decoration: none;
    cursor: pointer;
    color: var(--color-text-tertiary);
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    transition:
      color 0.18s ease,
      transform 0.18s ease;
  }

  .bottom-nav-item:active {
    transform: scale(0.94);
  }

  .bottom-nav-item:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    border-radius: 8px;
  }

  .bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: transform 0.18s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
  }

  .bottom-nav-label {
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Active / inactive states */
  .bottom-nav-item.active {
    color: var(--color-primary);
  }

  .bottom-nav-item.active .bottom-nav-icon {
    transform: translateY(-1px);
  }

  [data-theme="dark-slate"] .bottom-nav-item.active,
  [data-theme="dark"] .bottom-nav-item.active {
    color: var(--color-accent);
  }

  .bottom-nav-item:not(.active):hover {
    color: var(--color-text-secondary);
  }

  /* Small active-state indicator dot above the icon */
  .bottom-nav-item.active::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 3px;
    border-radius: var(--radius-full, 9999px);
    background: var(--color-primary);
  }

  [data-theme="dark"] .bottom-nav-item.active::before,
  [data-theme="dark-slate"] .bottom-nav-item.active::before {
    background: var(--color-accent);
  }

  .bottom-nav-icon-profile {
    width: 28px;
    height: 28px;
    margin-top: -3px;
    margin-bottom: -3px;
    border-radius: var(--radius-full, 9999px);
    box-shadow: var(--shadow-md);
  }

  .bottom-nav-item-profile.active {
    color: var(--color-text-tertiary);
    /* label stays neutral; icon carries the emphasis */
  }

  .bottom-nav-item-profile.active::before {
    content: none;
    /* the raised pill icon is indicator enough */
  }

  .bottom-nav-item-profile:active .bottom-nav-icon-profile {
    transform: scale(0.92);
  }

  /* Pinned bottom actions (contactDevBtn / install-app) — now nav's own
     last child (see the base .sidebar-pinned-actions rule), and the
     desktop-only sticky rule there doesn't apply under this breakpoint,
     so on mobile this simply flows as the final item in nav's single
     scroll region, right after the last menu link. */
  .sidebar-pinned-actions {
    margin-top: 4px;
  }

  .sidebar:not(.expanded) .sidebar-pinned-actions {
    /* Mobile sidebar is always full-width/expanded-style (labels visible),
       so the collapsed-rail centering variant never actually applies here
       — kept only so nothing regresses if that assumption ever changes. */
    padding: 8px;
    align-items: stretch;
  }

  /* More button opened state (drawer visible) */
  .bottom-nav-item[aria-expanded="true"] {
    color: var(--color-primary);
  }

  [data-theme="dark"] .bottom-nav-item[aria-expanded="true"],
  [data-theme="dark-slate"] .bottom-nav-item[aria-expanded="true"] {
    color: var(--color-accent);
  }
}

/* ── Reduced Motion ──────────────────────────────────────────────────────── */
html[data-motion="reduced"] .sidebar,
html[data-motion="reduced"] .toggle-switch,
html[data-motion="reduced"] .toggle-switch::after,
html[data-motion="reduced"] .side-menu-backdrop,
html[data-motion="reduced"] .menu-item,
html[data-motion="reduced"] .theme-selector-btn,
html[data-motion="reduced"] .sidebar-collapse-btn,
html[data-motion="reduced"] .sidebar-favicon,
html[data-motion="reduced"] .sidebar-favicon img,
html[data-motion="reduced"] .sidebar-favicon svg,
html[data-motion="reduced"] .sidebar-collapse-btn svg,
html[data-motion="reduced"] .menu-label,
html[data-motion="reduced"] .sidebar-expanded-only,
html[data-motion="reduced"] body {
  transition: none !important;
}

/* .menu-item svg / the icon hover+draw animation (below) are intentionally
   left out of the reduced-motion kill switch above: the sidebar and
   menu-item icon hover state stays active even under "الأداء الفائق"
   (High Performance / reduced motion) mode. */

/* ============================================================================
   User Name
   ============================================================================ */
.change-username {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.12);

  position: relative;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 2px 6px;
  border-radius: 6px;
  margin-right: 0;
  margin-left: 0;
}

/* ==================== Global Nav Avatar ==================== */
/*
 * These mirror the SVG icon they replace: same box, circular crop.
 * JS toggles which one is visible; both exist in the DOM at all times so a
 * failed avatar load (corrupt localStorage entry, decode error, etc.) can
 * fall back to the default icon without a layout shift.
 */
.menu-item-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.bottom-nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* ============================================================================
   ROLE BADGE — Admin / Developer marker on nav avatars
   ============================================================================ */
.nav-badge-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

.menu-item-avatar.nav-avatar-has-badge,
.bottom-nav-avatar.nav-avatar-has-badge {
  -webkit-mask-image: radial-gradient(circle 7px at calc(100% - 5px) calc(100% - 5px),
      transparent 99%,
      #000 100%);
  mask-image: radial-gradient(circle 7px at calc(100% - 5px) calc(100% - 5px),
      transparent 99%,
      #000 100%);
}

.nav-badge-overlay {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 14px;
  height: 14px;
  z-index: 10;
  box-sizing: border-box;
  padding: 2.5px;
  object-fit: contain;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #6d28d9);
  box-shadow: 0 2px 5px rgba(109, 40, 217, 0.4);
}

.nav-badge-overlay[data-role="admin"] {
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.4);
}

/* No ring, no hover, no idle motion, no reduced-motion override needed for
   any of it: matching .admin-gallery-badge.role-badge:hover in profile.css,
   which explicitly resets transform to none. The badge is a static marker,
   not an interactive control — same size on desktop and mobile since it was
   never inflated past a size that needed to shrink for touch/hover. */
.menu-item:hover .nav-badge-overlay,
.menu-item:focus-visible .nav-badge-overlay,
.menu-item:active .nav-badge-overlay,
.bottom-nav-item-profile:hover .nav-badge-overlay,
.bottom-nav-item-profile:focus-visible .nav-badge-overlay,
.bottom-nav-item-profile:active .nav-badge-overlay,
.nav-badge-overlay:hover {
  transform: none;
}

/* ============================================================================
   CONTACT DEVELOPER OVERLAY
   ============================================================================ */
.contact-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1100;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.contact-overlay-card {
  background: var(--color-surface);
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

.contact-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
  border-bottom: 2px solid var(--color-border);
}

.contact-overlay-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-overlay-body {
  padding: 28px;
}

.contact-overlay-desc {
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-bottom: 22px;
}

.contact-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-option-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 2px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-background);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: right;
  direction: rtl;
  font-family: "Inter", sans-serif;
}

.contact-option-btn:hover {
  
  box-shadow: var(--shadow-md);
}

.contact-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}

.contact-whatsapp .contact-option-icon {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: white;
}

.contact-whatsapp:hover {
  border-color: #25d366;
  background: rgba(37, 211, 102, 0.05);
}

.contact-telegram .contact-option-icon {
  background: linear-gradient(135deg, #2ca5e0 0%, #1a7fb5 100%);
  color: white;
}

.contact-telegram:hover {
  border-color: #2ca5e0;
  background: rgba(44, 165, 224, 0.05);
}

.contact-email .contact-option-icon {
  background: var(--gradient-accent);
  color: white;
}

.contact-email:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.contact-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.contact-option-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.contact-option-sub {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  direction: ltr;
  text-align: right;
}

.contact-overlay-footer {
  display: flex;
  justify-content: center;
  padding: 0 28px 24px;
}

.cancel-contact-overlay-button {
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  font-size: large;
}

[data-theme="dark"] .cancel-contact-overlay-button,
[data-theme="dark-slate"] .cancel-contact-overlay-button {
  color: #e8f0fe;
}

[data-theme="dark"] .contact-overlay-card,
[data-theme="dark-slate"] .contact-overlay-card {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme="dark"] .contact-overlay-header,
[data-theme="dark-slate"] .contact-overlay-header {
  border-color: var(--color-border);
}

[data-theme="dark"] .contact-option-btn,
[data-theme="dark-slate"] .contact-option-btn {
  background: var(--color-background);
  border-color: var(--color-border);
}

[data-theme="dark"] .contact-whatsapp:hover,
[data-theme="dark-slate"] .contact-whatsapp:hover {
  background: rgba(37, 211, 102, 0.08);
}

[data-theme="dark"] .contact-telegram:hover,
[data-theme="dark-slate"] .contact-telegram:hover {
  background: rgba(44, 165, 224, 0.08);
}

/* ── Lesson section navigator (lesson-section-nav.js) ───────────────────── */
.lesson-section-nav__heading {
  padding: 4px 10px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--color-text-tertiary, #888);
}

.lesson-section-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 38vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lesson-section-nav__item[hidden] {
  display: none;
}

.lesson-section-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--color-text-secondary, var(--color-text));
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: start;
  direction: rtl;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.lesson-section-nav__link:hover {
  background: var(--color-background-secondary, #f5f5f5);
}

.lesson-section-nav__link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.lesson-section-nav__dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
}

.lesson-section-nav__item.is-visited .lesson-section-nav__dot {
  background: var(--color-success, #10b981);
  border-color: var(--color-success, #10b981);
}

.lesson-section-nav__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-section-nav__time {
  flex: none;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-tertiary, #888);
}

.lesson-section-nav__item.is-active .lesson-section-nav__link {
  background: var(--color-primary-light, rgba(99, 102, 241, 0.12));
  color: var(--color-primary);
}

.lesson-section-nav__item.is-active .lesson-section-nav__dot {
  border-color: var(--color-primary);
}

/* Collapsed rail shows only the icon button; no panel. */
.sidebar:not(.expanded) .lesson-section-nav__panel {
  display: none;
}

/* Mobile: the sheet is always expanded and nav is the scroll owner, so let the
   list flow instead of nesting a second scroller. */
@media (max-width: 768px) {
  .lesson-section-nav__list { max-height: none; overflow: visible; }
}

/* Collapsed-rail icon matches the 18px theme icon (lessonIcon svgs are unsized). */
.lesson-section-nav .theme-section-header svg {
  width: 18px;
  height: 18px;
  flex: none;
}
