/* Persib Mini App — mobile-first, mengikuti tema Telegram.
   Warna Telegram diambil dari variabel --tg-theme-* (di-inject Web App);
   setiap variabel punya fallback agar tampilan tetap benar di browser biasa. */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1a1a1a);
  --hint: var(--tg-theme-hint-color, #707579);
  --link: var(--tg-theme-link-color, #1e50c8);
  --button: var(--tg-theme-button-color, #0a2f7d);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f2f4f7);
  --section-separator: var(--tg-theme-section-separator-color, #e3e6ea);
  --persib: #0a2f7d;
  --persib-light: #1e50c8;
  --persib-pale: #e8eefb;
  --gold: #d9a400;
  --green: #1a9e4b;
  --green-pale: #e3f5e9;
  --red: #d33a2c;
  --red-pale: #fdecea;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--link); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

/* ---------- header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--section-separator);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-badge {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--persib); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; letter-spacing: .02em;
}
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: .08em; color: var(--persib); }
.brand-sub { font-size: 12px; color: var(--hint); }

/* ---------- view ---------- */
.view { padding: 16px 16px 8px; }
.view h1 { font-size: 21px; margin: 2px 0 12px; }
.view h2 { font-size: 16px; margin: 20px 0 8px; }
.view h3 { font-size: 14px; margin: 14px 0 6px; color: var(--hint); text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--hint); font-size: 13px; }

/* ---------- cards ---------- */
.card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card-link { display: block; color: inherit; }
.card-link:active { opacity: .75; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.card-title { font-weight: 700; font-size: 15px; }
.card-more { font-size: 13px; color: var(--link); white-space: nowrap; }
.comp-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--persib-light);
}
.status-tag {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--persib-pale); color: var(--persib); white-space: nowrap;
}
.status-tag.done { background: var(--green-pale); color: var(--green); }
.status-tag.pending { background: #f3e9c8; color: #8a6d00; }

/* hero: laga berikutnya */
.hero {
  background: linear-gradient(135deg, #0a2f7d 0%, #123f9e 60%, #1e50c8 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.hero .comp-tag { color: #ffd75e; }
.hero-teams { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; }
.hero-team { flex: 1; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.25; }
.hero-vs {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: var(--gold); color: #0a2f7d;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.hero-meta { text-align: center; font-size: 13px; opacity: .92; margin-top: 8px; }
.countdown {
  display: flex; justify-content: center; gap: 8px; margin-top: 14px;
}
.countdown-cell {
  background: rgba(255, 255, 255, .14);
  border-radius: 10px; min-width: 58px; padding: 8px 4px; text-align: center;
}
.countdown-num { font-size: 22px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.countdown-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }

/* team badge (initials, no logos) */
.team-badge {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: #fff; letter-spacing: .02em;
}
.team-badge.lg { width: 44px; height: 44px; font-size: 15px; }

/* match rows */
.match-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid var(--section-separator);
  color: inherit; width: 100%; text-align: left;
}
.match-row:last-child { border-bottom: 0; }
button.match-row:active, a.match-row:active { opacity: .7; }
.match-main { flex: 1; min-width: 0; }
.match-teams { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-sub { font-size: 12px; color: var(--hint); margin-top: 2px; }
.match-right { text-align: right; flex: none; }
.match-score { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.match-time { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.result-w { color: var(--green); }
.result-d { color: var(--hint); }
.result-l { color: var(--red); }

/* filters */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  padding: 7px 13px; border-radius: 999px;
  background: var(--secondary-bg); font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
}
.chip.active { background: var(--persib); color: #fff; }
.filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filter-row label { font-size: 13px; color: var(--hint); }
.filter-row select {
  font: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--section-separator); border-radius: 10px;
  background: var(--secondary-bg); color: var(--text);
}

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td {
  padding: 8px 7px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--section-separator);
  font-variant-numeric: tabular-nums;
}
table.data th { font-size: 11px; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; }
table.data th:first-child, table.data td:first-child { text-align: center; }
table.data td.team, table.data th.team { text-align: left; }
table.data tr.persib-row td { background: var(--persib-pale); font-weight: 700; color: var(--persib); }
table.data tr.persib-row td:first-child { border-radius: 8px 0 0 8px; }
table.data tr.persib-row td:last-child { border-radius: 0 8px 8px 0; }

/* empty state */
.empty-state {
  text-align: center; padding: 28px 16px; color: var(--hint);
}
.empty-state .empty-title { font-weight: 700; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty-state p { margin: 6px 0; font-size: 14px; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--hint); margin: 10px 0 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-dot.gold { background: var(--gold); }
.legend-dot.green { background: var(--green); }
.legend-dot.red { background: var(--red); }
.legend-dot.blue { background: var(--persib-light); }

/* stat grid (proyeksi) */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat-box {
  background: var(--bg); border: 1px solid var(--section-separator);
  border-radius: 12px; padding: 10px 8px; text-align: center;
}
.stat-value { font-size: 20px; font-weight: 800; color: var(--persib); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--hint); margin-top: 2px; line-height: 1.3; }

/* bar chart (pure CSS) */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; margin: 14px 0 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-value { font-size: 10px; font-weight: 700; color: var(--persib); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.bar {
  width: 100%; max-width: 30px; border-radius: 5px 5px 0 0;
  background: var(--persib-light); min-height: 3px;
}
.bar.current { background: var(--gold); }
.bar-label { font-size: 10px; color: var(--hint); margin-top: 5px; }

/* list links (Lainnya) */
.link-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 13px 2px; border-bottom: 1px solid var(--section-separator);
  color: inherit; text-align: left; font-size: 15px; font-weight: 600;
}
.link-row:last-child { border-bottom: 0; }
.link-row:active { opacity: .7; }
.link-row .chev { color: var(--hint); font-weight: 400; }
.soon {
  font-size: 11px; font-weight: 700; color: var(--hint);
  border: 1px solid var(--section-separator); border-radius: 999px; padding: 3px 8px;
  white-space: nowrap;
}

/* freshness footer */
.freshness {
  margin: 20px 0 8px; padding: 10px 12px;
  background: var(--secondary-bg); border-radius: 10px;
  font-size: 12px; color: var(--hint); text-align: center; line-height: 1.5;
}

/* back link */
.back-link {
  display: inline-block; margin-bottom: 10px; font-size: 14px; font-weight: 600;
}
.back-link:active { opacity: .7; }

/* score detail */
.score-big {
  text-align: center; padding: 10px 0 4px;
}
.score-big .score { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-big .score-sub { font-size: 13px; color: var(--hint); margin-top: 4px; }

/* tab bar */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 520px;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--section-separator);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 0 2px; color: var(--hint); font-size: 11px; font-weight: 600;
}
.tab svg { width: 23px; height: 23px; fill: currentColor; }
.tab.active { color: var(--persib-light); }
.tab:active { opacity: .7; }
