/* =====================================================================
   styles.css — Global UI (Navbar, Sidebar, Footer & Mobile Drawer)
   ===================================================================== */

/* =====================================================================
   --- 1. ROOT VARIABLES ---
   ===================================================================== */
:root {
  --logo-hat-start: #e9d5ff;
  --logo-hat-end: var(--color-sec);
  --logo-string-start: #dbeafe;
  --logo-string-end: var(--primary-light);

  --primary: #1c3f94;
  --primary-light: #4361ee;
  --secondary: #1e293b;
  --bg-light: #f8fafc;
  --text-main: #1b263b;
  --white: #ffffff;

  --color-sec: #9c27b0;
  --color-mid: #ff9800;
  --color-pri: #4CAF50;

  --sidebar-purple-hover: #6a1b9a;
  --sidebar-orange-hover: #ef6c00;
  --sidebar-green-hover: #2e7d32;

  --header-h: 48px;
  --radius: 12px;
  --radius-lg: 20px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
  --shadow: 0 4px 15px rgba(0,0,0,0.08);
  --shadow-hover: 10px 25px rgba(0,0,0,0.12);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark-mode,
body.dark-mode {
  --bg-light: #0f172a;
  --text-main: #f1f5f9;
  --white: #1e293b;
  --secondary: #020617;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --sidebar-purple-hover: #b27ad9;
  --sidebar-orange-hover: #ffbf1d;
  --sidebar-green-hover: #44e680;
}

/* =====================================================================
   --- 2. BASE STYLES ---
   ===================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Tajawal', sans-serif;
}

body {
  background: var(--bg-light);
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

ul { list-style: none; }

a {
  text-decoration: none;
  color: inherit;
  transition: 0.2s;
}

button {
  font-family: inherit;
  cursor: pointer;
}

#navbar-slot {
  display: contents;
}

/* =====================================================================
   --- 3. HEADER & NAVBAR ---
   ===================================================================== */
.app-header {
  height: var(--header-h);
  background: var(--white);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  transition: transform 0.3s ease, background 0.3s;
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(
    to right,
    var(--color-sec),
    var(--primary-light),
    var(--color-mid),
    var(--color-pri)
  ) 1;
}

.app-header.hide-on-scroll {
  transform: translateY(-100%);
  box-shadow: none;
}

.header-container {
  width: 95%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-align: center;
  transition: transform 0.2s;
  overflow: visible;
  height: var(--header-h);
  max-height: var(--header-h);
}

.schoolep-logo {
  width: 32px;
  height: 32px;
  margin-bottom: -12px;
  flex-shrink: 0;
  transition: transform 0.4s;
  z-index: 2;
  position: relative;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 900;
  background: linear-gradient(
    to right,
    var(--color-sec),
    var(--primary-light),
    var(--color-mid),
    var(--color-pri),
    var(--color-sec)
  );
  background-size: 200% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: logo-glow-light 4s linear infinite;
  display: block;
  line-height: 1.2;
  margin-top: -2px;
  padding-bottom: 2px;
  position: relative;
  z-index: 3;
}

.dark-mode .logo-text {
  background: linear-gradient(
    to right,
    #c084fc,
    #60a5fa,
    #fbbf24,
    #4ade80,
    #c084fc
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  animation: logo-glow-dark 4s linear infinite;
}

.app-title:hover .schoolep-logo { transform: translateY(-1px) scale(1.05); }
.app-title:active { transform: scale(0.95); }

@keyframes logo-glow-light {
  0% { background-position: 0% center; }
  50% { background-position: 100% center; }
  100% { background-position: 200% center; }
}

@keyframes logo-glow-dark {
  0% { background-position: 0% center; }
  50% { background-position: 100% center; }
  100% { background-position: 200% center; }
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.action-btn,
.mobile-btn {
  background: var(--bg-light);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 0.9rem;
  transition: var(--transition);
}

.action-btn:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
}

#language-icon {
  display: block !important;
  width: 22px !important;
  height: 16px !important;
  background-size: cover !important;
  background-position: center !important;
  border-radius: 3px;
  transform: scale(0.95);
}

.desktop-nav .menu-root {
  display: flex;
  gap: 12px;
}

.menu-item {
  position: relative;
}

.menu-toggle {
  background: transparent;
  border: none;
  padding: 6px 16px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  transition: 0.3s;
  font-size: 1.1em;
}

.desktop-nav .menu-root > li:nth-child(1) .menu-toggle { color: var(--color-pri); }
.desktop-nav .menu-root > li:nth-child(2) .menu-toggle { color: var(--color-mid); }
.desktop-nav .menu-root > li:nth-child(3) .menu-toggle { color: var(--color-sec); }

.menu-toggle:hover { background: rgba(0,0,0,0.03); }
.dark-mode .menu-toggle:hover { background: rgba(255,255,255,0.05); }

.sub-menu {
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--white);
  min-width: 180px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  visibility: hidden;
  opacity: 0;
  transition: 0.3s;
  border: 1px solid rgba(0,0,0,0.05);
  z-index: 1010;
}

