/* SchoolEP V229.10 — exact Level-3 sidebar first-paint/state CSS reused by Level-4. */
/* =====================================================================
   Shared shell stability guard — v20260603-sidebar-footer-stable
   ---------------------------------------------------------------------
   Prevents the desktop resource sidebar from painting expanded for one
   frame before script.js hydrates it. Default = closed/collapsed.
   If localStorage says the user opened it, the shared shell adds the
   expanded class before writing the sidebar HTML.
   ===================================================================== */
@media (min-width: 993px) {
  html.schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) {
    width: 80px !important;
    overflow: visible !important;
  }

  html.schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) .sidebar-card {
    padding: 16px 5px 12px 5px !important;
    overflow: visible !important;
  }

  html.schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) .level-group {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    margin-top: 15px !important;
    margin-bottom: 0 !important;
  }

  html.schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) .level-group:first-child {
    margin-top: 0 !important;
  }

  html.schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) .level-group h4 {
    width: auto !important;
    min-width: 60px !important;
    max-width: 70px !important;
    padding: 5px 7px !important;
    margin: 0 auto 4px auto !important;
    border-radius: 18px !important;
    font-size: var(--sidebar-title-pc-collapsed-ar-font-size, 1.00rem) !important;
    white-space: nowrap !important;
  }

  html[dir="ltr"].schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) .level-group h4 {
    font-size: var(--sidebar-title-pc-collapsed-fr-font-size, 0.82rem) !important;
  }

  html.schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) .level-btn {
    justify-content: center !important;
    width: 50px !important;
    height: 50px !important;
    padding: 0 !important;
    margin: 5px auto !important;
    border-radius: 12px !important;
    overflow: visible !important;
    position: relative !important;
  }

  html.schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) .level-btn i {
    font-size: 1.4rem !important;
    margin: 0 !important;
  }

  html.schoolep-sidebar-boot:not(.schoolep-shell-sidebar-expanded) .levels-sidebar:not(.pc-collapsed) .btn-text {
    opacity: 0 !important;
    visibility: hidden !important;
  }
}


/* =====================================================================
   Global sidebar state guard — v20260617-no-flicker-v2
   ---------------------------------------------------------------------
   The sidebar follows one saved state across pages like language/dark mode.
   These selectors let the html boot class control the drawer before JS
   finishes hydrating the component, preventing close/open flicker.
   ===================================================================== */
@media (max-width: 992px) {
  html.resource-sidebar-open #sidebar-slot .levels-sidebar,
  body.resource-sidebar-open #sidebar-slot .levels-sidebar,
  html.resource-sidebar-open .levels-sidebar,
  body.resource-sidebar-open .levels-sidebar {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  html.resource-sidebar-open #levels-overlay,
  body.resource-sidebar-open #levels-overlay {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

@media (min-width: 993px) {
  html.schoolep-sidebar-boot.schoolep-shell-sidebar-expanded .levels-sidebar {
    width: 215px !important;
  }

  html.schoolep-sidebar-boot.schoolep-shell-sidebar-collapsed .levels-sidebar {
    width: 80px !important;
  }
}


/* =====================================================================
   SIDEBAR GLOBAL STATE — FIRST PAINT LOCK (v3)
   One localStorage-controlled sidebar state across all pages.
   Prevents desktop open→close and mobile close→open flashes on reload/back.
   ===================================================================== */
html.schoolep-sidebar-boot .levels-sidebar,
html.schoolep-sidebar-boot .levels-sidebar *,
html.schoolep-sidebar-boot #sidebar-slot,
html.schoolep-sidebar-boot #sidebar-slot * {
  transition: none !important;
  animation: none !important;
}

@media (min-width: 993px) {
  html.schoolep-shell-sidebar-collapsed .levels-sidebar {
    width: 80px !important;
    overflow: visible !important;
  }

  html.schoolep-shell-sidebar-expanded .levels-sidebar {
    width: 215px !important;
  }

  html.schoolep-shell-sidebar-collapsed .levels-sidebar .sidebar-card {
    padding: 16px 5px 12px 5px !important;
    overflow: visible !important;
  }

  html.schoolep-shell-sidebar-collapsed .levels-sidebar .level-group {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    margin-top: 15px !important;
    margin-bottom: 0 !important;
  }

  html.schoolep-shell-sidebar-collapsed .levels-sidebar .level-group:first-child {
    margin-top: 0 !important;
  }

  html.schoolep-shell-sidebar-collapsed .levels-sidebar .level-group h4 {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: var(--sidebar-title-pc-collapsed-ar-font-size, 1.00rem) !important;
    font-weight: 900 !important;
    width: auto !important;
    min-width: 60px !important;
    max-width: 70px !important;
    padding: 5px 7px !important;
    margin: 0 auto 4px auto !important;
    border-radius: 18px !important;
    white-space: nowrap !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
  }

  html[dir="ltr"].schoolep-shell-sidebar-collapsed .levels-sidebar .level-group h4,
  body[dir="ltr"].schoolep-shell-sidebar-collapsed .levels-sidebar .level-group h4 {
    font-size: var(--sidebar-title-pc-collapsed-fr-font-size, 0.82rem) !important;
  }

  html.schoolep-shell-sidebar-collapsed .levels-sidebar .level-btn {
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    justify-content: center !important;
    gap: 0 !important;
    overflow: visible !important;
  }

  html.schoolep-shell-sidebar-collapsed .levels-sidebar .level-btn i {
    font-size: 1.4rem !important;
    margin: 0 !important;
  }

  html.schoolep-shell-sidebar-collapsed .levels-sidebar .btn-text {
    position: absolute !important;
    top: 50% !important;
    width: max-content !important;
    max-width: 220px !important;
    padding: 8px 12px !important;
    border-radius: 10px !important;
    background: #1e293b !important;
    color: #fff !important;
    font-size: 0.85rem !important;
    line-height: 1.2 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: 9999 !important;
    white-space: nowrap !important;
  }

  html[dir="rtl"].schoolep-shell-sidebar-collapsed .levels-sidebar .btn-text,
  body[dir="rtl"].schoolep-shell-sidebar-collapsed .levels-sidebar .btn-text {
    right: calc(100% + 15px) !important;
    transform: translateY(-50%) translateX(10px) !important;
  }

  html[dir="ltr"].schoolep-shell-sidebar-collapsed .levels-sidebar .btn-text,
  body[dir="ltr"].schoolep-shell-sidebar-collapsed .levels-sidebar .btn-text {
    left: calc(100% + 15px) !important;
    transform: translateY(-50%) translateX(-10px) !important;
  }

  html[dir="rtl"].schoolep-shell-sidebar-collapsed .levels-sidebar .level-btn:hover .btn-text,
  body[dir="rtl"].schoolep-shell-sidebar-collapsed .levels-sidebar .level-btn:hover .btn-text,
  html[dir="ltr"].schoolep-shell-sidebar-collapsed .levels-sidebar .level-btn:hover .btn-text,
  body[dir="ltr"].schoolep-shell-sidebar-collapsed .levels-sidebar .level-btn:hover .btn-text {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(-50%) translateX(0) !important;
  }
}

@media (max-width: 992px) {
  html.schoolep-sidebar-boot .levels-sidebar,
  html.schoolep-sidebar-boot .levels-sidebar * {
    transition: none !important;
    animation: none !important;
  }

  html:not(.resource-sidebar-open) #sidebar-slot .levels-sidebar:not(.active) {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  html.resource-sidebar-open #sidebar-slot .levels-sidebar,
  body.resource-sidebar-open #sidebar-slot .levels-sidebar {
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
  }
}
