:root {
  /* Core Palette - Deep, Sophisticated, Educational */
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
  --primary-glow: rgba(37, 99, 235, 0.4);

  --secondary-color: #0d9488;
  --secondary-dark: #0f766e;
  --secondary-glow: rgba(13, 148, 136, 0.4);

  --accent-gold: #fbbf24;
  --accent-rose: #f43f5e;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-light: #e2e8f0;
  --border-glow: rgba(37, 99, 235, 0.1);

  /* Modern Effects */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-premium: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Body Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background Animation */
body::before {
  content: '';
  position: fixed;
  top: -10%;
  left: -10%;
  width: 40%;
  height: 40%;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  z-index: -1;
  filter: blur(80px);
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  bottom: -10%;
  right: -10%;
  width: 40%;
  height: 40%;
  background: radial-gradient(circle, var(--secondary-glow) 0%, transparent 70%);
  z-index: -1;
  filter: blur(80px);
  pointer-events: none;
}

/* Typography Hub */
h1,
h2,
h3,
h4 {
  line-height: 1.2;
  font-weight: 800;
}

.page-title {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.page-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 600px;
  margin: 0 auto 3rem;
}

/* Premium Navigation Player Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar - Glassmorphism */
.sidebar {
  width: 300px;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-left: 1px solid var(--border-light);
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s var(--ease-in-out);
}

.sidebar-platform-label {
  font-size: 1.25rem;
  font-weight: 800;
}

.sidebar-school-name {
  font-size: 0.75rem;
  color: var(--text-light);
}

.sidebar-help-wrap {
  margin-top: auto;
  padding-top: 2rem;
}

.sidebar-help-box {
  padding: 1rem;
  background: rgba(37, 99, 235, 0.05);
  border-radius: var(--radius-md);
}

.sidebar-help-text {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.sidebar-help-link {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
}

.sidebar-help-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-help-actions .sidebar-help-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  background: #eff6ff;
}

.sidebar-help-actions .sidebar-help-link i {
  font-size: 0.9rem;
}

.sidebar-help-actions .sidebar-help-whatsapp {
  background: #ecfdf5;
  color: #16a34a;
}

.sidebar-help-actions .sidebar-help-whatsapp i {
  color: #16a34a;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
}

.sidebar-toggle-btn {
  background: white;
  border: 1px solid var(--border-light);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.main-header-right {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.main-header-greeting {
  text-align: left;
}

.main-header-greeting-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.main-header-greeting-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

.main-header-avatar {
  width: 48px;
  height: 48px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-muted);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 3rem;
  padding: 0.5rem;
}

.logo-box {
  width: 48px;
  height: 48px;
  background: var(--primary-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 8px 16px var(--primary-glow);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 700;
  transition: all 0.3s var(--ease-out);
  cursor: pointer;
}

.nav-item i {
  font-size: 1.2rem;
}

.nav-item:hover {
  background: rgba(37, 99, 235, 0.05);
  color: var(--primary-color);
  transform: translateX(-5px);
}

.nav-item.active {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 8px 16px var(--primary-glow);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 2rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Student global search */
.student-global-search {
  margin: 2rem auto 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  max-width: 900px;
  width: 100%;
}

.student-search-input-wrapper {
  position: relative;
  width: 100%;
}

.student-search-input-wrapper i {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.student-search-input-wrapper input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  padding-right: 2.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: #f8fafc;
  font-family: inherit;
  font-size: 0.95rem;
  min-height: 48px;
}

.student-search-input-wrapper input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: #ffffff;
}

.student-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  width: 100%;
}

.student-filters-label {
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.filter-chip {
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  background: #f8fafc;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.filter-chip.active {
  background: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
}

.filter-chip-reset {
  background: #f1f5f9;
}

.student-search-results {
  position: relative;
  width: 100%;
}

.student-search-results.open {
  margin-top: 0.25rem;
}

.student-search-results .search-loading,
.student-search-results .search-error,
.student-search-results .search-empty {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.student-search-results .search-loading i {
  margin-left: 0.5rem;
  color: var(--primary-color);
}

.search-result-item {
  width: 100%;
  text-align: right;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  margin-bottom: 0.25rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s var(--ease-out);
}

.search-result-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.search-result-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: right;
}

.search-result-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.search-result-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.search-result-type {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary-color);
}

/* Dashboard Cards - Premium Look */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

.premium-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: all 0.4s var(--ease-in-out);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.premium-card:hover {
  transform: translateY(-10px);
  box-shadow: var(--shadow-premium);
  border-color: var(--primary-color);
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  background: rgba(37, 99, 235, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  transition: all 0.3s var(--ease-out);
}

.premium-card:hover .card-icon {
  background: var(--primary-color);
  color: white;
  transform: rotate(-10deg) scale(1.1);
}

.card-title {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  flex: 1;
}

.card-footer {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 600;
}

.btn-arrow {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
  transition: all 0.3s var(--ease-out);
}

.premium-card:hover .btn-arrow {
  background: var(--primary-color);
  color: white;
}

/* Dashboard sections */
.dashboard-section {
  margin-bottom: 3rem;
}

.dashboard-welcome {
  margin-bottom: 2.5rem;
}

.dashboard-welcome-main {
  text-align: center;
}

.dashboard-student-name {
  color: var(--primary-color);
}

.dashboard-welcome-stats {
  margin-top: 2rem;
}

.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.dashboard-stat-card {
  padding: 1.25rem 1.5rem;
}

.dashboard-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.dashboard-stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-color);
}

.dashboard-section-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
}