.sub-menu::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid var(--white);
}

.dark-mode .sub-menu::before { border-bottom-color: #1e293b; }

.sub-menu::after {
  content: "";
  position: absolute;
  top: -15px;
  left: 0;
  width: 100%;
  height: 15px;
  background: transparent;
}

[dir="ltr"] .sub-menu { right: auto; left: 50%; }

.menu-item:hover .sub-menu {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sub-menu li a {
  display: block;
  padding: 10px 20px;
  color: var(--text-main);
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  white-space: nowrap;
}

.desktop-nav .menu-root > li:nth-child(1) .sub-menu li a:hover { color: var(--color-pri); background: rgba(76, 175, 80, 0.1); }
.desktop-nav .menu-root > li:nth-child(2) .sub-menu li a:hover { color: var(--color-mid); background: rgba(255, 152, 0, 0.1); }
.desktop-nav .menu-root > li:nth-child(3) .sub-menu li a:hover { color: var(--color-sec); background: rgba(156, 39, 176, 0.1); }

/* =====================================================================
   --- 4. LAYOUT & SIDEBAR CORE ---
   ===================================================================== */
#sidebar-slot { display: contents; }

.main-wrapper {
  display: flex;
  gap: 25px;
  margin: 30px auto 0 auto;
  width: 95%;
  max-width: 1400px;
  flex: 1;
  align-items: flex-start;
}

.content-area {
  flex: 1;
  min-width: 0;
  width: 100%;
  transition: width 0.3s;
  position: relative;
  z-index: 1;
}

.levels-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 30px);
  order: -1;
  width: 215px;
  flex-shrink: 0;
  transition: width 0.3s ease;
  z-index: 600;
  overflow: visible;
}

