/* ==========================================================================
   منصة أروى التعليمية & قسم Bint El-Shemy
   نظام وتنسيق بطاقات المراجعة التفاعلية الموحد (Cards Theme)
   الهوية البصرية الرسمية: Study Buddy — Teen Edition
   ========================================================================== */

@import url("variables.css");
@import url("base.css");
@import url("components.css");

/* ── 1. الحاوية والصفحة الأساسية ── */
body {
  background-color: var(--cream);
  color: var(--deep-navy);
  font-family: var(--font-family);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.cards-page-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ── 2. ترويسة الصفحة والتنقل السريع (Header & Breadcrumbs) ── */
.cards-header {
  text-align: center;
  padding: 32px 24px 28px;
  margin-bottom: 24px;
  background: radial-gradient(circle at 50% 20%, rgba(235, 241, 246, 0.9) 0%, rgba(248, 243, 234, 0.6) 80%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.header-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.btn-back-portal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background-color: var(--white);
  color: var(--deep-navy);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--beige-mid);
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-subtle);
}

.btn-back-portal:hover {
  background-color: var(--dusty-blue);
  color: var(--pure-white);
  border-color: var(--dusty-blue);
  transform: translateX(3px);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background-color: rgba(127, 155, 181, 0.12);
  border: 1px solid var(--dusty-blue-border);
  border-radius: var(--radius-full);
  color: var(--dusty-blue-dark);
  font-size: 0.85rem;
  font-weight: 700;
}

.cards-header h1 {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--deep-navy);
  margin: 10px 0 8px;
  letter-spacing: -0.5px;
}

.cards-header .subtitle {
  font-size: 1.05rem;
  color: var(--navy-light);
  max-width: 720px;
  margin: 0 auto;
}

/* ── 3. شريط تقدم الإتقان والمذاكرة (Mastery Progress Bar) ── */
.mastery-tracker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-subtle);
}

.mastery-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mastery-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--deep-navy);
}

.mastery-badge i {
  color: var(--soft-orange);
}

.mastery-progress-track {
  flex: 1;
  min-width: 180px;
  height: 10px;
  background: var(--beige-light);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.mastery-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--dusty-blue), var(--success));
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
  width: 0%;
}

.mastery-stats-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy-muted);
}

/* ── 4. لوحة التحكم والبحث الذكي (Control Panel) ── */
.controls-panel {
  background: var(--white);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.controls-row-top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-wrapper svg.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  fill: var(--navy-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 42px 12px 36px;
  font-family: var(--font-family);
  font-size: 0.95rem;
  border: 1.5px solid var(--beige-mid);
  border-radius: var(--radius-full);
  background: var(--cream-light);
  color: var(--deep-navy);
  outline: none;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.search-input:focus {
  border-color: var(--dusty-blue);
  background: var(--white);
  box-shadow: 0 0 0 4px var(--dusty-blue-glow);
}

.search-clear-btn {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--navy-muted);
  cursor: pointer;
  padding: 4px;
  display: none;
  font-size: 0.9rem;
}

.search-clear-btn.visible {
  display: block;
}

.counter-badge {
  background: var(--dusty-blue-light);
  border: 1px solid var(--dusty-blue-border);
  color: var(--deep-navy);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.counter-badge span {
  color: var(--dusty-blue-dark);
}

/* ── 5. الفلاتر وأزرار الـ Pills ── */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 7px 15px;
  background: var(--cream-light);
  border: 1px solid var(--beige-mid);
  border-radius: var(--radius-full);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--deep-navy);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.pill:hover {
  background: var(--dusty-blue-light);
  border-color: var(--dusty-blue);
  color: var(--deep-navy);
  transform: translateY(-1px);
}

.pill.active {
  background: var(--dusty-blue);
  border-color: var(--dusty-blue);
  color: var(--pure-white);
  box-shadow: 0 2px 8px var(--dusty-blue-glow);
}

.pill-fav {
  border-color: var(--baby-pink-border);
}

.pill-fav.active {
  background: #E57373;
  border-color: #E57373;
  color: var(--pure-white);
}

.pill-mastered.active {
  background: var(--success);
  border-color: var(--success);
  color: var(--pure-white);
}

/* ── 6. شريط الأدوات السريعة للمذاكرة (Action Bar) ── */
.quick-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--beige-light);
}

