@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

/* =========================================================
   نظام التصميم الموحّد للمنصة
   ملاحظة مهمة: كل المتغيرات والأسماء (classes/ids) القديمة
   محتفظ بيها بالكامل حتى لا يتأثر أي كود جافاسكريبت شغال.
   ========================================================= */
:root {
  --sf-primary: #4F46E5;
  --sf-primary-dark: #372FA3;
  --sf-primary-light: #EEF0FF;
  --sf-accent: #10B3A3;
  --sf-accent-light: #E6FBF6;
  --sf-warm: #F59E0B;
  --sf-warm-light: #FEF3C7;
  --sf-bg: #F5F6FC;
  --sf-text: #1E1B2E;
  --sf-muted: #6B7280;
  --sf-radius: 18px;
  --sf-radius-sm: 12px;
  --sf-shadow: 0 4px 16px rgba(49, 46, 129, 0.08);
  --sf-shadow-lg: 0 12px 30px rgba(49, 46, 129, 0.14);
  --sf-transition: 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ===== Reset & Base ===== */
* {
  font-family: 'Cairo', sans-serif;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  background: var(--sf-bg);
  color: var(--sf-text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ===== Navbar ===== */
.navbar {
  background: linear-gradient(135deg, #211D52, #3F37B8) !important;
  padding: 12px 16px !important;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

.navbar .navbar-brand {
  font-weight: 800;
  font-size: 1.02rem;
  color: #fff !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar .btn {
  font-size: 0.78rem;
  padding: 7px 12px;
  border-radius: 10px;
  font-weight: 700;
  transition: var(--sf-transition);
}

.navbar .btn-light {
  background: rgba(255,255,255,0.97);
  color: var(--sf-primary);
}

.navbar .btn-light:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.navbar .btn-outline-light {
  border-color: rgba(255,255,255,0.35);
  color: #fff;
}

.navbar .btn-outline-light:hover,
.navbar .btn-outline-light:active {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.55);
}

/* عشان الأزرار في الـ navbar على الموبايل متتزاحمش */
.navbar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

/* ===== Logo Mark ===== */
.sf-logo-mark {
  width: 30px;
  height: 30px;
  min-width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10B3A3, #4F46E5);
  border-radius: 9px;
  color: #fff;
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.35);
}

/* ===== Container ===== */
.container {
  padding-left: 16px !important;
  padding-right: 16px !important;
  max-width: 720px;
}

/* ===== Cards ===== */
.card {
  border: none;
  border-radius: var(--sf-radius);
  box-shadow: var(--sf-shadow);
  overflow: hidden;
  margin-bottom: 18px;
  transition: box-shadow var(--sf-transition);
  animation: sfCardIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

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

.card-body {
  padding: 18px;
}

.card h5, .card h6 {
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--sf-text);
  font-size: 0.98rem;
}

/* عنوان قسم بشرطة لون جانبية لإحساس أوضح بالتقسيم */
.card > .card-body > h5:first-child,
.card > .card-body > h6:first-child {
  position: relative;
  padding-right: 12px;
}
html[dir="rtl"] .card > .card-body > h5:first-child::before,
html[dir="rtl"] .card > .card-body > h6:first-child::before {
  content: "";
  position: absolute;
  right: 0; top: 2px; bottom: 2px;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--sf-accent), var(--sf-primary));
}
html[dir="ltr"] .card > .card-body > h5:first-child,
html[dir="ltr"] .card > .card-body > h6:first-child {
  padding-right: 0;
  padding-left: 12px;
}
html[dir="ltr"] .card > .card-body > h5:first-child::before,
html[dir="ltr"] .card > .card-body > h6:first-child::before {
  content: "";
  position: absolute;
  left: 0; top: 2px; bottom: 2px;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--sf-accent), var(--sf-primary));
}

/* ===== بطاقة بيانات الطالب ===== */
.card-body.row {
  margin: 0;
}

.card-body.row .col-md-3 {
  padding: 0;
  margin-bottom: 12px;
}

.card-body.row .col-md-9 {
  padding: 0;
}

.card-body.row .col-md-3 img {
  max-width: 120px !important;
  border-radius: 10px;
}

.card-body.row p {
  font-size: 0.88rem;
  margin-bottom: 6px;
}

