/* DPKT -- styling minimal, fungsional dulu (Phase 2). Belum jadi prioritas. */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #f7f7f8;
  color: #1a1a1a;
}

header {
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

header a.brand-logo {
  text-decoration: none;
  color: #1a1a1a;
  font-weight: 700;
}

nav a {
  margin-right: 16px;
  color: #555;
  font-weight: 500;
  text-decoration: none;
  font-size: 14px;
}

nav a:hover { color: #c2410c; }
nav a.is-active { color: #c2410c; }

/* Dropdown "Laporan" (Keyword / Kategori). Murni CSS: buka saat hover atau
   saat tombolnya fokus (klik, tap, Tab). */
.nav-dropdown {
  position: relative;
  display: inline-block;
  margin-right: 16px;
}
.nav-dropdown-toggle {
  background: none;
  border: none;
  padding: 0;
  color: #555;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
}
.nav-dropdown-toggle span { font-size: 10px; }
.nav-dropdown:hover .nav-dropdown-toggle,
.nav-dropdown.is-active .nav-dropdown-toggle { color: #c2410c; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: -12px;
  z-index: 20;
  min-width: 150px;
  /* padding-top menjembatani celah tombol -> menu supaya hover tidak putus */
  padding-top: 8px;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  margin: 0;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top-width: 0;
}
.nav-dropdown-menu a:first-child { border-top-width: 1px; border-radius: 8px 8px 0 0; }
.nav-dropdown-menu a:last-child { border-radius: 0 0 8px 8px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06); }
.nav-dropdown-menu a:hover { background: #f8fafc; }

/* Identitas user + tombol keluar, didorong ke ujung kanan header */
.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.header-user-name { font-weight: 600; color: #334155; }
.header-user .btn { padding: 5px 10px; font-size: 12px; }

/* ==== Halaman login ==== */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.login-title { font-size: 24px; margin: 0 0 4px; }
.login-sub { color: #64748b; font-size: 12px; margin: 0 0 24px; }
.login-btn { width: 100%; padding: 10px; font-size: 15px; }
.login-note {
  color: #94a3b8;
  font-size: 12px;
  margin: 20px 0 0;
  text-align: center;
}

main {
  /* Dinaikkan dari 960px: tabel laporan sekarang punya 5 kolom riwayat
     harian, di 960px kolom "Update" sampai terpotong padahal layar masih
     lapang. Tetap dibatasi supaya halaman lain (form brand/keyword) tidak
     melebar berlebihan di monitor besar. */
  max-width: min(1440px, 96vw);
  margin: 24px auto;
  padding: 0 16px 48px;
}

h1 { font-size: 22px; margin-bottom: 16px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

th { background: #fafafa; font-weight: 600; }

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  background: #c2410c;
  color: #fff;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.btn.secondary {
  background: #e5e5e5;
  color: #1a1a1a;
}

.actions { display: flex; gap: 12px; margin-bottom: 16px; }

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 14px;
}

.flash.success { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }
.flash.info { background: #e0f2fe; color: #075985; line-height: 1.5; }

form.inline { display: inline; }

.form-group { margin-bottom: 14px; max-width: 420px; }

label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; }

input, select, textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.status-badge {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-active { background: #dcfce7; color: #166534; }
.status-inactive, .status-paused { background: #f3f4f6; color: #6b7280; }

/* ==== Ticker board (Laporan Keyword) -- gaya papan bursa saham, tema terang ==== */

.tk-board {
  background: #fff;
  color: #0f172a;
  border-radius: 10px;
  padding: 20px 24px 28px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.tk-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.tk-title { color: #0f172a; font-size: 20px; margin: 0 0 4px; }
.tk-subtitle { color: #64748b; font-size: 12px; margin: 0; }

.tk-summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }

.tk-pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tk-pill-up { background: #dcfce7; color: #15803d; border-color: #86efac; }
.tk-pill-down { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.tk-pill-flat { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.tk-pill-na { background: #f8fafc; color: #94a3b8; border-color: #e2e8f0; }

.tk-banner {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}
.tk-banner-danger { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.tk-banner-warning { background: #fef9c3; color: #713f12; border: 1px solid #fde047; }
.tk-banner code { background: rgba(0, 0, 0, 0.06); color: #0f172a; }

.tk-quota-note { color: #64748b; font-size: 12px; margin: 0 0 12px; }

/* ==== Panel progres "Scrape Sekarang" ====
   Scrape 76 keyword butuh 10-30 menit. Dulu tombolnya bikin request HTTP
   menggantung selama itu tanpa tanda apa pun (halaman putih sampai timeout);
   sekarang jalan di background dan panel ini yang melaporkan progresnya. */

.tk-progress {
  position: relative;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 12px 40px 12px 14px;
  margin-bottom: 14px;
  animation: tk-fade-in 0.25s ease-out;
}
.tk-progress[data-status="done"] { background: #f0fdf4; border-color: #bbf7d0; }
.tk-progress[data-status="error"] { background: #fef2f2; border-color: #fecaca; }

.tk-progress-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #0f172a;
}

.tk-progress-elapsed { font-size: 12px; margin-left: auto; }

.tk-progress-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: #64748b;
  /* nama keyword yang panjang jangan sampai melebarkan panel */
  overflow-wrap: anywhere;
}

.tk-progress-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}

.tk-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #ea580c;
  transition: width 0.4s ease;
}
.tk-progress[data-status="done"] .tk-progress-fill { background: #16a34a; }
.tk-progress[data-status="error"] .tk-progress-fill { background: #dc2626; }

/* Selama total keyword belum diketahui (masih buka browser & login), bar-nya
   diisi penuh tapi bergaris bergerak -- menandakan "jalan, belum terukur"
   alih-alih terlihat macet di 0%. */
.tk-progress.is-indeterminate .tk-progress-fill {
  background-image: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0.45) 25%, transparent 25%,
    transparent 50%, rgba(255, 255, 255, 0.45) 50%,
    rgba(255, 255, 255, 0.45) 75%, transparent 75%
  );
  background-size: 18px 18px;
  animation: tk-stripes 0.8s linear infinite;
  transition: none;
}

/* Spinner dipakai di panel dan di dalam tombol (ukurannya beda) */
.tk-spinner,
.tk-btn-spinner {
  display: inline-block;
  border-radius: 50%;
  border: 2px solid rgba(234, 88, 12, 0.25);
  border-top-color: #ea580c;
  animation: tk-spin 0.7s linear infinite;
  flex: none;
}
.tk-spinner { width: 14px; height: 14px; }

/* Panel yang sudah selesai/gagal tidak perlu spinner berputar lagi */
.tk-progress[data-status="done"] .tk-spinner,
.tk-progress[data-status="error"] .tk-spinner { display: none; }

.tk-progress-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  width: auto;
  padding: 2px 6px;
  font-size: 18px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
}
.tk-progress-close:hover { color: #475569; }

/* Tombol: spinner cuma muncul saat tombolnya disabled (= scrape jalan) */
.tk-btn-spinner {
  display: none;
  width: 12px;
  height: 12px;
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  margin-right: 7px;
}
.tk-btn:disabled { cursor: progress; opacity: 0.75; }
.tk-btn:disabled .tk-btn-spinner { display: inline-block; }
.tk-btn-primary:disabled:hover { background: #c2410c; }

@keyframes tk-spin { to { transform: rotate(360deg); } }
@keyframes tk-stripes { to { background-position: 18px 0; } }
@keyframes tk-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tk-spinner, .tk-btn-spinner, .tk-progress, .tk-progress.is-indeterminate .tk-progress-fill {
    animation: none;
  }
  .tk-progress-fill { transition: none; }
}

.tk-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.tk-filter-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  margin-left: 2px;
}

/* pemisah visual antara filter data (brand/ring/market) dan kontrol periode */
.tk-filter-sep {
  width: 1px;
  align-self: stretch;
  background: #e2e8f0;
  margin: 0 4px;
}

.tk-filter-bar select,
.tk-filter-bar input[type="date"],
.tk-filter-bar .tk-month-input {
  background: #fff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  width: auto;
}
.tk-filter-bar .tk-month-input { width: 96px; }

.tk-btn {
  display: inline-flex;
  align-items: center;
  background: #fff;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.tk-btn:hover { background: #f8fafc; }
.tk-btn-primary { background: #c2410c; border-color: #c2410c; color: #fff; font-weight: 600; }
.tk-btn-primary:hover { background: #ea580c; }

.tk-table-wrap {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.tk-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.tk-table th {
  text-align: left;
  padding: 10px 14px;
  color: #64748b;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.tk-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
}

.tk-table tbody tr:hover { background: #f8fafc; }

.tk-col-kw { min-width: 180px; font-weight: 600; }
.tk-dim { color: #64748b; }
.tk-num { text-align: left; font-variant-numeric: tabular-nums; }
.tk-last { color: #0f172a; font-weight: 700; }
.tk-date { font-size: 11px; }

/* Kolom riwayat 5 hari -- warnanya menandakan arah perubahan dibanding
   hari sebelumnya. Sengaja lebih ringan dari kolom "vs Kemarin" (tidak
   bold) supaya kolom utama tetap yang paling menonjol. */
.tk-day-col {
  font-size: 12px;
  padding-left: 10px;
  padding-right: 10px;
}
.tk-day-up { color: #15803d; }
.tk-day-down { color: #b91c1c; }
.tk-day-flat { color: #64748b; }

.tk-chg { display: inline-block; font-variant-numeric: tabular-nums; }
.tk-up { color: #15803d; font-weight: 700; }
.tk-down { color: #b91c1c; font-weight: 700; }
.tk-flat { color: #64748b; }
.tk-na { color: #cbd5e1; }

.tk-ring {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
}
.tk-ring-1 { background: #ea580c; }
.tk-ring-2 { background: #2563eb; }
.tk-ring-3 { background: #64748b; }

.tk-empty {
  text-align: center;
  color: #94a3b8;
  padding: 32px;
}
.tk-empty strong { color: #475569; }
.tk-empty-action { margin-top: 12px; }

/* Tombol kecil di kolom Aksi + varian hapus (merah = warna "turun" di
   Laporan, supaya tidak menambah palet baru). */
.tk-actions { text-align: center; white-space: nowrap; }
.tk-actions-group { display: inline-flex; gap: 8px; }
.tk-nowrap { white-space: nowrap; }

/* Tabel Laporan Kategori: Kategori mengambil sisa ruang, kolom lain lebar
   tetap supaya angka rupiah (rata kanan, tabular-nums dari .tk-num) tersusun
   lurus vertikal. min-width: di layar sempit tabel di-scroll horizontal
   (.tk-table-wrap), bukan kolomnya dipepetkan. */
.tk-cr-table { min-width: 680px; }
.tk-cr-col-month { width: 160px; }
.tk-cr-col-num { width: 180px; }
.tk-cr-col-actions { width: 170px; }
.tk-cr-table .tk-col-kw { min-width: 0; }
.tk-btn-sm { padding: 3px 9px; font-size: 12px; }
.tk-btn-danger { background: #b91c1c; border-color: #b91c1c; color: #fff; font-weight: 600; }
.tk-btn-danger:hover { background: #991b1b; }
.tk-btn-danger-outline { color: #b91c1c; border-color: #fca5a5; }
.tk-btn-danger-outline:hover { background: #fee2e2; }
.tk-empty-action .tk-btn + .tk-btn { margin-left: 6px; }

/* Modal tambah/edit & konfirmasi hapus (<dialog> bawaan browser) */
.tk-modal {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px 24px;
  width: min(460px, 92vw);
  color: #0f172a;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
}
.tk-modal-sm { width: min(380px, 92vw); }
.tk-modal::backdrop { background: rgba(15, 23, 42, 0.35); }
.tk-modal-title { font-size: 17px; margin: 0 0 14px; }
.tk-modal-text { font-size: 14px; color: #475569; margin: 0 0 8px; }
.tk-modal .form-group { max-width: none; }
.tk-form-row { display: flex; gap: 12px; }
.tk-form-row .form-group { flex: 1; }
.tk-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Checkbox berlabel (form import). Input global width:100% dibatalkan. */
.tk-check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tk-check input { width: auto; margin: 0; }

/* ==== Raw Data (pivot: baris = tanggal, kolom = keyword) ====
   Tampilan sel/header/hover sepenuhnya dari .tk-table (sama dengan
   Laporan); kolom keyword memakai .tk-day-col seperti kolom riwayat harian
   di Laporan. Yang ditambahkan di sini hanya yang dibutuhkan tabel lebar:
   scroll horizontal di wrapper, tinggi dibatasi supaya header (sticky top)
   tetap kelihatan saat histori panjang, dan kolom Tanggal sticky kiri. */
.tk-raw-wrap { max-height: 70vh; }
.tk-raw-table { width: max-content; min-width: 100%; }
.tk-raw-table th,
.tk-raw-table td { white-space: nowrap; }

/* Nama keyword di header ditulis persis seperti aslinya (huruf besar/kecil
   tidak diubah) supaya mudah dicocokkan; ukuran & warna tetap .tk-table. */
.tk-raw-table th.tk-raw-kw { text-transform: none; letter-spacing: normal; }

/* Kolom Tanggal tetap di kiri saat tabel digeser horizontal. Background
   wajib supaya angka yang lewat di bawahnya tertutup. */
.tk-raw-table .tk-raw-date {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  font-weight: 600;
}
.tk-raw-table th.tk-raw-date { background: #f8fafc; z-index: 3; }
.tk-raw-table th { z-index: 2; }
.tk-raw-table tbody tr:hover .tk-raw-date { background: #f8fafc; }

/* Header bisa diklik untuk sort. nowrap (di atas) menjaga ikon tetap
   menempel di label, tidak terpotong ke baris baru. */
.tk-sort {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tk-sort:hover { color: #c2410c; }
.tk-sort-ico { color: #cbd5e1; font-size: 11px; }
.tk-sort.is-active,
.tk-sort.is-active .tk-sort-ico { color: #c2410c; }

.tk-footer {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

pre {
  background: #fff;
  padding: 12px;
  border-radius: 6px;
  overflow: auto;
  font-size: 13px;
  border: 1px solid #eee;
}

code {
  background: #eee;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar select,
.filter-bar input[type="date"] {
  width: auto;
  padding: 6px 10px;
}
.filter-bar .tk-month-input { width: 96px; padding: 6px 10px; }

/* Grafik Kategori: toggle seri Omset / Omset Toko */
.chart-series-toggle { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.chart-series-toggle .tk-check { font-size: 14px; cursor: pointer; }
.chart-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
/* Bar chart dengan banyak label: scroll horizontal, bukan label berdesakan */
.chart-scroll { overflow-x: auto; }

.trend-up { color: #166534; font-weight: 600; }
.trend-down { color: #991b1b; font-weight: 600; }
.trend-flat { color: #6b7280; }

.banner {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.banner-danger {
  background: #fee2e2;
  color: #7f1d1d;
  border: 1px solid #fca5a5;
}

.banner-warning {
  background: #fef9c3;
  color: #713f12;
  border: 1px solid #fde047;
}

.chart-box {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-top: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chart-box h2 {
  font-size: 15px;
  margin: 0 0 12px;
}

.chart-note {
  color: #898781;
  font-size: 12px;
  margin: -6px 0 14px;
}

