/* ====== Font Arab Utsmani ====== */
@import url('https://fonts.googleapis.com/css2?family=Amiri+Quran&family=Scheherazade+New:wght@400;500;600;700&family=Quicksand:wght@300;400;500;600;700&display=swap');

:root {
  --color-primary: #A8623E;
  --color-primary-dark: #844C30;
  --color-primary-light: #DA8856;
  --color-gold: #D4A574;
  --color-gold-light: #E8C8A0;
  --color-bg: #FAFAF8;
  --color-surface: #FFFFFF;
  --color-text: #1F2937;
  --color-muted: #6B7280;
  --color-border: #E5E7EB;

  /* Tajwid color tokens */
  --c-ghunnah:   #2ECC71;
  --c-ikhfa:     #5DADE2;
  --c-idgham:    #E67E22;
  --c-iqlab:     #E91E8C;
  --c-izhar:     #64748B;
  --c-qalqalah:  #E74C3C;
  --c-mad_tabii: #1A5276;
  --c-mad_wajib: #1A5276;
  --c-mad_jaiz:  #1A5276;
  --c-makhroj:   #8B5CF6;
  --c-tasydid:   #F59E0B;
  --c-waqaf:     #06B6D4;
  --c-lahn_jali: #DC2626;
}

.dark {
  --color-bg: #0F172A;
  --color-surface: #1E293B;
  --color-text: #F1F5F9;
  --color-muted: #94A3B8;
  --color-border: #334155;
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Quicksand', system-ui, -apple-system, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.font-arabic {
  font-family: 'Scheherazade New', 'Amiri Quran', serif;
  font-weight: 500;
  line-height: 2.4;
  direction: rtl;
  text-align: right;
}

.font-arabic-display {
  font-family: 'Amiri Quran', 'Scheherazade New', serif;
}

