/* ==========================================================================
   Billing BRIAPI
   Tanpa framework CSS. Variabel warna mendukung mode terang dan gelap.
   ========================================================================== */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-alt: #f0f2f5;
    --border: #e2e5ea;
    --text: #14171c;
    --text-muted: #656d7a;
    --primary: #0b5cd5;
    --primary-hover: #094aad;
    --primary-soft: #e8f0fd;
    --success: #0d7a4a;
    --success-soft: #e3f5ec;
    --warning: #8a5a00;
    --warning-soft: #fdf2dc;
    --danger: #b3261e;
    --danger-soft: #fbe9e8;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
    --shadow-lg: 0 8px 28px rgba(16, 24, 40, .10);
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1116;
        --surface: #161a21;
        --surface-alt: #1d222b;
        --border: #2a303a;
        --text: #e8eaed;
        --text-muted: #9aa3b2;
        --primary: #5b9dff;
        --primary-hover: #7cb2ff;
        --primary-soft: #16243a;
        --success: #4ade80;
        --success-soft: #10261c;
        --warning: #fbbf24;
        --warning-soft: #2a2010;
        --danger: #f87171;
        --danger-soft: #2c1616;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-lg: 0 8px 28px rgba(0, 0, 0, .5);
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.075rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
code, .mono { font-family: var(--mono); }

.muted { color: var(--text-muted); }
.num { text-align: right; }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }
.empty { color: var(--text-muted); padding: 1.5rem 0; text-align: center; }

.truncate {
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Topbar ------------------------------------------------------------------ */

.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1.25rem;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { font-weight: 650; color: var(--text); text-decoration: none; }
.topnav { display: flex; gap: 1.1rem; margin-right: auto; }
.topnav a { color: var(--text-muted); text-decoration: none; font-size: .925rem; }
.topnav a:hover { color: var(--text); }
.logout { margin: 0; }

.checkout-header {
    display: flex;
    justify-content: center;
    padding: 1.5rem 1rem .5rem;
}

/* Layout ------------------------------------------------------------------ */

.container { max-width: 1040px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.checkout-container { max-width: 480px; margin: 0 auto; padding: .5rem 1rem 2rem; }
.checkout-body { background: var(--bg); }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    max-width: 1040px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2rem;
    color: var(--text-muted);
    font-size: .8rem;
}

.footer-center { justify-content: center; }

.env-badge {
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .68rem;
    padding: .15rem .45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
}

body.is-navigating { cursor: progress; }

/* Card -------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card-centered { text-align: center; max-width: 520px; margin: 3rem auto; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
}

/* Statistik --------------------------------------------------------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: .85rem;
    margin-bottom: 1.25rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.stat-label { color: var(--text-muted); font-size: .8rem; }
.stat-value { font-size: 1.35rem; font-weight: 650; letter-spacing: -.01em; }
.stat-meta { color: var(--text-muted); font-size: .78rem; }

/* Tabel ------------------------------------------------------------------- */

/* Tabel lebar menggulir di dalam wadahnya sendiri - body halaman tidak
   pernah menggulir horizontal. */
.table-scroll { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }

.table th {
    text-align: left;
    font-weight: 550;
    color: var(--text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td { padding: .7rem .6rem; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-alt); }

/* Badge ------------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 550;
    white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-alt); color: var(--text-muted); }

.text-danger { color: var(--danger); }

/* Form ringkas di dalam baris tabel atau header halaman. */
.form-inline {
    display: flex;
    gap: .4rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 0;
}

.form-inline input {
    padding: .35rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .875rem;
    min-width: 10rem;
}

.form-inline input:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
}

/* Tombol ------------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
}

.btn:hover { background: var(--surface-alt); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* Form -------------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { font-size: .85rem; font-weight: 550; }
.field em { font-style: normal; font-weight: 400; }

.field input {
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    width: 100%;
}

.field input:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    border-color: var(--primary);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }

@media (max-width: 560px) {
    .field-row { grid-template-columns: 1fr; }
}

/* Tab --------------------------------------------------------------------- */

.tabs { display: flex; gap: .35rem; margin-bottom: 1rem; flex-wrap: wrap; }

.tab {
    padding: .4rem .8rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: .875rem;
    border: 1px solid transparent;
}

.tab:hover { background: var(--surface-alt); }
.tab.is-active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft); }