.actions-left, .actions-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--cream-light);
  border: 1px solid var(--beige-mid);
  color: var(--deep-navy);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action:hover {
  background: var(--dusty-blue-light);
  border-color: var(--dusty-blue);
  color: var(--deep-navy);
}

.btn-action-primary {
  background: var(--dusty-blue);
  border-color: var(--dusty-blue);
  color: var(--pure-white);
}

.btn-action-primary:hover {
  background: var(--dusty-blue-hover);
  color: var(--pure-white);
}

/* ── 7. شبكة عرض البطاقات (3D Cards Grid) ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 22px;
  margin-top: 20px;
}

.card-container {
  perspective: 1200px;
  -webkit-perspective: 1200px;
  min-height: 380px;
  display: block;
  width: 100%;
}

.cards-grid .card,
.focus-card-wrapper .card,
.card-container .card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d !important;
  -webkit-transform-style: preserve-3d !important;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border-radius: var(--radius-lg);
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
  display: block !important;
}

.cards-grid .card.flipped,
.focus-card-wrapper .card.flipped,
.card-container .card.flipped {
  transform: rotateY(180deg) !important;
  -webkit-transform: rotateY(180deg) !important;
}

.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden !important;
  backface-visibility: hidden !important;
  border-radius: var(--radius-lg);
  background: var(--white);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
  box-sizing: border-box;
}

.card:hover .card-face {
  border-color: var(--dusty-blue-border);
  box-shadow: var(--shadow-card-hover);
}

/* شريط مستوى الصعوبة العلوي */
.level-strip {
  height: 6px;
  width: 100%;
  flex-shrink: 0;
}

.level-strip.level-easy { background-color: var(--success); }
.level-strip.level-medium { background-color: var(--soft-orange); }
.level-strip.level-hard { background-color: var(--danger); }

/* ── وجه البطاقة الأمامي (Card Front) ── */
.card-front {
  padding: 0;
  transform: rotateY(0deg) !important;
  -webkit-transform: rotateY(0deg) !important;
  z-index: 2;
}

.card.flipped .card-front {
  z-index: 1;
}

.card-back {
  transform: rotateY(180deg) !important;
  -webkit-transform: rotateY(180deg) !important;
  background: #FCFBF7;
  z-index: 1;
}

.card.flipped .card-back {
  z-index: 2;
}

.front-header {
  padding: 16px 18px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.type-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--dusty-blue-light);
  color: var(--deep-navy);
  border: 1px solid var(--dusty-blue-border);
}

.btn-fav {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  color: var(--navy-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-fav:hover {
  background: var(--baby-pink-light);
  color: #E57373;
  transform: scale(1.15);
}

.btn-fav.active {
  color: #E57373;
  transform: scale(1.1);
}

.btn-fav svg, .btn-fav i {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.front-body {
  flex: 1;
  padding: 10px 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.icon-container {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1.5px solid;
  transition: transform var(--transition-fast);
}

.card:hover .icon-container {
  transform: scale(1.08);
}

.icon-container svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.icon-container i {
  font-size: 1.5rem;
}

.card-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--deep-navy);
  margin: 0;
  line-height: 1.5;
}

.front-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--beige-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--cream-light);
  flex-shrink: 0;
}

.level-text {
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.level-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.level-dot.easy { background: var(--success); }
.level-dot.medium { background: var(--soft-orange); }
.level-dot.hard { background: var(--danger); }

.flip-hint {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dusty-blue-dark);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.flip-hint svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* ── وجه البطاقة الخلفي (Card Back) ── */

.back-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--beige-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--cream-light);
  flex-shrink: 0;
}

.back-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--deep-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}

.back-body {
  flex: 1;
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: right;
}

