/* الأساسيات العامة - Mobile First & RTL */
:root {
  --primary-color: #0d5c3f;
  --primary-hover: #09472f;
  --bg-color: #f4f6f8;
  --card-bg: #ffffff;
  --text-main: #212529;
  --text-muted: #6c757d;
  --border-color: #e2e8f0;
  --header-height: 65px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-3d: 0 8px 15px -3px rgba(13, 92, 63, 0.1), 0 3px 6px -2px rgba(13, 92, 63, 0.05);
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  line-height: 1.5;
  overflow-x: hidden;
}

/* App Shell Layout */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 1. Header العلوي الثابت */
.app-header {
  height: var(--header-height);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* 2. الهيكل الداخلي */
.app-layout {
  display: flex;
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  gap: 24px;
  align-items: flex-start;
}

/* 3. الـ Sidebar الرأسي المضغوط (Compact Sidebar على اليمين) */
.app-sidebar {
  width: 220px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  padding: 12px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: calc(var(--header-height) + 24px);
  z-index: 900;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  width: 100%;
  text-align: right;
  position: relative;
}

.nav-icon {
  font-size: 1.2rem;
}

.nav-label {
  font-size: 0.9rem;
  font-weight: 600;
}

.nav-item:hover {
  background-color: #f8fafc;
  color: var(--primary-color);
  transform: translateX(-3px);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, #0a4831 100%);
  color: #ffffff;
  box-shadow: var(--shadow-3d);
  transform: translateX(-3px);
}

/* 4. منطقة المحتوى الرئيسي */
.app-content {
  flex: 1;
  min-width: 0;
  animation: smoothTransition 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.app-content.fade-in {
  animation: smoothTransition 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes smoothTransition {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Dashboard Specific Styles --- */
.dashboard-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-welcome-card {
  background: linear-gradient(135deg, var(--primary-color) 0%, #083b27 100%);
  color: #ffffff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-welcome-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.dash-date {
  font-size: 0.85rem;
  opacity: 0.9;
}

.dash-subtitle {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 4px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background-color: var(--card-bg);
  padding: 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Sections & Cards */
.dash-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  border-right: 3px solid var(--primary-color);
  padding-right: 8px;
}

.lesson-card {
  background-color: var(--card-bg);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.lesson-card.current {
  border-right: 5px solid #22c55e;
  background: linear-gradient(to left, #f0fdf4 0%, #ffffff 100%);
}

.lesson-card.upcoming {
  border-right: 5px solid #3b82f6;
}

.lesson-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lesson-student {
  font-weight: 700;
  font-size: 1rem;
}

.lesson-time {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.lesson-type {
  font-size: 0.75rem;
  background-color: #f1f5f9;
  color: var(--text-main);
  padding: 2px 8px;
  border-radius: 6px;
  width: fit-content;
  font-weight: 500;
}

/* Lessons List */
.lessons-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lesson-list-item {
  background-color: var(--card-bg);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-student {
  font-weight: 600;
  font-size: 0.95rem;
}

.item-time-type {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.badge.completed { background-color: #dcfce7; color: #166534; }
.badge.current { background-color: #fef9c3; color: #854d0e; }
.badge.upcoming { background-color: #e0f2fe; color: #0369a1; }

/* Quick Actions */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 640px) {
  .actions-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.quick-action-btn, .dash-action-btn {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.quick-action-btn:hover, .dash-action-btn:hover {
  background-color: #f8fafc;
  color: var(--primary-color);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

/* --- Students Module & Filters Styles --- */
.students-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.students-header-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 20px 24px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.students-title-area h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.students-title-area p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.primary-action-btn {
  background: linear-gradient(135deg, var(--primary-color) 0%, #0a4831 100%);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-3d);
  transition: transform 0.2s ease;
}

.primary-action-btn:hover {
  transform: translateY(-2px);
}

/* Filters Panel Styles */
.filters-panel {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-bar-wrapper {
  width: 100%;
}

.search-input, .filter-input, .filter-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  font-family: inherit;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input:focus, .filter-input:focus, .filter-select:focus {
  border-color: var(--primary-color);
}

.filters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .filters-grid {
    grid-template-columns: 1fr 1fr 1fr auto;
  }
}

.students-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 640px) {
  .students-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.student-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.student-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.student-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.student-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.student-age {
  font-size: 0.8rem;
  background-color: #f1f5f9;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.student-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.student-card-body strong {
  color: var(--text-main);
}

.student-notes {
  background-color: #f8fafc;
  padding: 6px 10px;
  border-radius: 8px;
  margin-top: 4px;
  font-size: 0.82rem;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.modal-content {
  background-color: var(--card-bg);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  animation: modalScaleUp 0.25s ease-out forwards;
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-group input, .form-group textarea {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--primary-color);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.secondary-btn {
  background-color: #f1f5f9;
  color: var(--text-main);
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn:hover {
  background-color: #e2e8f0;
}

.no-data {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 24px;
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  grid-column: 1 / -1;
}

.welcome-placeholder {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

/* تجاوب الشاشات الصغيرة (Mobile First) */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }

  .app-sidebar {
    width: 100%;
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
  }

  .sidebar-nav {
    flex-direction: row;
    width: 100%;
    gap: 4px;
  }

  .nav-item {
    flex: 1;
    justify-content: center;
    padding: 10px 8px;
    gap: 6px;
  }

  .nav-item:hover, .nav-item.active {
    transform: translateY(-2px);
  }
}
