/* RastQR Gateway: admin panel + checkout styles (no build step required) */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --text: #18212f;
    --muted: #5f6b7a;
    --border: #e3e7ec;
    --primary: #0f766e;
    --primary-strong: #0b5c56;
    --primary-soft: #e6f4f2;
    --success: #067647;
    --success-soft: #e7f6ec;
    --warning: #9a5b00;
    --warning-soft: #fff4e0;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --info: #1d4ed8;
    --info-soft: #e8efff;
    --neutral-soft: #eef0f3;
    --sidebar: #111a24;
    --sidebar-text: #c6ced8;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }

p { margin: 0 0 .75rem; }

code, .mono { font-family: var(--mono); font-size: .9em; }

[hidden] { display: none !important; }

/* ---------- Admin layout ---------- */

.admin {
    display: grid;
    grid-template-columns: 236px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 1.25rem .75rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 0 .6rem 1.25rem;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--primary);
    display: grid;
    place-items: center;
    font-size: .8rem;
}

.nav-section {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #7d8896;
    padding: 1rem .6rem .35rem;
}

.nav a {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--sidebar-text);
    padding: .5rem .6rem;
    border-radius: 7px;
    font-weight: 500;
}

.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(15, 118, 110, .28); color: #fff; }

.main { min-width: 0; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-user { display: flex; align-items: center; gap: .9rem; color: var(--muted); }

.content { padding: 1.5rem 1.75rem 3rem; max-width: 1280px; }

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

.page-head p { color: var(--muted); margin: 0; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Cards & grids ---------- */

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

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1.15rem;
    border-bottom: 1px solid var(--border);
}

.card-head h2 { margin: 0; font-size: 1rem; }
.card-body { padding: 1.15rem; }
.card-body > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.15rem;
}

.stat-label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-top: .2rem; }
.stat-note { color: var(--muted); font-size: .8rem; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
    text-align: left;
    padding: .65rem 1.15rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfd; }

td.num, th.num { text-align: right; white-space: nowrap; }

.empty { padding: 2rem 1.15rem; text-align: center; color: var(--muted); }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: .5rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- Badges & alerts ---------- */

.badge {
    display: inline-block;
    padding: .12rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: var(--neutral-soft);
    color: var(--muted);
    white-space: nowrap;
}

.badge--paid, .badge--decoded, .badge--active, .badge--success { background: var(--success-soft); color: var(--success); }
.badge--pending, .badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--failed, .badge--unsupported, .badge--danger, .badge--cancelled { background: var(--danger-soft); color: var(--danger); }
.badge--expired, .badge--inactive { background: var(--neutral-soft); color: var(--muted); }
.badge--info { background: var(--info-soft); color: var(--info); }

.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}

