/* ==========================================================================
   E-TAJWID DIGITAL LEARNING MEDIA DESIGN SYSTEM - BAB 4
   Modern, Clean, Responsive, Educational, Mobile-First
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Noto+Naskh+Arabic:wght@400;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Color Tokens - Light Theme */
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --bg-accent-light: #ecfdf5;

  --primary: #0d5c3a;
  --primary-light: #10b981;
  --primary-dark: #064e3b;
  --primary-rgb: 13, 92, 58;

  --accent-gold: #d97706;
  --accent-gold-light: #fef3c7;
  --accent-gold-dark: #b45309;

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

  --border-color: #e2e8f0;
  --border-active: #a7f3d0;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(13, 92, 58, 0.08);
  --shadow-lg: 0 12px 24px -4px rgba(13, 92, 58, 0.12);

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

  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-arabic: 'Noto Naskh Arabic', 'Amiri', serif;
}

[data-theme="dark"] {
  --bg-main: #090d16;
  --bg-surface: #111827;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --bg-accent-light: rgba(16, 185, 129, 0.15);

  --primary: #34d399;
  --primary-light: #6ee7b7;
  --primary-dark: #059669;

  --accent-gold: #fbbf24;
  --accent-gold-light: rgba(251, 191, 36, 0.15);

  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-light: #94a3b8;

  --border-color: #334155;
  --border-active: #059669;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.6);
}

/* Reset & Global */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography Helpers */
.arabic-inline, .arabic-text {
  font-family: var(--font-arabic);
  font-size: 1.4rem;
  direction: rtl;
  color: var(--primary);
  line-height: 1.8;
  display: inline-block;
}

.arabic-quote-card {
  background: var(--bg-accent-light);
  border-right: 4px solid var(--primary);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin: 16px 0;
  text-align: right;
}

.arabic-quote-card .arabic-text {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.arabic-quote-card .arabic-translation {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-style: italic;
  direction: ltr;
  text-align: left;
}

/* Layout Wrapper */
#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Header */
.top-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(var(--primary-rgb), 0.95);
  backdrop-filter: blur(10px);
  color: white;
  padding: 12px 20px;
  box-shadow: var(--shadow-md);
}

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

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 1.8rem;
  background: rgba(255, 255, 255, 0.15);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.78rem;
  opacity: 0.85;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* Sidebar & Main Layout */
.main-layout {
  display: flex;
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-category {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-light);
  letter-spacing: 0.05em;
  margin: 16px 0 6px 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: var(--bg-accent-light);
  color: var(--primary);
}

.nav-link.active {
  background: var(--primary);
  color: white;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.25);
}

/* Content Area */
.content-area {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
}

/* Section Intros */
.section-intro {
  margin-bottom: 24px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* Cards & Grid Systems */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-active);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-primary { background: var(--bg-accent-light); color: var(--primary); }
.badge-gold { background: var(--accent-gold-light); color: var(--accent-gold-dark); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary { background: var(--bg-surface); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-input); }

.btn-gold { background: var(--accent-gold); color: white; }
.btn-gold:hover { background: var(--accent-gold-dark); }

.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }

