:root {
  --primary-color: #00b894; /* أخضر زمردي */
  --primary-dark: #00896f;
  --bg-gradient: linear-gradient(135deg, #f6f8f9 0%, #e5ebee 100%);
  --card-bg: rgba(255, 255, 255, 0.95); /* خلفية شبه شفافة */
  --text-color: #2d3436;
  --text-light: #636e72;
  --accent-color: #fdcb6e;
  --shadow-soft: 0 20px 40px rgba(0,0,0,0.06);
  --shadow-sharp: 0 10px 25px rgba(0,0,0,0.1);
  --radius-lg: 24px;
  --radius-sm: 12px;
}

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

body { 
  font-family: 'Cairo', 'Segoe UI', sans-serif; 
  background: var(--bg-gradient); 
  color: var(--text-color);
  min-height: 100vh; 
  padding: 20px; 
  line-height: 1.6;
}

.container { max-width: 1400px; margin: 0 auto; }

/* --- Header Styles --- */
header { 
  text-align: center; 
  margin-bottom: 40px; 
  padding: 50px 20px;
  background: var(--card-bg);
  backdrop-filter: blur(10px); /* تأثير الزجاج */
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255,255,255,0.6);
  position: relative;
  overflow: hidden;
}

h1 { 
  font-size: 2.8em; 
  background: linear-gradient(45deg, var(--primary-dark), var(--primary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 15px; 
  font-weight: 800;
  letter-spacing: -1px;
}

.subtitle { 
  font-size: 1.2em; 
  color: var(--text-light); 
  font-weight: 600;
}

.header-actions {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
}

.header-button {
  border: none;
  border-radius: 50px;
  padding: 12px 28px;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.header-button.primary {
  background: var(--primary-color);
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 184, 148, 0.3);
}

.header-button.secondary {
  background: #fff;
  color: var(--text-color);
  border: 1px solid #eee;
}

.header-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

/* --- Grid Styles --- */
.lessons-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
  gap: 30px; 
  margin-bottom: 40px; 
}

.lesson-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  transition: all 0.4s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  padding: 30px;
  border: 1px solid rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 220px;
}

.lesson-card:hover { 
  transform: translateY(-10px) scale(1.02); 
  box-shadow: 0 30px 60px rgba(0,0,0,0.12); 
}

.lesson-number {
  font-size: 2em;
  font-weight: 900;
  color: rgba(0, 184, 148, 0.1);
  position: absolute;
  top: 15px;
  right: 20px;
  transition: 0.3s;
}

.lesson-card:hover .lesson-number {
  color: var(--primary-color);
  transform: scale(1.1);
}

.lesson-title { 
  font-size: 1.5em; 
  color: var(--text-color); 
  margin-top: 40px;
  margin-bottom: 10px; 
  font-weight: 700; 
  position: relative;
  z-index: 2;
}

.audio-count { 
  color: var(--text-light); 
  font-size: 0.9em; 
  background: #f1f2f6;
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
  font-weight: 600;
}

/* --- Modal Styles (Improved) --- */
.modal { 
  display: none; 
  position: fixed; 
  z-index: 1000; 
  left: 0; top: 0; 
  width: 100%; height: 100%; 
  background-color: rgba(0, 0, 0, 0.4); 
  backdrop-filter: blur(8px); /* تعتيم الخلفية */
  justify-content: center;
  align-items: center;
  padding: 0;
}