.alert--success { background: var(--success-soft); color: var(--success); border-color: #b7e3c6; }
.alert--danger { background: var(--danger-soft); color: var(--danger); border-color: #f6c6c0; }
.alert--warning { background: var(--warning-soft); color: var(--warning); border-color: #f5d79e; }
.alert--info { background: var(--info-soft); color: var(--info); border-color: #c6d6fb; }
.alert ul { margin: .25rem 0 0; padding-left: 1.2rem; }

.secret-box {
    font-family: var(--mono);
    background: #0f1720;
    color: #d8f3ee;
    padding: .7rem .9rem;
    border-radius: 8px;
    word-break: break-all;
    margin: .4rem 0 .8rem;
    user-select: all;
}

/* ---------- Forms ---------- */

.form-row { margin-bottom: 1rem; }

label { display: block; font-weight: 600; margin-bottom: .3rem; }

.hint { color: var(--muted); font-size: .8rem; margin-top: .25rem; font-weight: 400; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=date], input[type=file], select, textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid #cfd5dc;
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(15, 118, 110, .25);
    border-color: var(--primary);
}

.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 500; }

.fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .9rem 1rem .2rem; margin: 0 0 1rem; }
.fieldset legend { font-weight: 700; padding: 0 .35rem; }
textarea.mono { font-family: var(--mono); font-size: .85rem; }
details summary { cursor: pointer; }
.checkbox input { width: auto; }

.field-error { color: var(--danger); font-size: .8rem; margin-top: .25rem; }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filters .form-row { margin: 0; min-width: 150px; }
.filters label { font-size: .75rem; color: var(--muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem .95rem;
    border-radius: 7px;
    border: 1px solid #cfd5dc;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-strong); }
.btn--danger { color: var(--danger); border-color: #f0b5ad; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--sm { padding: .3rem .6rem; font-size: .8rem; }
.btn--block { width: 100%; }

.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs a { padding: .55rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.pagination { display: flex; gap: .3rem; padding: .9rem 1.15rem; flex-wrap: wrap; align-items: center; }
.pagination .page { padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.pagination .page.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page.disabled { color: #b5bdc7; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .6rem 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .time { color: var(--muted); font-size: .8rem; }

pre.json {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem .8rem;
    font-size: .78rem;
    overflow-x: auto;
    margin: .35rem 0 0;
    max-height: 260px;
}

.muted { color: var(--muted); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

.inline-form { display: inline; }

/* ---------- Auth ---------- */

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { color: var(--text); justify-content: center; padding-bottom: 1rem; }
.auth-card .brand-mark { color: #fff; }

/* ---------- Checkout ---------- */

.checkout-body {
    background: linear-gradient(180deg, #e9f4f2 0%, var(--bg) 280px);
    min-height: 100vh;
    padding: 1.5rem 1rem;
}

.checkout {
    max-width: 420px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(16, 24, 40, .08);
    overflow: hidden;
}

.checkout-header { text-align: center; padding: 1.5rem 1.5rem 1rem; }
.checkout-merchant { color: var(--muted); font-weight: 600; }
.checkout-amount { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; margin-top: .2rem; }
.checkout-amount .currency { font-size: 1rem; font-weight: 700; color: var(--muted); margin-right: .2rem; }
.checkout-description { color: var(--muted); font-size: .9rem; margin-top: .25rem; }

.checkout-qr { padding: 0 1.5rem; }

.qr-frame {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1;
    margin: 0 auto;
    padding: .5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.qr-frame svg { width: 100%; height: 100%; display: block; }
.qr-frame.is-hidden { display: none; }

.qr-state { text-align: center; padding: 1.25rem .5rem .5rem; }
.qr-state p { color: var(--muted); }
.qr-state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto .75rem;
    display: grid;
    place-items: center;
    font-size: 1.8rem;
}
.qr-state--expired .qr-state-icon { background: var(--neutral-soft); }
.qr-state--paid .qr-state-icon { background: var(--success-soft); color: var(--success); }
.qr-state--failed .qr-state-icon { background: var(--danger-soft); color: var(--danger); }

.checkout-timer { padding: 1rem 1.5rem 0; }
.timer-row { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; }
.timer-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.timer-bar { height: 6px; background: var(--neutral-soft); border-radius: 99px; overflow: hidden; margin-top: .4rem; }
.timer-bar-fill { height: 100%; width: 100%; background: var(--primary); transition: width .25s linear; }
.checkout-timer.is-urgent .timer-bar-fill { background: var(--danger); }
.checkout-timer.is-urgent strong { color: var(--danger); }

.checkout-details { margin: 1.25rem 1.5rem 0; padding: 0; border-top: 1px solid var(--border); }
.checkout-details > div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.checkout-details dt { color: var(--muted); }
.checkout-details dd { margin: 0; text-align: right; word-break: break-all; }

.checkout-steps { margin: 1rem 1.5rem 1.5rem; padding-left: 1.2rem; color: var(--muted); font-size: .9rem; }
.checkout-steps li { margin-bottom: .2rem; }
.checkout-redirect { text-align: center; color: var(--muted); padding: 0 1.5rem 1.5rem; }

/* ---------- Docs ---------- */

.docs { max-width: 900px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.docs h2 { margin-top: 2rem; padding-top: .5rem; border-top: 1px solid var(--border); }
.docs pre {
    background: #0f1720;
    color: #dbe5ee;
    padding: 1rem;
    border-radius: 10px;
    overflow-x: auto;
    font-size: .82rem;
    line-height: 1.55;
}
.docs table { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin: .5rem 0 1rem; }

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .admin { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .nav { display: flex; flex-wrap: wrap; gap: .25rem; }
    .nav-section { width: 100%; padding-top: .5rem; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .content, .topbar { padding-left: 1rem; padding-right: 1rem; }
    .kv { grid-template-columns: 1fr; }
}
