/* =========================================================
   TIMELINE HOTSPOT (gaya NASA FIRMS) — bar di bawah peta
   Desain modern: panel kaca, chip tanggal dengan nama hari,
   kontrol ikon. Warna mengikuti tema halaman (terang/gelap)
   lewat variabel --tl-*; nilai dasar di sini untuk tema terang,
   ditimpa untuk tema gelap di css/theme.css.
   ========================================================= */

.tl {
  --tl-bg: rgba(255, 255, 255, 0.86);
  --tl-bg-solid: var(--surface);
  --tl-line: rgba(15, 23, 42, 0.09);
  --tl-line-strong: rgba(15, 23, 42, 0.18);
  --tl-text: var(--text);
  --tl-dim: var(--text-muted);
  --tl-accent: var(--brand);
  --tl-accent-2: var(--accent);
  --tl-chip: rgba(15, 23, 42, 0.045);
  --tl-chip-hover: rgba(13, 122, 61, 0.12);
  --tl-warn-bg: #fef3c7;
  --tl-warn-text: #92400e;
  --tl-fail-text: #b91c1c;
  --tl-fail-border: rgba(220, 38, 38, 0.5);
  --tl-sun: #dc2626;

  position: absolute;
  left: calc(12px + env(safe-area-inset-left, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  /* di atas .coord-bar (bottom 12px, tinggi ±28px) */
  bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  z-index: 16;

  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;

  color: var(--tl-text);
  font-family: inherit;
  font-size: 0.8rem;
  pointer-events: none;           /* hanya anak-anaknya yang menangkap klik */
}

.tl > * {
  pointer-events: auto;
}

/* Reset: style.css punya aturan global `button, select { width:100%;
   padding; margin-top:12px }` yang membuat tombol/dropdown timeline
   saling tumpuk. Netralkan semuanya di dalam .tl. */
.tl button,
.tl select {
  width: auto;
  margin: 0;
  box-sizing: border-box;
  font-family: inherit;
  box-shadow: none;
  transform: none;
}

.tl button:active {
  transform: none;
}

/* ---------- tombol buka/tutup ---------- */

.tl .tl-toggle {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px 6px 11px;
  border: 1px solid var(--tl-line-strong);
  border-radius: 99px;
  background: var(--tl-bg);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  color: var(--tl-text);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(2, 12, 27, 0.35);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tl .tl-toggle:hover {
  background: rgba(16, 36, 68, 0.92);
  border-color: var(--tl-accent);
  color: var(--tl-text);
}

.tl-toggle-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--tl-accent);
}

.tl-toggle-ico svg {
  width: 100%;
  height: 100%;
}

.tl-toggle-chev {
  display: inline-flex;
  width: 14px;
  height: 14px;
  color: var(--tl-dim);
  transition: transform 0.18s ease;
}

.tl-toggle-chev svg {
  width: 100%;
  height: 100%;
}

.tl.is-collapsed .tl-toggle-chev {
  transform: rotate(-90deg);
}

.tl.is-collapsed .tl-body {
  display: none;
}

/* ---------- panel utama ---------- */

.tl-body {
  display: flex;
  align-items: stretch;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 38%),
    var(--tl-bg);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--tl-line-strong);
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(2, 12, 27, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

/* ---------- strip hari ---------- */

.tl-strip {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--tl-line-strong) transparent;
  outline: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.tl-strip::-webkit-scrollbar {
  height: 6px;
}

.tl-strip::-webkit-scrollbar-thumb {
  background: var(--tl-line-strong);
  border-radius: 99px;
}

.tl-strip:focus-visible {
  box-shadow: inset 0 0 0 2px var(--tl-accent);
}

.tl-month {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 4px;
  border-right: 1px solid var(--tl-line);
}

.tl-month:last-child {
  border-right: 0;
}

.tl-month-title {
  position: sticky;
  left: 6px;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 9px 0 6px 6px;
  padding: 0;
  background: none;
  color: var(--tl-dim);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tl-month-title::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tl-accent), var(--tl-accent-2));
}

.tl-days {
  display: flex;
  gap: 3px;
  padding: 0 4px 9px;
}

/* ---------- chip tanggal ---------- */

.tl .tl-day {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 42px;
  height: 46px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--tl-chip);
  color: var(--tl-dim);
  font-size: 0.86rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.tl-dow {
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.tl-num {
  font-size: 0.92rem;
  font-weight: 600;
}

/* Minggu */
.tl-day.is-sun .tl-dow {
  color: var(--tl-sun);
  opacity: 0.95;
}

.tl .tl-day:hover {
  background: var(--tl-chip-hover);
  border-color: var(--tl-line-strong);
  color: #fff;
  transform: translateY(-1px);
}

.tl .tl-day:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 1px;
}

/* 5 hari terakhir = data live (instan, tanpa unduh arsip) */
.tl-day.is-live::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--tl-accent);
  box-shadow: 0 0 6px var(--tl-accent);
  opacity: 0.9;
}