.btn-outline-danger { background: transparent; border: 1.5px solid #ef4444; color: #ef4444; }
.btn-outline-danger:hover { background: #ef4444; color: white; }

.btn-audio-play {
  background: var(--bg-accent-light);
  color: var(--primary);
  border: 1px solid var(--border-active);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-audio-play.playing {
  background: var(--accent-gold);
  color: white;
  border-color: var(--accent-gold-dark);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

/* Callout Boxes */
.info-box { background: #f0f9ff; border-left: 4px solid #0284c7; color: #0369a1; padding: 16px; border-radius: var(--radius-md); margin: 16px 0; }
.warning-box { background: #fffbeb; border-left: 4px solid #f59e0b; color: #92400e; padding: 16px; border-radius: var(--radius-md); margin: 16px 0; }
.tip-box { background: #f0fdf4; border-left: 4px solid #16a34a; color: #15803d; padding: 16px; border-radius: var(--radius-md); margin: 16px 0; }
.keypoints-box { background: var(--bg-accent-light); border: 1.5px solid var(--border-active); border-radius: var(--radius-md); padding: 18px; margin: 20px 0; }
.keypoints-header { font-weight: 800; color: var(--primary); font-size: 0.95rem; margin-bottom: 8px; }

/* Custom Tables */
.table-responsive {
  overflow-x: auto;
  margin: 16px 0;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.custom-table th, .custom-table td {
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.custom-table th {
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.custom-table tr:nth-child(even) {
  background: var(--bg-main);
}

/* Subbab Tabs & Layout */
.subbab-tabs-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
}

.subbab-tab-btn {
  padding: 10px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.subbab-tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.subbab-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.subbab-header { margin-bottom: 16px; }
.subbab-tag { font-size: 0.8rem; font-weight: 800; color: var(--accent-gold); text-transform: uppercase; }
.subbab-title { font-size: 1.4rem; font-weight: 800; color: var(--primary); }

.subbab-footer-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* Interactive Check Box */
.interactive-check-box {
  background: var(--bg-main);
  border: 1.5px dashed var(--primary);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 24px;
}

.check-title { font-weight: 800; color: var(--primary); font-size: 1rem; margin-bottom: 6px; }
.check-question { font-size: 0.95rem; font-weight: 600; margin-bottom: 12px; }

.check-options { display: flex; flex-direction: column; gap: 8px; }
.check-opt-btn {
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.check-opt-btn:hover { background: var(--bg-accent-light); border-color: var(--primary); }
.check-feedback { padding: 12px 16px; border-radius: var(--radius-md); margin-top: 12px; font-size: 0.9rem; }
.feedback-correct { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.feedback-wrong { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* Interactive Concept Map Nodes Grid */
.concept-nodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.concept-node {
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.25 ease;
}

.concept-node:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  background: var(--bg-accent-light);
}

.concept-node-title { font-weight: 800; color: var(--primary); font-size: 0.98rem; margin-bottom: 4px; }
.concept-node-desc { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 10px; }
.concept-node-action { font-size: 0.78rem; font-weight: 700; color: var(--accent-gold); }

/* Flashcards */
.flashcard-wrapper { max-width: 500px; margin: 0 auto; text-align: center; }
.flashcard-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-size: 0.88rem; font-weight: 700; }

.flip-card {
  perspective: 1000px;
  height: 240px;
  cursor: pointer;
  margin-bottom: 20px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

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

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-active);
  box-shadow: var(--shadow-md);
}

.flip-card-front { background: var(--primary); color: white; }
.flip-card-back { background: var(--bg-card); color: var(--text-main); transform: rotateY(180deg); border-color: var(--accent-gold); }
.card-front-text { font-size: 1.15rem; font-weight: 800; line-height: 1.5; }
.card-back-text { font-size: 1rem; font-weight: 600; line-height: 1.6; color: var(--primary); }
.flip-hint { font-size: 0.75rem; margin-top: 14px; opacity: 0.8; }

/* Matching Game */
.matching-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0; }
.matching-item {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  margin-bottom: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
}

.matching-item.selected { border-color: var(--accent-gold); background: var(--accent-gold-light); }
.matching-item.matched { border-color: var(--primary-light); background: var(--bg-accent-light); opacity: 0.6; pointer-events: none; }

/* Sorting Game */
.sorting-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.sorting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-weight: 700;
}

/* Drag & Drop Classifier */
.pool-box { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px; background: var(--bg-main); border-radius: var(--radius-md); margin-bottom: 20px; }
.pool-item { padding: 8px 16px; background: var(--bg-card); border: 2px solid var(--primary); border-radius: var(--radius-full); cursor: pointer; font-weight: 700; }
.pool-item.selected { background: var(--accent-gold); color: white; border-color: var(--accent-gold-dark); }
.buckets-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.bucket-card { background: var(--bg-card); border: 2px dashed var(--border-color); border-radius: var(--radius-md); padding: 16px; min-height: 120px; cursor: pointer; }
.bucket-title { font-weight: 800; color: var(--primary); font-size: 0.9rem; margin-bottom: 8px; text-align: center; }

/* Quiz & Evaluasi Engine */
.quiz-card { background: var(--bg-card); border-radius: var(--radius-lg); border: 1px solid var(--border-color); padding: 28px; box-shadow: var(--shadow-md); }
.quiz-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.quiz-title { font-size: 1.3rem; font-weight: 800; color: var(--primary); }
.quiz-timer { font-size: 1.05rem; font-weight: 800; color: var(--accent-gold-dark); background: var(--accent-gold-light); padding: 8px 16px; border-radius: var(--radius-full); }

.options-container { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.option-btn:hover { background: var(--bg-accent-light); border-color: var(--primary); }
.option-btn.selected { background: var(--primary); color: white; border-color: var(--primary); }

.opt-indicator {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
}

.result-dashboard-card { text-align: center; padding: 30px; background: var(--bg-card); border-radius: var(--radius-lg); }
.score-ring-container { position: relative; width: 140px; height: 140px; margin: 0 auto 20px; }
.score-ring-svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--border-color); stroke-width: 10; }
.ring-fill { fill: none; stroke: var(--primary); stroke-width: 10; stroke-dasharray: 314; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.score-number { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 2.2rem; font-weight: 800; color: var(--primary); }

.stats-breakdown { display: flex; justify-content: center; gap: 20px; margin: 20px 0; }
.stat-box { padding: 14px 20px; border-radius: var(--radius-md); background: var(--bg-main); width: 110px; }
.box-total { border-bottom: 4px solid #0284c7; }
.box-correct { border-bottom: 4px solid #16a34a; }
.box-wrong { border-bottom: 4px solid #ef4444; }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--bg-card); border-radius: var(--radius-lg); padding: 28px; width: 90%; max-width: 500px; position: relative; }
.modal-close-btn { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

/* Form Controls */
.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
}

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

/* Bottom Nav (Mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  z-index: 999;
  padding: 6px 0;
}

.bottom-nav-menu { display: flex; justify-content: space-around; list-style: none; }
.bottom-nav-item a { display: flex; flex-direction: column; align-items: center; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-decoration: none; }
.bottom-nav-item a.active { color: var(--primary); }

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: -280px; bottom: 0;
    z-index: 1500;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.active { left: 0; }
  .bottom-nav { display: block; }
  .content-area { padding: 16px; padding-bottom: 70px; }
  .matching-grid { grid-template-columns: 1fr; }
  .stats-breakdown { gap: 10px; }
  .stat-box { width: 90px; padding: 10px; }
}

@media print {
  .no-print, .top-header, .sidebar, .bottom-nav, .result-actions-row { display: none !important; }
  body { background: white; color: black; }
  .result-dashboard-card { border: none; box-shadow: none; }
}