/* تحسين شكل نافذة الدرس لتكون أكبر */
.modal-content {
  background-color: #fff;
  border-radius: var(--radius-lg);
  width: 98%;
  max-width: 1600px;
  height: 95vh; /* ارتفاع ثابت تقريباً */
  max-height: 95vh;
  margin: 0; /* إزالة الهوامش الخارجية للتمركز */
  box-shadow: 0 25px 80px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  position: relative;
  animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header { 
  padding: 25px 40px; 
  border-bottom: 1px solid #f0f0f0;
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 10;
}

.modal-title-group h2 {
  color: var(--primary-dark);
  font-size: 2em;
  font-weight: 800;
}

.close { 
  background: #f1f2f6;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-color); 
  font-size: 28px; 
  cursor: pointer; 
  transition: all 0.2s;
}

.close:hover { 
  background: #ff7675; 
  color: white; 
  transform: rotate(90deg);
}

.modal-body { 
  padding: 0 40px 40px 40px; 
  overflow-y: auto; /* التمرير داخل الجسم فقط */
  flex: 1;
}

/* Scrollbar Customization */
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-track { background: #f1f1f1; }
.modal-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }

/* --- Tabs Design --- */
.tab-container { 
  display: flex; 
  justify-content: center; 
  gap: 10px; 
  margin: 30px auto; 
  background: #f8f9fa;
  padding: 8px;
  border-radius: 60px;
  width: fit-content;
  border: 1px solid #eee;
}

.tab { 
  padding: 12px 35px; 
  cursor: pointer; 
  border: none; 
  background: transparent; 
  font-size: 1.05em; 
  color: var(--text-light); 
  border-radius: 50px; 
  transition: all 0.3s; 
  font-weight: 700;
}
    
.tab.active { 
  background: #fff;
  color: var(--primary-color); 
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* --- Content Styles --- */
.tab-content { display: none; animation: fadeIn 0.5s ease; padding-top: 10px; }
.tab-content.active { display: block; }

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

.audio-section {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 25px;
  margin-bottom: 25px;
  border: 1px solid #edf2f7;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
  transition: transform 0.2s;
}
    
.audio-section:hover {
  transform: translateY(-2px);
  border-color: var(--primary-color);
}

.audio-label { 
  font-weight: 700; 
  color: var(--text-color); 
  margin-bottom: 15px; 
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.audio-with-image { 
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid #eee;
}

.lesson-image { 
  width: 100%; 
  display: block; 
}

audio { 
  width: 100%; 
  height: 45px;
  border-radius: 30px; 
}

/* --- Note Area --- */
.text-content {
  background-color: #fff;
  border: 2px dashed #e1e1e1;
  padding: 40px;
  border-radius: var(--radius-sm);
  min-height: 50vh;
  font-size: 1.15em;
  line-height: 2;
  color: #333;
  outline: none;
  background-image: linear-gradient(to bottom, #f9f9f9 1px, transparent 1px);
  background-size: 100% 2.4em;
  line-height: 2.4em;
  transition: border-color 0.3s;
}

.text-content:focus { border-color: var(--primary-color); }

/* --- Responsive (Mobile Optimization) --- */
@media (max-width: 768px) {
  body { padding: 15px; }
  
  h1 { font-size: 2em; }
  
  /* جعل النافذة تملأ الشاشة بالكامل في الموبايل */
  .modal { 
    align-items: flex-end; /* أو center حسب الرغبة */
  }

  .modal-content { 
    width: 100%; 
    height: 100%; /* ملء الشاشة */
    max-height: 100%;
    border-radius: 0; /* إزالة الحواف الدائرية */
    display: flex;
    flex-direction: column;
  }
  
  .modal-header {
    border-radius: 0;
    padding: 15px 20px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  }

  .modal-title-group h2 { font-size: 1.5em; }
  .modal-body { padding: 20px; }
  
  .tab-container { 
    width: 100%; 
    overflow-x: auto; 
    justify-content: flex-start; 
    border-radius: 15px;
    padding: 5px;
  }
  
  .tab { white-space: nowrap; padding: 10px 20px; font-size: 0.9em; }
}

/* --- PDF & Misc --- */
.pdf-viewer-iframe {
  width: 100%;
  height: 75vh;
  border: none;
  border-radius: var(--radius-sm);
}

/* Image Modal */
.image-modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); }
.image-modal img { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 95%; max-height: 95%; }
.image-arrow {
        position: absolute;
        width: 40px; height: 40px;
        color: #e74c3c;
        z-index: 100;
        pointer-events: none;
        filter: drop-shadow(0px 4px 6px rgba(0,0,0,0.3));
        transition: left 0.8s cubic-bezier(0.25, 1, 0.5, 1), top 0.8s cubic-bezier(0.25, 1, 0.5, 1);
        transform: translate(-50%, -50%) rotate(90deg); 
        transform-origin: center center;
    }

/* --- Flashcards Styles --- */
.flashcards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding: 20px 0;
  justify-items: center;
}

/* Colors from fla.html */
.bg-blue { background-color: #E3F2FD; border-color: #BBDEFB; }
.bg-green { background-color: #E8F5E9; border-color: #C8E6C9; }
.bg-yellow { background-color: #FFFDE7; border-color: #FFF9C4; }
.bg-pink { background-color: #FCE4EC; border-color: #F8BBD0; }
.bg-purple { background-color: #F3E5F5; border-color: #E1BEE7; }
.bg-orange { background-color: #FFF3E0; border-color: #FFE0B2; }

.flashcard {
  background-color: transparent;
  width: 240px;
  height: 300px;
  perspective: 1000px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.flashcard:hover {
  transform: scale(1.02);
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  box-shadow: 0 10px 20px rgba(0,0,0,0.08);
  border-radius: 20px;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 15px;
  border: 4px solid white; /* Adapted from fla.html */
  box-sizing: border-box;
}

.flashcard-front {
  color: #333;
}

.flashcard-back {
  transform: rotateY(180deg);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  height: 40px;
}

.hanzi-large {
  font-family: 'Ma Shan Zheng', 'Noto Sans SC', cursive;
  font-size: 3.5rem;
  line-height: 1.2;
  color: #333;
  margin: 5px 0;
  font-weight: normal;
}

.pinyin {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.5rem;
  color: #666;
  margin-bottom: 10px;
  font-weight: 700;
}

.translation {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.1rem;
  color: #888;
  font-weight: 500;
}

.flashcard-hint {
  position: absolute;
  bottom: 15px;
  font-size: 0.8rem;
  color: rgba(0,0,0,0.3);
  font-family: 'Tajawal', sans-serif;
}