/* ===== Buttons ===== */
.btn {
  border-radius: var(--sf-radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 18px;
  transition: transform 0.15s ease, box-shadow var(--sf-transition), background var(--sf-transition);
  min-height: 44px;
  border-width: 1.5px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--sf-primary), var(--sf-primary-dark));
  border-color: var(--sf-primary-dark);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.btn-primary:hover, .btn-primary:active {
  background: linear-gradient(135deg, var(--sf-primary-dark), var(--sf-primary-dark));
  border-color: var(--sf-primary-dark);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.btn-success {
  background: linear-gradient(135deg, var(--sf-accent), #0d8f83);
  border-color: #0d8f83;
  box-shadow: 0 4px 12px rgba(16, 179, 163, 0.28);
}

.btn-success:hover, .btn-success:active {
  background: linear-gradient(135deg, #0d8f83, #0b7b70);
  border-color: #0b7b70;
}

.btn-outline-primary {
  border-width: 1.5px;
}

/* ===== Badges ===== */
.badge {
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.76rem;
  padding: 5px 10px;
  letter-spacing: 0.2px;
}

/* ===== Tables ===== */
.table-responsive {
  border-radius: var(--sf-radius-sm);
  overflow: hidden;
}

.table {
  font-size: 0.84rem;
  margin-bottom: 0;
}

.table thead th {
  background: var(--sf-primary-light);
  color: var(--sf-primary-dark);
  font-weight: 800;
  font-size: 0.8rem;
  border: none;
  padding: 12px 10px;
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
  padding: 10px;
  border-color: #F3F4F6;
  font-size: 0.84rem;
}

/* تلميح لطيف لتنبيه المستخدم أن الجدول يمكن تحريكه لليمين والشمال على الموبايل */
.table-responsive {
  position: relative;
}
.table-responsive::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  inset-inline-end: 0;
  width: 22px;
  pointer-events: none;
  background: linear-gradient(to left, rgba(0,0,0,0.06), transparent);
}
html[dir="ltr"] .table-responsive::after {
  background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
}

/* ===== Forms ===== */
.form-control, .form-select {
  border-radius: var(--sf-radius-sm);
  border: 1.5px solid #E2E4F3;
  font-size: 0.92rem;
  padding: 11px 14px;
  min-height: 46px;
  transition: border-color var(--sf-transition), box-shadow var(--sf-transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--sf-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-label {
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--sf-text);
}

/* ===== List Groups ===== */
.list-group-item {
  padding: 12px 14px;
  font-size: 0.86rem;
  border-color: #F3F4F6;
}

/* ===== كروت الدروس ===== */
.lesson-card {
  cursor: pointer;
  transition: transform var(--sf-transition), box-shadow var(--sf-transition);
  border-radius: var(--sf-radius) !important;
  border-top: 4px solid var(--sf-accent) !important;
  margin-bottom: 12px;
}

.lesson-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--sf-shadow-lg) !important;
}
.lesson-card:active {
  transform: translateY(-1px) scale(0.99);
}

.lesson-card .card-body {
  padding: 15px;
}

.lesson-card h6 {
  font-size: 0.92rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--sf-text);
  line-height: 1.4;
}

/* ===== Alert ===== */
.alert {
  border-radius: var(--sf-radius-sm);
  font-size: 0.88rem;
  padding: 13px 15px;
  border: none;
}

.alert-warning {
  background: var(--sf-warm-light);
  color: #92400E;
}

.alert-danger {
  background: #FEE2E2;
  color: #B91C1C;
}

.alert-success {
  background: var(--sf-accent-light);
  color: #0b7b70;
}

.alert-secondary {
  background: #EEF0FB;
  color: #3730A3;
}

/* ===== صفحة Login ===== */
.login-card {
  border: none;
  border-radius: 22px;
  box-shadow: 0 24px 55px rgba(30,27,75,0.28);
}

/* ===== لوحة الصدارة ===== */
#pointsBox .row {
  margin: 0 -6px;
}

#pointsBox .col-6 {
  padding: 0 6px;
}

#pointsBox .col-6 > div {
  border-radius: var(--sf-radius-sm);
  padding: 14px 10px !important;
}

/* ===== مشغل الفيديو ===== */
video {
  border-radius: var(--sf-radius-sm);
  width: 100%;
  max-height: 280px;
  background: #000;
}

iframe {
  border-radius: var(--sf-radius-sm);
}

/* ===== أزرار التنقل بين أجزاء الفيديو ===== */
#prevPartBtn, #nextPartBtn {
  font-size: 0.82rem;
  padding: 6px 12px;
}