/* Flash ------------------------------------------------------------------- */

.flash-stack {
    position: fixed;
    top: 68px;
    right: 1rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: min(380px, calc(100vw - 2rem));
}

.flash {
    padding: .7rem .9rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: .9rem;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: opacity .3s, transform .3s;
}

.flash.is-leaving { opacity: 0; transform: translateX(12px); }
.flash-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.flash-info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.notice { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.notice-success { background: var(--success-soft); color: var(--success); }
.notice-warning { background: var(--warning-soft); color: var(--warning); }
.notice-danger { background: var(--danger-soft); color: var(--danger); }

/* Detail invoice ---------------------------------------------------------- */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.detail-grid > div { display: flex; flex-direction: column; gap: .2rem; }
.detail-label { color: var(--text-muted); font-size: .78rem; }
.amount { font-size: 1.15rem; }

.channel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.channel-form { margin: 0; }

.channel-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .2rem;
    padding: .9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.channel-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.channel-btn:disabled { opacity: .6; cursor: not-allowed; }
.channel-btn span { color: var(--text-muted); font-size: .82rem; }

/* Halaman pembayaran ------------------------------------------------------ */

.pay-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem 1.25rem;
    text-align: center;
}

.pay-head { margin-bottom: 1rem; }
.pay-label { color: var(--text-muted); font-size: .82rem; margin-bottom: .15rem; }
.pay-amount { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .35rem; }

.pay-countdown {
    display: inline-flex;
    align-items: baseline;
    gap: .4rem;
    padding: .35rem .8rem;
    border-radius: 999px;
    background: var(--surface-alt);
    margin-bottom: 1.25rem;
}

.countdown-value { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.countdown-label { color: var(--text-muted); font-size: .78rem; }
.pay-countdown.is-urgent { background: var(--danger-soft); color: var(--danger); }

.qr-image {
    display: block;
    margin: 0 auto 1rem;
    width: 280px;
    height: 280px;
    max-width: 100%;
    background: #fff;
    padding: .5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.qr-fallback {
    display: block;
    word-break: break-all;
    font-size: .7rem;
    background: var(--surface-alt);
    padding: .6rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: left;
}

.va-number {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    flex-wrap: wrap;
    background: var(--surface-alt);
    border-radius: var(--radius);
    padding: .8rem;
    margin-bottom: 1rem;
}

.va-number code { font-size: 1.2rem; font-weight: 600; letter-spacing: .04em; }

.pay-steps {
    text-align: left;
    color: var(--text-muted);
    font-size: .86rem;
    margin: 0 0 1rem;
    padding-left: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.pay-foot { border-top: 1px solid var(--border); padding-top: 1rem; }

.pay-status-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    color: var(--text-muted);
    font-size: .82rem;
    margin-bottom: .75rem;
}

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse 1.6s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .35; transform: scale(.75); }
}

@media (prefers-reduced-motion: reduce) {
    .pulse { animation: none; }
    .flash { transition: none; }
}

.pay-result { padding: 1rem 0; }

.pay-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1rem;
}

.pay-result-success .pay-icon { background: var(--success-soft); color: var(--success); }
.pay-result-muted .pay-icon { background: var(--surface-alt); color: var(--text-muted); }

.pay-receipt {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .35rem .9rem;
    text-align: left;
    margin: 1.25rem 0 0;
    font-size: .86rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.pay-receipt dt { color: var(--text-muted); }
.pay-receipt dd { margin: 0; word-break: break-all; }

/* Error ------------------------------------------------------------------- */

.error-code { font-size: 3rem; font-weight: 700; color: var(--text-muted); margin: 0; }

.error-detail {
    text-align: left;
    font-size: .75rem;
    background: var(--surface-alt);
    padding: .8rem;
    border-radius: var(--radius);
    overflow-x: auto;
    max-height: 320px;
}