.dashboard-section-header h2 {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dashboard-section-header h2 i {
  color: var(--primary-color);
}

.dashboard-section-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.dashboard-continue-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.dashboard-continue-card .btn-arrow {
  display: none;
}

.dashboard-continue-footer {
  justify-content: center;
}

.dashboard-progress-row {
  margin-top: 1rem;
}

.dashboard-progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.dashboard-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.dashboard-progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: inherit;
}

.dashboard-empty-card {
  text-align: right;
}

/* Term Organization (Tabs) */
.term-tabs {
  display: flex;
  gap: 1rem;
  background: #f1f5f9;
  padding: 0.5rem;
  border-radius: var(--radius-full);
  margin-bottom: 3rem;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.term-tab {
  padding: 0.75rem 2rem;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.term-tab.active {
  background: white;
  color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

/* Modern Unit List */
.unit-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  margin-bottom: 1rem;
  transition: all 0.3s var(--ease-out);
  cursor: pointer;
}

.unit-row:hover {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.02);
  transform: translateX(-10px);
}

.unit-number {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: var(--radius-md);
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--text-light);
  font-size: 1.25rem;
}

.unit-row:hover .unit-number {
  background: var(--primary-color);
  color: white;
}

.unit-info {
  flex: 1;
}

.unit-title {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.unit-meta {
  display: flex;
  gap: 1.5rem;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Lesson Grid */
.lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.lesson-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--border-light);
  transition: all 0.3s var(--ease-out);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lesson-card:hover {
  border-color: var(--secondary-color);
  box-shadow: var(--shadow-md);
  transform: scale(1.02);
}

.lesson-thumb {
  height: 140px;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-light);
  opacity: 0.4;
}

/* Lesson Content - Reader Focused */
.reader-container {
  max-width: 900px;
  margin: 0 auto;
  background: white;
  padding: 4rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  position: relative;
}

.reader-header {
  margin-bottom: 3rem;
  border-bottom: 2px solid var(--bg-main);
  padding-bottom: 2rem;
}

.lesson-content {
  font-size: 1.25rem;
  line-height: 2;
  color: var(--text-main);
}

.lesson-content p {
  margin-bottom: 2rem;
}

/* Animations Hub */
@keyframes slideInUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

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

.animate-up {
  animation: slideInUp 0.6s var(--ease-out) forwards;
}

/* Hide hamburger on desktop; show full nav. Show hamburger only on mobile/tablet */
#sidebarToggle {
  display: none;
}

@media (min-width: 1025px) {
  #sidebarToggle {
    display: none;
  }
}

/* Mobile and tablet: show hamburger, sidebar as overlay */
@media (max-width: 1024px) {
  #sidebarToggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    transform: translateX(100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    padding: 1.5rem;
  }

  .page-title {
    font-size: 2rem;
  }
}

/* Floating Navigation Bottom (Mobile) */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0px;
  left: 0;
  right: 0;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-light);
  padding: 0.75rem 1rem;
  justify-content: space-around;
  z-index: 100;
}

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
  }

  .reader-container {
    padding: 1.5rem;
  }

  /* Leave room for fixed mobile nav so last cards are fully visible */
  .main-content {
    padding-bottom: 5rem;
  }
}