/* satu atau lebih satelit tidak tersedia di hari ini (mis. MODIS sebelum batas NRT) */
.tl-day.is-limited::before {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fbbf24;
  opacity: 0.9;
}

.tl-day.is-today {
  color: var(--tl-text);
  border-color: var(--tl-line-strong);
}

.tl-day.is-today .tl-num {
  font-weight: 800;
}

/* hari terpilih / rentang terpilih */
.tl .tl-day.is-sel {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.34), rgba(99, 102, 241, 0.26));
  border-color: rgba(56, 189, 248, 0.55);
  color: #fff;
}

.tl .tl-day.is-end {
  background: linear-gradient(135deg, var(--tl-accent), var(--tl-accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.38);
}

.tl-day.is-end .tl-dow {
  opacity: 0.95;
}

.tl-day.is-end .tl-num {
  font-weight: 800;
}

/* hari di rentang terpilih yang gagal diambil / belum lengkap dari server */
.tl .tl-day.is-failed {
  color: var(--tl-fail-text);
  border-color: var(--tl-fail-border);
}

.tl .tl-day.is-sel.is-failed {
  border-color: rgba(220, 38, 38, 0.8);
}

/* tanggal awal rentang bebas yang sudah diklik, menunggu tanggal akhir */
.tl .tl-day.is-pending {
  background: rgba(250, 204, 21, 0.22);
  border-color: #facc15;
  color: #fff;
}

/* ---------- kontrol kanan ---------- */

.tl-ctrl {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-left: 1px solid var(--tl-line);
  background: rgba(255, 255, 255, 0.02);
}

.tl-label {
  align-self: stretch;
  padding: 6px 14px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 99px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(99, 102, 241, 0.2));
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-note {
  max-width: 330px;
  margin: 0 auto;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--tl-warn-bg);
  color: var(--tl-warn-text);
  font-size: 0.7rem;
  line-height: 1.3;
  text-align: center;
  cursor: help;
}

.tl-note[hidden] {
  display: none;
}

.tl-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* tombol transport (⏮ ▶ ⏭) menyatu sebagai satu grup */
.tl-transport {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--tl-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.tl .tl-btn,
.tl .tl-span {
  height: 30px;
  border: 1px solid var(--tl-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--tl-text);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.tl .tl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 30px;
  padding: 0 11px;
  white-space: nowrap;
}

.tl .tl-btn svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  pointer-events: none;
}

.tl .tl-transport .tl-btn {
  min-width: 32px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
}

.tl .tl-span {
  min-width: 82px;
  padding: 0 24px 0 11px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238fa8c8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

.tl .tl-span option {
  color: #0f172a;
  background: #fff;
}
/* Opsi dropdown ditampilkan native oleh browser (selalu latar terang),
   jadi teksnya memang sengaja tidak memakai var(--tl-text). */

.tl .tl-btn:hover,
.tl .tl-span:hover {
  background-color: var(--tl-chip-hover);
  border-color: var(--tl-line-strong);
  color: #fff;
}

.tl .tl-btn:focus-visible,
.tl .tl-span:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 1px;
}

.tl .tl-play.is-on,
.tl .tl-rangebtn.is-on {
  background: linear-gradient(135deg, var(--tl-accent), var(--tl-accent-2));
  color: #fff;
  border-color: transparent;
}

.tl .tl-transport .tl-play {
  background: rgba(56, 189, 248, 0.18);
  color: #fff;
}

.tl-all {
  font-weight: 600;
}

.tl:not(.has-sel) .tl-all {
  opacity: 0.45;
}

.tl.is-busy .tl-body {
  cursor: progress;
}

.tl.is-busy .tl-day,
.tl.is-busy .tl-btn,
.tl.is-busy .tl-span {
  pointer-events: none;
}

.tl.is-busy .tl-label::after {
  content: " …";
}

/* saat memuat, "Semua" menjadi "Batal" dan tetap bisa diklik */
.tl.is-busy .tl-all {
  pointer-events: auto;
  opacity: 1;
  background: rgba(248, 113, 113, 0.28);
  border-color: rgba(248, 113, 113, 0.6);
  color: #fff;
}

/* ---------- layar sempit ---------- */

@media (max-width: 780px) {
  .tl-body {
    flex-direction: column;
  }

  .tl-ctrl {
    align-items: stretch;
    border-left: 0;
    border-top: 1px solid var(--tl-line);
    padding: 8px 10px;
  }

  .tl-row {
    justify-content: stretch;
  }

  /* baris 1: transport + dropdown (melebar); baris 2: Rentang & Semua berbagi lebar sama */
  .tl .tl-span {
    flex: 1 1 0;
  }

  .tl .tl-rangebtn,
  .tl .tl-all {
    flex: 1 1 45%;
  }

  .tl .tl-day {
    width: 38px;
    height: 44px;
  }
}

@media (max-width: 420px) {
  .tl-toggle-txt {
    display: none;
  }
}