#partIndicator {
  font-size: 0.82rem;
  color: var(--sf-muted);
}

/* ===== تبويبات الفيديو (شرح/أسئلة/حل) ===== */
.btn-group {
  border-radius: var(--sf-radius-sm);
  overflow: hidden;
}

.btn-group .btn {
  font-size: 0.82rem;
  padding: 8px 10px;
  min-height: 38px;
  border-radius: 0 !important;
}

/* ===== QR Code ===== */
#qrImage {
  max-width: 130px !important;
  border-radius: 12px;
  border: 3px solid var(--sf-primary-light);
  padding: 4px;
}

/* ===== py-4 تصغير على موبايل ===== */
.py-4 {
  padding-top: 14px !important;
  padding-bottom: 14px !important;
}

/* =========================================================
   عناصر مساعدة جديدة للتصميم "الحيوي" وسهولة الاستخدام
   (كل ما يلي إضافات جديدة بالكامل ولا تتعارض مع أي كلاس قديم)
   ========================================================= */

/* تلميحة صغيرة ودّية (لأولياء الأمور خصوصاً) */
.hint-text {
  background: var(--sf-primary-light);
  color: var(--sf-primary-dark);
  border-radius: var(--sf-radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
}

/* صندوق "اعرف أكتر" القابل للطي — تفاصيل بديهية بدون جافاسكريبت */
details.sf-more {
  background: #fff;
  border: 1px solid #ECEDF7;
  border-radius: var(--sf-radius-sm);
  margin-top: 10px;
  overflow: hidden;
}
body.dark-theme details.sf-more {
  background: transparent;
  border-color: var(--dark-border, #334155);
}
details.sf-more summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--sf-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
details.sf-more summary::-webkit-details-marker { display: none; }
details.sf-more summary::after {
  content: "⌄";
  font-size: 1.1rem;
  transition: transform 0.25s ease;
  color: var(--sf-muted);
}
details.sf-more[open] summary::after {
  transform: rotate(180deg);
}
details.sf-more .sf-more-body {
  padding: 0 14px 14px;
  font-size: 0.84rem;
  color: var(--sf-muted);
  line-height: 1.8;
}

/* حركة نبض خفيفة لجذب الانتباه لعنصر مهم مرة عند ظهوره */
@keyframes sfPulseOnce {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.35); }
  70% { box-shadow: 0 0 0 10px rgba(79, 70, 229, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}
.sf-attn {
  animation: sfPulseOnce 1.8s ease-out 1;
}

/* أشكال خلفية هلامية عامة قابلة لإعادة الاستخدام */
.sf-bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: -1;
  opacity: 0.22;
  animation: sfFloat 7s ease-in-out infinite;
}
@keyframes sfFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(22px); }
}

/* ===== Utilities ===== */
.text-success { color: #0d8f6e !important; }
.text-danger { color: #DC2626 !important; }
.text-muted { color: var(--sf-muted) !important; font-size: 0.82rem; }
.fw-bold { font-weight: 700 !important; }
.small { font-size: 0.82rem !important; }

a { text-decoration: none; }

/* ===== Responsive: موبايل صغير (أقل من 400px) ===== */
@media (max-width: 400px) {
  html { font-size: 14px; }

  .navbar .btn { font-size: 0.72rem; padding: 5px 8px; }

  .btn-group .btn { font-size: 0.75rem; padding: 6px 6px; }

  .table { font-size: 0.78rem; }
  .table thead th { font-size: 0.74rem; padding: 9px 6px; }
  .table td { padding: 7px 6px; }

  .card-body { padding: 14px; }

  video { max-height: 220px; }
}

/* ===== Responsive: تابلت ===== */
@media (min-width: 576px) {
  .container { padding-left: 22px !important; padding-right: 22px !important; }

  .card-body { padding: 22px; }

  video { max-height: 360px; }

  .table { font-size: 0.9rem; }
  .table thead th { font-size: 0.84rem; }
}

/* ===== Safe Area لـ iPhone X وما فوق ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .navbar {
    padding-top: max(10px, env(safe-area-inset-top)) !important;
  }
}

/* تقليل الحركة لمن يفضّل ذلك (إمكانية وصول أفضل) */
@media (prefers-reduced-motion: reduce) {
  *, .card, .btn, .lesson-card {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}