.sidebar-card {
  background: var(--white);
  border-radius: 20px;
  padding: 16px 10px 12px 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.level-group {
  margin-bottom: 4px;
  width: 100%;
  transition: 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* =====================================================================
   --- 5. SIDEBAR TITLES (EXPANDED - COMPLETELY STATIC) ---
   ===================================================================== */
.level-group h4 {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 900;
  margin: 0 auto 12px auto;
  padding: 8px 18px;
  border-radius: 999px;
  text-align: center;
text-transform: none;
letter-spacing: 0;
  width: auto;
  min-width: 118px;
  max-width: 145px;
  white-space: nowrap;

  transition: none;
  box-shadow: none;
  cursor: default;

  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}


/* Specific Accent Borders & Colors (Light Mode) */
.level-group:nth-child(1) h4 { border-bottom: 4px solid var(--color-sec); color: var(--color-sec); }
.level-group:nth-child(2) h4 { border-bottom: 4px solid var(--color-mid); color: var(--color-mid); }
.level-group:nth-child(3) h4 { border-bottom: 4px solid var(--color-pri); color: var(--color-pri); }

/* Dark Mode Static Style Base */
html.dark-mode .level-group h4 {
  background: #1e293b;
  border: 1px solid #334155;
  border-bottom-width: 4px;
  border-bottom-style: solid;
  text-shadow: none;
  box-shadow: none;
}

/* Lighter Accent Colors for Dark Mode Contrast */
html.dark-mode .level-group:nth-child(1) h4 { border-bottom-color: #c084fc; color: #c084fc; }
html.dark-mode .level-group:nth-child(2) h4 { border-bottom-color: #fbbf24; color: #fbbf24; }
html.dark-mode .level-group:nth-child(3) h4 { border-bottom-color: #4ade80; color: #4ade80; }

/* =====================================================================
   --- 6. SIDEBAR BUTTONS (CLICKABLE) ---
   ===================================================================== */
.level-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 95%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.90rem;
  color: #fff;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.level-btn i {
  font-size: 1.15rem;
  width: 20px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}

.btn-text { transition: opacity 0.2s, width 0.2s; opacity: 1; }

.level-group:nth-child(1) .level-btn { background: var(--color-sec); }
.level-group:nth-child(1) .level-btn:hover { background: var(--sidebar-purple-hover); transform: translateY(-2px); }
.level-group:nth-child(2) .level-btn { background: var(--color-mid); }
.level-group:nth-child(2) .level-btn:hover { background: var(--sidebar-orange-hover); transform: translateY(-2px); }
.level-group:nth-child(3) .level-btn { background: var(--color-pri); }
.level-group:nth-child(3) .level-btn:hover { background: var(--sidebar-green-hover); transform: translateY(-2px); }

/* =====================================================================
   --- 7. PC COLLAPSED MODE ---
   ===================================================================== */
@media (min-width: 993px) {
  /* Shrink Sidebar */
  .levels-sidebar.pc-collapsed { width: 80px; overflow: visible; }
  .levels-sidebar.pc-collapsed .sidebar-card {
    padding: 16px 5px 12px 5px;
    overflow: visible;
  }

  /* Group Spacing */
  .levels-sidebar.pc-collapsed .level-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 15px; 
    margin-bottom: 0;
  }
  
  .levels-sidebar.pc-collapsed .level-group:first-child { margin-top: 0; }

  /* Static Mini Capsules */
  .levels-sidebar.pc-collapsed .level-group h4 {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem; 
    font-weight: 900;
text-transform: none;
letter-spacing: 0;
    width: auto;
    min-width: 60px;
    max-width: 70px;
    padding: 5px 7px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0;
    margin-bottom: 4px; 
    border-radius: 18px;
    white-space: nowrap;
    
    /* Strictly Static */
    transition: none;
    box-shadow: none;
    cursor: default;
    
    /* Light Mode */
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
  }

  .levels-sidebar.pc-collapsed .level-group:nth-child(1) h4 { border-bottom: 2px solid var(--color-sec); color: var(--color-sec); }
  .levels-sidebar.pc-collapsed .level-group:nth-child(2) h4 { border-bottom: 2px solid var(--color-mid); color: var(--color-mid); }
  .levels-sidebar.pc-collapsed .level-group:nth-child(3) h4 { border-bottom: 2px solid var(--color-pri); color: var(--color-pri); }

  html.dark-mode .levels-sidebar.pc-collapsed .level-group h4 {
    background: #0f172a;
    border: 1px solid #334155;
    border-bottom-width: 2px; 
    border-bottom-style: solid;
    text-shadow: none;
    box-shadow: none;
  }

  html.dark-mode .levels-sidebar.pc-collapsed .level-group:nth-child(1) h4 { border-bottom-color: #c084fc; color: #c084fc; }
  html.dark-mode .levels-sidebar.pc-collapsed .level-group:nth-child(2) h4 { border-bottom-color: #fbbf24; color: #fbbf24; }
  html.dark-mode .levels-sidebar.pc-collapsed .level-group:nth-child(3) h4 { border-bottom-color: #4ade80; color: #4ade80; }

  /* Center buttons */
  .levels-sidebar.pc-collapsed .level-btn {
    justify-content: center;
    width: 50px;
    height: 50px;
    padding: 0;
    margin: 5px auto; 
    border-radius: 12px;
    overflow: visible;
    position: relative;
  }
  .levels-sidebar.pc-collapsed .level-btn i { font-size: 1.4rem; margin: 0; }

  /* PERFECTLY ALIGNED TOOLTIP */
  .levels-sidebar.pc-collapsed .btn-text {
    position: absolute;
    top: 50%; 
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    background: #1e293b;
    color: #fff;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1; 
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .levels-sidebar.pc-collapsed .btn-text::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
  }

  /* DIRECTIONAL TOOLTIP LOGIC */
  [dir="rtl"] .levels-sidebar.pc-collapsed .btn-text { right: calc(100% + 15px); transform: translateY(-50%) translateX(10px); }
  [dir="rtl"] .levels-sidebar.pc-collapsed .btn-text::after { left: 100%; border-left-color: #1e293b; }
  [dir="rtl"] .levels-sidebar.pc-collapsed .level-btn:hover .btn-text { opacity: 1; visibility: visible; transform: translateY(-50%) translateX(0); }

  [dir="ltr"] .levels-sidebar.pc-collapsed .btn-text { left: calc(100% + 15px); transform: translateY(-50%) translateX(-10px); }
  [dir="ltr"] .levels-sidebar.pc-collapsed .btn-text::after { right: 100%; border-right-color: #1e293b; }
  [dir="ltr"] .levels-sidebar.pc-collapsed .level-btn:hover .btn-text { opacity: 1; visibility: visible; transform: translateY(-50%) translateX(0); }

  /* Dark Mode Tooltips */
  html.dark-mode .levels-sidebar.pc-collapsed .btn-text { background: #334155; }
  html.dark-mode[dir="rtl"] .levels-sidebar.pc-collapsed .btn-text::after, [dir="rtl"] .dark-mode .levels-sidebar.pc-collapsed .btn-text::after { border-left-color: #334155; }
  html.dark-mode[dir="ltr"] .levels-sidebar.pc-collapsed .btn-text::after, [dir="ltr"] .dark-mode .levels-sidebar.pc-collapsed .btn-text::after { border-right-color: #334155; }
}

/* =====================================================================
   --- 8. PC COLLAPSE TOGGLE BUTTON (MOVED UP TO CORNER) ---
   ===================================================================== */
.pc-collapse-btn {
  position: absolute;
  top: 2px; /* Sits perfectly on the top edge border! */
  width: 30px;
  height: 30px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 200;
  transition: var(--transition);
}

.pc-collapse-btn i { transition: transform 0.3s ease; font-size: 0.8rem; }

/* LTR (French) */
[dir="ltr"] .pc-collapse-btn { right: -15px; } /* Half outside right border */
[dir="ltr"] .pc-collapse-btn i { transform: rotate(180deg); }
[dir="ltr"] .levels-sidebar.pc-collapsed .pc-collapse-btn i { transform: rotate(0deg); }

/* RTL (Arabic) */
[dir="rtl"] .pc-collapse-btn { left: -15px; } /* Half outside left border */
[dir="rtl"] .pc-collapse-btn i { transform: rotate(0deg); }
[dir="rtl"] .levels-sidebar.pc-collapsed .pc-collapse-btn i { transform: rotate(180deg); }

.pc-collapse-btn:hover { background: var(--primary-light); transform: scale(1.1); }

/* =====================================================================
   --- 9. FOOTER ---
   ===================================================================== */
.app-footer { background: var(--secondary); color: #fff; padding: 25px 4% 15px; margin-top: 30px; }

/* PC: 4 Columns */
.footer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; max-width: 1400px; margin: 0 auto; }
.footer-col { display: flex; flex-direction: column; align-items: flex-start; text-align: start; }

/* Center the first column (Logo & Description) on all screens */
.footer-col:first-child { 
  align-items: center; 
  text-align: center; 
}
/* Force nested logo containers to center their content */
.footer-col:first-child > * {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

.footer-col h3 { margin-bottom: 12px; font-size: 1.1rem; color: #fff; display: flex; align-items: center; gap: 8px; }
.footer-col h3 i { color: var(--primary-light); }
html.dark-mode .footer-col h3 i { color: #bae6fd; }

.footer-col ul { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.footer-col ul li a { color: #cbd5e1; display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; transition: color 0.3s, transform 0.3s; }
.footer-col ul li a:hover { color: var(--white); transform: translateX(-5px); }

/* Mobile: 2 Columns (Creates a perfect 2x2 grid) */
@media (max-width: 768px) {
  .footer-grid { 
    grid-template-columns: repeat(2, 1fr); /* Forces exactly 2 items per row */
    gap: 20px 10px; 
  }
  
  .footer-col:first-child { 
    grid-column: auto; /* Ensures the logo only takes up 1 of the 2 mobile slots */
    align-items: center; 
    text-align: center; 
  }
}

.footer-bottom { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 12px; margin-top: 20px; text-align: center; color: #94a3b8; font-size: 0.8rem; }

/* FOOTER ICON DIRECTION FIX */
.footer-col ul li a i { display: inline-block; transition: transform 0.3s ease; }
[dir="ltr"] .footer-col ul li a i { transform: rotate(180deg); }
[dir="rtl"] .footer-col ul li a i { transform: rotate(0deg); }
/* =====================================================================
   --- 10. GLOBALS & OVERLAYS ---
   ===================================================================== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 1500;
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: 0.25s ease;
}

.sidebar-overlay.active { opacity: 1; visibility: visible; }
.mobile-sidebar-container.active .sidebar-overlay { opacity: 1; visibility: visible; }

/* =====================================================================
   --- 11. PRO MOBILE NAVBAR DRAWER ---
   ===================================================================== */
@media (max-width: 992px) {
  .desktop-nav { display: none; }
  .pc-collapse-btn { display: none !important; }
  .main-wrapper { flex-direction: column; align-items: stretch; margin-top: 20px; }

  .levels-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(75vw, 260px);
    background: var(--white); z-index: 2001; transform: translateX(-100%);
    transition: transform 0.3s ease; overflow-y: auto; padding-top: 20px;
    box-shadow: 10px 0 20px rgba(0,0,0,0.1);
  }

  [dir="ltr"] .levels-sidebar { left: 0; right: auto; transform: translateX(-110%); }
  [dir="rtl"] .levels-sidebar { left: auto; right: 0; transform: translateX(110%); }
  .levels-sidebar.active { transform: translateX(0); }
  .dark-mode .levels-sidebar { background: #0f172a; }

  .mobile-sidebar-container { position: fixed; inset: 0; z-index: 2000; visibility: hidden; pointer-events: none; transition: visibility 0.25s; }
  .mobile-sidebar-container.active { visibility: visible; pointer-events: auto; }

  .mobile-sidebar {
    position: absolute; top: 0; right: 0; width: min(75vw, 260px); height: 100vh;
    background: rgba(255,255,255,0.96); backdrop-filter: blur(18px);
    box-shadow: -24px 0 50px rgba(15, 23, 42, 0.18); transform: translateX(110%);
    transition: transform 0.3s cubic-bezier(.2,.8,.2,1); display: flex;
    flex-direction: column; z-index: 1600; border-left: 1px solid rgba(226, 232, 240, 0.9); overflow: hidden;
  }

  [dir="ltr"] .mobile-sidebar { right: auto; left: 0; transform: translateX(-110%); }
  .mobile-sidebar-container.active .mobile-sidebar { transform: translateX(0); }

  .drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #edf2f7; }
  .drawer-brand { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
  .brand-badge { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .drawer-brand-text { display: grid; gap: 4px; text-align: start; }
  .drawer-brand-text strong { font-size: 1.1rem; color: var(--text-main); font-weight: 800; }
  .drawer-brand-text small { color: #64748b; line-height: 1.4; font-size: 0.8rem; font-weight: 500; }
  
  .close-btn {
    width: 36px; height: 36px; border: none; border-radius: 10px; background: #f8fafc;
    color: #334155; cursor: pointer; border: 1px solid #e2e8f0; flex-shrink: 0;
    transition: 0.2s ease; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; margin-top: 4px;
  }
  .close-btn:hover { background: #f1f5f9; }

  .drawer-body { flex: 1; overflow-y: auto; padding: 12px; display: grid; gap: 6px; align-content: flex-start; }

  .quick-link {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    text-decoration: none; color: var(--text-main); background: var(--white);
    border: 1px solid #e9eef5; border-radius: 10px; padding: 6px 14px !important;
    font-weight: 700; box-shadow: 0 4px 10px rgba(15, 23, 42, 0.04); transition: 0.18s ease; font-size: 1.05rem;
  }
  .quick-link:hover { transform: translateY(-2px); border-color: #d8dee8; }
  .quick-link i { width: 22px; text-align: center; color: var(--primary); font-size: 1.05rem; }

  .accordion-list { display: grid; gap: 6px; width: 100%; }
  .accordion-item { background: rgba(255,255,255,0.94); border: 1px solid #e9eef5; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 10px rgba(15, 23, 42, 0.04); transition: 0.3s; }
  .accordion-item.active { border-color: var(--primary-light); box-shadow: 0 4px 12px rgba(67, 97, 238, 0.15); }

  .accordion-btn { width: 100%; border: none; background: transparent; padding: 6px 14px !important; display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; text-align: center; }
  .accordion-title { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 1.05rem; font-weight: 800; color: var(--text-main); }
  .accordion-btn .chevron { position: absolute; right: 14px; color: #64748b; transition: transform 0.24s ease; font-size: 0.85rem; }
  [dir="rtl"] .accordion-btn .chevron { right: auto; left: 14px; }
  .accordion-item.active .chevron { transform: rotate(180deg); color: var(--primary); }

  .accordion-content { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease; }
  .accordion-item.active .accordion-content { grid-template-rows: 1fr; }
  .accordion-content-inner { overflow: hidden; }

  .accordion-links { padding: 0 10px 10px; display: grid; gap: 4px; }
  .accordion-links a { text-decoration: none; color: #334155; background: #f8fafc; border: 1px solid #edf2f7; border-radius: 8px; padding: 6px 12px !important; font-weight: 700; transition: 0.2s ease; font-size: 1rem; text-align: center; }
  .accordion-links a:hover, .accordion-links a:active { color: var(--primary); background: #f3e8ff; border-color: #e9d5ff; }

  .accordion-list .accordion-item:nth-child(1) .accordion-title { color: var(--color-sec); }
  .accordion-list .accordion-item:nth-child(2) .accordion-title { color: var(--color-mid); }
  .accordion-list .accordion-item:nth-child(3) .accordion-title { color: var(--color-pri); }

  /* Dark mode Mobile Overrides */
  .dark-mode .mobile-sidebar { background: rgba(15, 23, 42, 0.96); border-color: #1e293b; }
  .dark-mode .drawer-head { border-color: #1e293b; }
  .dark-mode .close-btn { background: #1e293b; border-color: #334155; color: #f1f5f9; }
  .dark-mode .close-btn:hover { background: #334155; }
  .dark-mode .accordion-item { background: #0f172a; border-color: #1e293b; }
  .dark-mode .quick-link { background: #0f172a; border-color: #1e293b; color: #f1f5f9; }
  .dark-mode .accordion-links a { background: #1e293b; border-color: #334155; color: #cbd5e1; }
  .dark-mode .accordion-links a:hover { background: rgba(124, 58, 237, 0.2); border-color: var(--primary); color: #fff; }
  .dark-mode .drawer-brand-text strong { color: #f1f5f9; }
  .dark-mode .drawer-brand-text small { color: #94a3b8; }
  .dark-mode .accordion-btn .chevron { color: #94a3b8; }
  .dark-mode .accordion-title { color: #f1f5f9; }

  /* Mobile only: adapt from 180px PC sidebar */
  .levels-sidebar {
    width: min(78vw, 210px);
  }

  .levels-sidebar .sidebar-card {
    padding: 16px 10px 12px 10px;
    border-radius: 18px;
  }

  .levels-sidebar .level-group {
    width: 100%;
    align-items: center;
    margin-bottom: 4px;
  }

  .levels-sidebar .level-group h4 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 110px;
    max-width: 132px;
    margin: 0 auto 10px auto;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 900;
    letter-spacing: 0.3px;
    line-height: 1.1;
    white-space: nowrap;
    text-align: center;
  }

  .levels-sidebar .level-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    height: 38px;
    padding: 8px 10px;
    margin: 0 auto 10px auto;
    gap: 7px;
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
  }

  .levels-sidebar .level-btn i {
    font-size: 0.92rem;
    width: 17px;
    min-width: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .levels-sidebar .btn-text {
    text-align: center;
    line-height: 1;
    flex: 0 1 auto;
  }

  /* Fix collapsed sidebar on small widths too */
  .levels-sidebar.pc-collapsed .sidebar-card {
    padding: 16px 5px 12px 5px;
    overflow: visible;
    align-items: center;
  }

  .levels-sidebar.pc-collapsed .level-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 12px;
    margin-bottom: 0;
  }

  .levels-sidebar.pc-collapsed .level-group:first-child {
    margin-top: 0;
  }

  .levels-sidebar.pc-collapsed .level-group h4 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 52px;
    max-width: 62px;
    padding: 5px 7px;
    margin: 0 auto 5px auto;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.5px;
    white-space: nowrap;
  }

  .levels-sidebar.pc-collapsed .level-btn {
    justify-content: center;
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    height: 50px;
    padding: 0 !important;
    margin: 5px auto !important;
    gap: 0 !important;
    border-radius: 12px;
    overflow: visible;
    position: relative;
  }

  .levels-sidebar.pc-collapsed .level-btn i {
    font-size: 1.35rem;
    width: auto;
    min-width: 0;
    margin: 0;
  }

  .levels-sidebar.pc-collapsed .btn-text {
    position: absolute;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    background: #1e293b;
    color: #fff;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .levels-sidebar.pc-collapsed .btn-text::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
  }

  [dir="rtl"] .levels-sidebar.pc-collapsed .btn-text {
    right: calc(100% + 15px);
    transform: translateY(-50%) translateX(10px);
  }

  [dir="rtl"] .levels-sidebar.pc-collapsed .btn-text::after {
    left: 100%;
    border-left-color: #1e293b;
  }

  [dir="rtl"] .levels-sidebar.pc-collapsed .level-btn:hover .btn-text {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
  }

  [dir="ltr"] .levels-sidebar.pc-collapsed .btn-text {
    left: calc(100% + 15px);
    transform: translateY(-50%) translateX(-10px);
  }

  [dir="ltr"] .levels-sidebar.pc-collapsed .btn-text::after {
    right: 100%;
    border-right-color: #1e293b;
  }

  [dir="ltr"] .levels-sidebar.pc-collapsed .level-btn:hover .btn-text {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
  }

  html.dark-mode .levels-sidebar.pc-collapsed .btn-text {
    background: #334155;
  }

  html.dark-mode[dir="rtl"] .levels-sidebar.pc-collapsed .btn-text::after,
  [dir="rtl"] .dark-mode .levels-sidebar.pc-collapsed .btn-text::after {
    border-left-color: #334155;
  }

  html.dark-mode[dir="ltr"] .levels-sidebar.pc-collapsed .btn-text::after,
  [dir="ltr"] .dark-mode .levels-sidebar.pc-collapsed .btn-text::after {
    border-right-color: #334155;
  }
}

@media (min-width: 993px) {
  .mobile-sidebar-container,
  .mobile-btn,
  #sidebar-toggle-btn {
    display: none !important;
  }
}