/* =========================================================
   Bankpediaa Books — design system (single stylesheet)
   Direction: sophisticated SaaS / restrained enterprise.
   Bump ?v= on every referencing file when this changes.
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
    /* brand */
    --brand: #1877F2;
    --brand-dim: #1560C7;
    --brand-soft: #EAF2FE;
    --brand-ring: rgba(24, 119, 242, 0.15);

    /* neutrals */
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --faint: #94a3b8;
    --line: #e6eaf0;
    --line-2: #eef1f5;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #fafbfc;

    /* status */
    --success: #16a34a;
    --success-soft: #ecfdf3;
    --warning: #b45309;
    --warning-soft: #fef7ec;
    --danger: #dc2626;
    --danger-soft: #fef2f2;

    /* spacing scale */
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

    /* radius */
    --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-full: 9999px;

    /* elevation (3 real levels) */
    --e1: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
    --e2: 0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
    --e3: 0 24px 48px rgba(15,23,42,.14);

    /* type */
    --sans: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --text: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;

    --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--text);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dim); }
h1, h2, h3, h4 { font-family: var(--sans); color: var(--ink); margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

/* ---------- Layout helpers ---------- */
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap2 { gap: var(--s2); }
.row.gap3 { gap: var(--s3); }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: var(--s4); }
.mt2{margin-top:var(--s2)} .mt3{margin-top:var(--s3)} .mt4{margin-top:var(--s4)} .mt5{margin-top:var(--s5)} .mt6{margin-top:var(--s6)}
.page-head { margin-bottom: var(--s5); }
.page-head p { margin: 6px 0 0; color: var(--muted); }

/* =========================================================
   ADMIN SHELL — left sidebar + topbar + content
   ========================================================= */
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: var(--s5) var(--s4);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px var(--s5); }
.sidebar-brand .mark {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    background: var(--brand); color: #fff; display: grid; place-items: center;
    font-family: var(--sans); font-weight: 800; font-size: 17px;
}
.sidebar-brand b { font-family: var(--sans); font-size: 15px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.sidebar-brand span { font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.nav-section { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: var(--s4) 8px var(--s2); }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; margin-bottom: 2px;
    border-radius: var(--r-sm); font-size: 14px; font-weight: 600; color: var(--ink-2);
    transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-dim); }
.nav-link svg { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; padding-top: var(--s4); border-top: 1px solid var(--line-2); }
.sidebar-user { font-size: 13px; color: var(--muted); padding: 0 8px 8px; }
.sidebar-user b { display: block; color: var(--ink); font-family: var(--text); font-weight: 600; font-size: 14px; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
    height: 60px; background: var(--surface); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5);
    position: sticky; top: 0; z-index: 30;
}
.admin-topbar .crumb { font-family: var(--sans); font-weight: 700; font-size: 15px; }
.admin-content { padding: var(--s6) var(--s5); max-width: 1120px; width: 100%; }

.hamburger { display: none; background: none; border: 1px solid var(--line); border-radius: var(--r-sm); width: 38px; height: 38px; cursor: pointer; }
.hamburger svg { width: 20px; height: 20px; }

/* =========================================================
   CARDS
   ========================================================= */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--e1); }