/* ====== Tajwid Color Classes ====== */
.tajwid-ghunnah { color: #2ECC71; }
.tajwid-ikhfa { color: #5DADE2; }
.tajwid-idgham { color: #E67E22; }
.tajwid-iqlab { color: #E91E8C; }
.tajwid-qalqalah { color: #E74C3C; }
.tajwid-mad { color: #1A5276; }
.tajwid-lam-jalalah { color: #6E2F1A; }

.dark .tajwid-mad { color: #6BB6FF; }
.dark .tajwid-lam-jalalah { color: #D4A574; }

/* ====== Decorative Patterns ====== */
.pattern-islamic {
  background-image:
    radial-gradient(circle at 25% 25%, rgba(168, 98, 62, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(212, 165, 116, 0.04) 0%, transparent 50%);
}

.dark .pattern-islamic {
  background-image:
    radial-gradient(circle at 25% 25%, rgba(218, 136, 86, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(212, 165, 116, 0.04) 0%, transparent 50%);
}

/* ====== Bismillah Border ====== */
.bismillah-frame {
  background: linear-gradient(135deg, rgba(168, 98, 62, 0.06), rgba(212, 165, 116, 0.06));
  border: 1px solid rgba(168, 98, 62, 0.15);
}

.dark .bismillah-frame {
  background: linear-gradient(135deg, rgba(218, 136, 86, 0.08), rgba(212, 165, 116, 0.06));
  border: 1px solid rgba(218, 136, 86, 0.2);
}

/* ====== Smooth Card Hover ====== */
.card-hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -10px rgba(168, 98, 62, 0.25);
}

/* ====== Audio Player ====== */
.audio-progress {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(168, 98, 62, 0.2);
  outline: none;
  cursor: pointer;
}
.audio-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(168, 98, 62, 0.4);
}
.audio-progress::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  cursor: pointer;
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(168, 98, 62, 0.3);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(168, 98, 62, 0.5); }

/* ====== Animations ====== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-up { animation: fadeInUp 0.4s ease-out forwards; }

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(168, 98, 62, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(168, 98, 62, 0); }
  100% { box-shadow: 0 0 0 0 rgba(168, 98, 62, 0); }
}
.playing-ring { animation: pulse-ring 2s infinite; }

/* ====== Active Ayat Highlight ====== */
.ayat-active {
  background: linear-gradient(90deg, rgba(168, 98, 62, 0.08), rgba(168, 98, 62, 0.02));
  border-left: 3px solid var(--color-primary);
}

.dark .ayat-active {
  background: linear-gradient(90deg, rgba(218, 136, 86, 0.12), rgba(218, 136, 86, 0.02));
}

/* ====== Ayat Number Badge ====== */
.ayat-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(168, 98, 62, 0.3);
}

/* ====== Loader ====== */
.loader {
  width: 40px; height: 40px;
  border: 3px solid rgba(168, 98, 62, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== Toast ====== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ====== Role Chip ====== */
.role-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 14px 8px 8px;
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 14px;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.role-chip:hover {
  border-color: var(--color-primary-light);
  box-shadow: 0 4px 14px -6px rgba(168,98,62,.3);
  transform: translateY(-1px);
}
.dark .role-chip { background: #1E293B; border-color: #334155; }
.role-chip-avatar {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  color: white;
  flex-shrink: 0;
}
.role-chip-avatar.role-primary { background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)); }
.role-chip-avatar.role-gold    { background: linear-gradient(135deg, var(--color-gold), #C6925A); }
.role-chip-text {
  display: flex; flex-direction: column;
  line-height: 1.1;
}
.role-chip-eyebrow {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  font-weight: 600;
}
.role-chip-name {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  margin-top: 1px;
}
.dark .role-chip-name { color: #f1f5f9; }
.role-chip-switch {
  margin-left: 4px;
  width: 26px; height: 26px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(168,98,62,.1);
  color: var(--color-primary);
  font-size: 12px;
  border: none;
  cursor: pointer;
  transition: all .15s ease;
}
.role-chip:hover .role-chip-switch {
  background: var(--color-primary);
  color: white;
  transform: rotate(180deg);
}
.dark .role-chip-switch { background: rgba(218,136,86,.18); color: var(--color-primary-light); }

/* ====== Print friendly ====== */
@media print {
  .no-print { display: none !important; }
}

/* ====== Word-Level Marking (penilaian) ====== */
.ayat-word {
  display: inline-block;
  margin: 2px 4px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  border-bottom: 2px solid transparent;
}
.ayat-word:hover {
  background: rgba(168, 98, 62, 0.06);
}
.dark .ayat-word:hover {
  background: rgba(218, 136, 86, 0.1);
}
.ayat-word.word-selected {
  background: rgba(168, 98, 62, 0.12);
  outline: 2px dashed rgba(168, 98, 62, 0.5);
  outline-offset: 1px;
}
.dark .ayat-word.word-selected {
  background: rgba(218, 136, 86, 0.18);
  outline-color: rgba(218, 136, 86, 0.6);
}

/* Error colors per tajwid type */
.ayat-word.word-error[data-err="GHUNNAH"]   { background: rgba(46,204,113,.22); border-bottom-color:#2ECC71; }
.ayat-word.word-error[data-err="IKHFA"]     { background: rgba(93,173,226,.22); border-bottom-color:#5DADE2; }
.ayat-word.word-error[data-err="IDGHAM"]    { background: rgba(230,126,34,.22); border-bottom-color:#E67E22; }
.ayat-word.word-error[data-err="IQLAB"]     { background: rgba(233,30,140,.18); border-bottom-color:#E91E8C; }
.ayat-word.word-error[data-err="IZHAR"]     { background: rgba(100,116,139,.22); border-bottom-color:#64748B; }
.ayat-word.word-error[data-err="QALQALAH"]  { background: rgba(231,76,60,.20); border-bottom-color:#E74C3C; }
.ayat-word.word-error[data-err="MAD_TABII"] { background: rgba(26,82,118,.18); border-bottom-color:#1A5276; }
.ayat-word.word-error[data-err="MAD_WAJIB"] { background: rgba(26,82,118,.22); border-bottom-color:#1A5276; }
.ayat-word.word-error[data-err="MAD_JAIZ"]  { background: rgba(26,82,118,.14); border-bottom-color:#1A5276; }
.ayat-word.word-error[data-err="MAKHROJ"]   { background: rgba(139,92,246,.20); border-bottom-color:#8B5CF6; }
.ayat-word.word-error[data-err="TASYDID"]   { background: rgba(245,158,11,.20); border-bottom-color:#F59E0B; }
.ayat-word.word-error[data-err="WAQAF"]     { background: rgba(6,182,212,.20); border-bottom-color:#06B6D4; }
.ayat-word.word-error[data-err="LAHN_JALI"] { background: rgba(220,38,38,.28); border-bottom-color:#DC2626; }

/* Floating error code chip above word */
.ayat-word.word-error::after {
  content: attr(data-err-short);
  position: absolute;
  top: -10px;
  right: -2px;
  background: var(--color-text);
  color: var(--color-bg);
  font-family: 'Quicksand', sans-serif;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  line-height: 1.3;
  pointer-events: none;
  white-space: nowrap;
  direction: ltr;
}

/* Error type pill on toolbar (when active selection) */
.err-btn-active {
  background: var(--color-primary) !important;
  color: white !important;
  border-color: var(--color-primary) !important;
}
