// ui-countdown.js — FINAL PRO

// Update label & timer untuk sholat berikutnya
export function updateNextPrayerLabel(name = "-", timestr = "--:--:--") {
    const label = document.getElementById("nextPrayerLabel");
    const countdown = document.getElementById("countdownNextPrayer");

    if (label) label.textContent = name;
    if (countdown) countdown.textContent = timestr;
}

// Tandai sholat yang sedang berlangsung (Iqomah aktif)
export function markActivePrayer(name) {
    const rows = document.querySelectorAll(".waktu-sholat-row");

    rows.forEach(r => r.classList.remove("active-prayer"));

    const target = Array.from(rows).find(r =>
        r.textContent.toLowerCase().includes(name.toLowerCase())
    );
    if (target) target.classList.add("active-prayer");
}

// Flash merah saat kritis ≤ 1 menit
export function flashCritical(selector) {
    const el = document.querySelector(selector);
    if (!el) return;

    el.classList.add("flash-critical");
    setTimeout(() => el.classList.remove("flash-critical"), 1000);
}