.card-pad { padding: var(--s5); }
.card-head { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.card-head h2 { font-size: 16px; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; font-family: var(--sans); font-size: 14px; font-weight: 700;
    border: 1px solid transparent; border-radius: var(--r-sm); cursor: pointer;
    background: var(--brand); color: #fff; transition: background .14s, box-shadow .14s, transform .04s;
    white-space: nowrap; line-height: 1;
}
.btn svg { width: 17px; height: 17px; stroke-width: 2.2; }
.btn:hover { background: var(--brand-dim); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; color:#fff; }
.btn-danger-ghost { background: var(--surface); color: var(--danger); border-color: #f3c9c9; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

/* =========================================================
   FORMS
   ========================================================= */
.field { margin-bottom: var(--s4); }
.field > label { display: block; font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.field .req { color: var(--danger); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], select, textarea {
    width: 100%; padding: 10px 12px; font-family: var(--text); font-size: 14.5px; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
    transition: border-color .14s, box-shadow .14s;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-family: var(--mono); font-size: 14px; pointer-events: none; }
.input-prefix input { padding-left: 28px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s5); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--s3); align-items: center; padding-top: var(--s4); margin-top: var(--s2); border-top: 1px solid var(--line-2); }

/* toggle */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 42px; height: 24px; border-radius: var(--r-full); background: #cbd5e1; position: relative; transition: background .16s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--e1); transition: transform .16s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--brand-ring); }

/* file drop */
.filedrop {
    border: 1.5px dashed var(--line); border-radius: var(--r-md); padding: var(--s5);
    text-align: center; color: var(--muted); background: var(--surface-2); cursor: pointer; transition: border-color .14s, background .14s;
}
.filedrop:hover { border-color: var(--brand); background: var(--brand-soft); }
.filedrop svg { width: 26px; height: 26px; color: var(--faint); margin-bottom: 8px; }
.filedrop input { display: none; }
.filedrop b { color: var(--brand-dim); font-family: var(--sans); }

/* =========================================================
   BADGES
   ========================================================= */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; font-family: var(--sans); padding: 4px 9px; border-radius: var(--r-full); letter-spacing: .01em; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-published { background: var(--success-soft); color: var(--success); }
.badge-draft { background: var(--warning-soft); color: var(--warning); }
.badge-sample { background: var(--brand-soft); color: var(--brand-dim); }
.badge-neutral { background: var(--line-2); color: var(--muted); }

/* =========================================================
   TABLES
   ========================================================= */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; padding: 11px 16px; font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--line); }
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); font-size: 14px; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
.cell-title { font-family: var(--sans); font-weight: 700; color: var(--ink); }
.cover-thumb { width: 44px; height: 60px; border-radius: 6px; object-fit: cover; box-shadow: var(--e1); background: var(--line-2); }
.cover-thumb.placeholder { display: grid; place-items: center; color: var(--faint); }

/* row of chapters (reorderable list) */
.ch-list { display: flex; flex-direction: column; }
.ch-item { display: flex; align-items: center; gap: var(--s3); padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); margin-bottom: 8px; }
.ch-item .ord { font-family: var(--mono); font-size: 13px; color: var(--faint); width: 26px; text-align: center; }
.ch-item .ch-name { font-family: var(--sans); font-weight: 600; color: var(--ink); }
.ch-item .ch-part { font-size: 12px; color: var(--muted); }
.ch-move { display: flex; flex-direction: column; gap: 2px; }
.ch-move button { width: 26px; height: 20px; }

/* =========================================================
   STAT TILES
   ========================================================= */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s4); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4) var(--s5); box-shadow: var(--e1); }
.stat .num { font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* =========================================================
   ALERTS + EMPTY STATES
   ========================================================= */
.alert { padding: 12px 15px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: var(--s4); display: flex; gap: 10px; align-items: flex-start; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-error { background: var(--danger-soft); color: #991b1b; border: 1px solid #f5cccc; }
.alert-success { background: var(--success-soft); color: #14663b; border: 1px solid #b7ebc9; }
.alert-info { background: var(--brand-soft); color: var(--brand-dim); border: 1px solid #cfe2fc; }

.empty { text-align: center; padding: var(--s7) var(--s5); }
.empty .ico { width: 52px; height: 52px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto var(--s4); }
.empty .ico svg { width: 26px; height: 26px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 380px; margin: 0 auto var(--s5); }

/* =========================================================
   AUTH SCREENS
   ========================================================= */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s5); background: radial-gradient(120% 120% at 50% 0%, #eef4ff 0%, var(--bg) 55%); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--e2); padding: var(--s6); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s5); }
.auth-brand .mark { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-family: var(--sans); font-weight: 800; }
.auth-card h1 { font-size: 21px; margin-bottom: 4px; }

/* =========================================================
   PUBLIC STORE (foundation; expanded in Phase 2)
   ========================================================= */
.site-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-top .inner { max-width: 1080px; margin: 0 auto; padding: var(--s4) var(--s5); display: flex; align-items: center; justify-content: space-between; }
.site-wrap { max-width: 1080px; margin: 0 auto; padding: var(--s7) var(--s5); }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s5); }
.book-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--e1); overflow: hidden; transition: box-shadow .16s, transform .16s; }
.book-card:hover { box-shadow: var(--e2); transform: translateY(-2px); }
.book-card .cover { aspect-ratio: 3/4; background: var(--line-2); object-fit: cover; width: 100%; }
.book-card .body { padding: var(--s4); }
.book-card .body h3 { font-size: 15px; margin-bottom: 4px; }
.book-card .price { font-family: var(--mono); font-weight: 600; margin-top: 10px; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed; z-index: 60; left: 0; top: 0; transform: translateX(-100%);
        transition: transform .22s ease; box-shadow: var(--e3);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .hamburger { display: inline-grid; place-items: center; }
    .admin-content { padding: var(--s5) var(--s4); }
    .sidebar-scrim { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
    .sidebar-scrim.show { opacity: 1; pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
