/* RAGH Reader — satu stylesheet untuk dashboard, admin, halaman bayar, dan dokumentasi. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #5f6873;
  --accent: #0f6e5c;
  --accent-soft: #e3f3ef;
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --bad: #c62828;
  --bad-soft: #fdecea;
  --info: #1f5fbf;
  --info-soft: #e7effb;
  --neutral-soft: #eceef1;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232a;
    --border: #2b313a;
    --text: #e6e9ee;
    --muted: #9aa4b0;
    --accent: #3cc3a4;
    --accent-soft: #143b33;
    --accent-text: #06201a;
    --ok: #57c77a;
    --ok-soft: #173424;
    --warn: #e3b341;
    --warn-soft: #3a2f12;
    --bad: #f47067;
    --bad-soft: #3d1c1a;
    --info: #6ea8fe;
    --info-soft: #172a45;
    --neutral-soft: #262c34;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; margin-top: 1.4rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .8rem 1rem; overflow-x: auto; }
code { background: var(--surface-2); padding: .08em .35em; border-radius: 4px; }
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
small, .muted { color: var(--muted); }

/* ---------- Kerangka dashboard ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; padding: .25rem .5rem 1rem; color: var(--text); }
.brand .dot { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: .8rem; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: .45rem .6rem; border-radius: 7px; color: var(--text); font-size: .93rem; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem .6rem .35rem; }
.nav .count { background: var(--bad); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .45rem; }
.main { padding: 1.4rem 1.6rem 3rem; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.topbar .who { color: var(--muted); font-size: .88rem; }
.btn.menu-toggle { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; height: 100%; box-shadow: var(--shadow); }
  .shell.open .sidebar { transform: none; }
  .btn.menu-toggle { display: inline-flex; }
  .main { padding: 1rem 1rem 3rem; }
}

/* ---------- Komponen ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.45rem; font-weight: 650; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: .8rem; color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .45rem .8rem; border-radius: 8px; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: .25rem .55rem; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: .85rem; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
input:not([type]), input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .93rem;
}
textarea { min-height: 90px; font-family: var(--mono); font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .25rem; }
.error { color: var(--bad); font-size: .83rem; margin-top: .2rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.wrap { white-space: normal; max-width: 360px; }

.badge { display: inline-block; padding: .08rem .5rem; border-radius: 99px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.dir-in { color: var(--ok); font-weight: 600; }
.dir-out { color: var(--bad); font-weight: 600; }

.alert { border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.secret { font-family: var(--mono); background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 8px; padding: .6rem .8rem; word-break: break-all; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0; }
.chip { border: 1px solid var(--border); border-radius: 99px; padding: .2rem .7rem; font-size: .83rem; color: var(--text); background: var(--surface); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; align-items: end; }
.search { display: flex; gap: .5rem; }
.search input { font-size: 1rem; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 .9rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline .when { color: var(--muted); font-size: .8rem; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: .35rem .9rem; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: .4rem; } }

.pagination { display: flex; gap: .35rem; justify-content: flex-end; margin-top: .8rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* Grafik batang sederhana (SVG dibuat di server) */
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar-in { fill: var(--accent); }
.chart .bar-out { fill: var(--bad); opacity: .75; }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.legend .in::before { background: var(--accent); }
.legend .out::before { background: var(--bad); opacity: .75; }

/* ---------- Halaman tamu (login, daftar) ---------- */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.guest .box { width: 100%; max-width: 420px; }
.guest .brand { justify-content: center; font-size: 1.1rem; }

/* ---------- Halaman bayar ---------- */
.pay { max-width: 460px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.pay .merchant { text-align: center; margin-bottom: 1rem; }
.pay .amount { font-size: 2.1rem; font-weight: 750; text-align: center; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.pay .amount .code { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.pay .copyrow { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.pay .copyrow:last-child { border-bottom: 0; }
.pay .copyrow .v { font-weight: 650; font-size: 1.05rem; word-break: break-all; }
.pay .state { text-align: center; font-size: 1.05rem; font-weight: 650; padding: .7rem; border-radius: 8px; margin: .8rem 0; }
.pay .countdown { text-align: center; color: var(--muted); font-size: .9rem; }
.pay footer { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 1.5rem; }

/* ---------- Dokumentasi ---------- */
.docs { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.docs aside { border-right: 1px solid var(--border); padding: 1.2rem 1rem; background: var(--surface); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.docs aside h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .3rem; }
.docs aside a { display: block; padding: .22rem .4rem; border-radius: 6px; font-size: .9rem; color: var(--text); }
.docs aside a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.docs article { padding: 2rem 2.2rem 4rem; max-width: 900px; min-width: 0; }
.docs article table { margin: .6rem 0 1rem; border: 1px solid var(--border); }
.docs article h2 { border-bottom: 1px solid var(--border); padding-bottom: .3rem; margin-top: 2rem; }
@media (max-width: 860px) {
  .docs { grid-template-columns: 1fr; }
  .docs aside { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .docs article { padding: 1.2rem 1rem 3rem; }
}
.docs article .heading-permalink { margin-left: .4rem; color: var(--muted); opacity: 0; font-weight: 400; text-decoration: none; }
.docs article h2:hover .heading-permalink, .docs article h3:hover .heading-permalink { opacity: 1; }
.docs article blockquote { margin: 1rem 0; padding: .6rem 1rem; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.docs article blockquote p:last-child { margin-bottom: 0; }
.docs article li { margin: .2rem 0; }
.docs article img { max-width: 100%; }
.docs .pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.docs .search-box { margin-bottom: .6rem; }

/* ---------- Beranda ---------- */
.landing { max-width: 1040px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }
.landing header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .4rem 0 1.6rem; }
.landing .hero { padding: 2.4rem 0 2rem; max-width: 720px; }
.landing .hero h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 1.15; }
.landing .hero p { font-size: 1.08rem; color: var(--muted); }
.landing .steps { counter-reset: s; }
.landing .steps .card::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; margin-bottom: .5rem; }
.landing .price { font-size: 1.6rem; font-weight: 750; }
.landing footer { margin-top: 3rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); padding-top: 1rem; }