/* تخصيص شريط التمرير للبطاقة */
.back-body::-webkit-scrollbar {
  width: 4px;
}
.back-body::-webkit-scrollbar-thumb {
  background: var(--beige-mid);
  border-radius: 4px;
}

.content-block {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--deep-navy);
  background: var(--white);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--beige-light);
}

.example-block {
  background: var(--dusty-blue-light);
  border: 1px solid var(--dusty-blue-border);
  border-right: 3.5px solid var(--dusty-blue);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
}

.example-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dusty-blue-dark);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.example-text {
  color: var(--deep-navy);
  line-height: 1.5;
}

.notes-block {
  background: var(--soft-orange-light);
  border: 1px solid var(--soft-orange-border);
  border-right: 3.5px solid var(--soft-orange);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  color: #79441D;
}

.notes-title {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* شريط التحكم السفلي في ظهر البطاقة */
.back-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--beige-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--cream-light);
  flex-shrink: 0;
}

.btn-card-action {
  background: none;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--navy-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.btn-card-action:hover {
  background: var(--white);
  border-color: var(--beige-mid);
  color: var(--deep-navy);
}

.btn-card-mastered {
  color: var(--success);
}
.btn-card-mastered.active {
  background: var(--success-light);
  border-color: var(--success-border);
  color: var(--success);
}

/* ── 8. جداول القواعد في البطاقات (Card Tables) ── */
.card-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 0.82rem;
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.card-table th {
  background: var(--dusty-blue-light);
  color: var(--deep-navy);
  padding: 6px 10px;
  font-weight: 700;
  border-bottom: 1.5px solid var(--beige-mid);
}

.card-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--beige-light);
  background: var(--white);
  color: var(--deep-navy);
}

/* ── 9. حالة عدم وجود نتائج (Empty State) ── */
.empty-state {
  display: none;
  text-align: center;
  padding: 50px 20px;
  background: var(--white);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-top: 24px;
}

.empty-state svg, .empty-state .empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  color: var(--navy-muted);
  fill: currentColor;
}

.empty-state h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--deep-navy);
  margin: 0 0 8px;
}

.empty-state p {
  color: var(--navy-muted);
  font-size: 0.95rem;
  margin: 0 0 16px;
}

.btn-reset-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  background: var(--dusty-blue);
  color: var(--pure-white);
  border: none;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-reset-filters:hover {
  background: var(--dusty-blue-hover);
}

/* ── 10. وضع التركيز والمذاكرة الفردية (Focus Mode Modal) ── */
.focus-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(38, 59, 83, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.focus-modal-overlay.active {
  display: flex;
  opacity: 1;
}

.focus-modal-content {
  width: 100%;
  max-width: 680px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.focus-header-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--pure-white);
  margin-bottom: 16px;
}

.focus-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--pure-white);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.focus-close-btn:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

.focus-card-wrapper {
  width: 100%;
  min-height: 420px;
  perspective: 1200px;
}

.focus-card-wrapper .card {
  min-height: 420px;
}

.focus-nav-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  gap: 12px;
}

.focus-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  background: var(--white);
  color: var(--deep-navy);
  border: 1px solid var(--border-card);
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.focus-nav-btn:hover:not(:disabled) {
  background: var(--dusty-blue);
  color: var(--pure-white);
  border-color: var(--dusty-blue);
}

.focus-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.focus-counter {
  color: var(--pure-white);
  font-weight: 700;
  font-size: 1rem;
}

.focus-shortcuts-hint {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  margin-top: 12px;
  text-align: center;
}

/* ── 11. التجاوب مع الشاشات المختلفة (Responsive Design) ── */
@media (max-width: 768px) {
  .cards-page-container {
    padding: 16px 12px 40px;
  }

  .cards-header {
    padding: 22px 16px;
  }

  .cards-header h1 {
    font-size: 1.6rem;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card-container {
    min-height: 350px;
  }

  .controls-panel {
    padding: 16px;
  }

  .controls-row-top {
    flex-direction: column;
    align-items: stretch;
  }

  .counter-badge {
    text-align: center;
  }

  .quick-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-left, .actions-right {
    justify-content: center;
  }
}
