/* ============================================================
 *  Flipbook — Admin / Dashboard styles
 * ============================================================ */
:root {
    --bg:        #0f1225;
    --bg-soft:   #171a35;
    --card:      #ffffff;
    --ink:       #1d2230;
    --ink-soft:  #5b6478;
    --line:      #e6e8f0;
    --brand:     #5b5bd6;
    --brand-dk:  #4646b8;
    --ok:        #12855f;
    --ok-bg:     #e5f6ee;
    --err:       #b42318;
    --err-bg:    #fdeceb;
    --warn:      #8a6d1a;
    --warn-bg:   #fdf5e2;
    --radius:    14px;
    --shadow:    0 10px 30px rgba(17, 20, 45, .12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: #f4f5fa;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Auth pages (login / install) ---------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(1200px 600px at 50% -10%, #2a2e63 0%, var(--bg) 60%);
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 30px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 26px; }
.brand h1 { font-size: 20px; margin: 0; }
.auth-card p.muted { margin-top: 6px; }

/* ---------- Top bar ---------- */
.topbar {
    background: var(--bg);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-in {
    max-width: 1080px;
    margin: 0 auto;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar .brand strong { font-size: 17px; }
.topbar .logo { font-size: 20px; }
.top-right { display: flex; align-items: center; gap: 14px; }
.top-right .muted { color: #b9bde0; font-size: 14px; }

/* ---------- Layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 26px 22px 60px; }
.wrap.narrow { max-width: 620px; }
.grid {
    display: grid;
    grid-template-columns: minmax(320px, 400px) 1fr;
    gap: 22px;
    align-items: start;
}
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

/* ---------- Stats ---------- */
.stats { display: flex; gap: 14px; margin-bottom: 22px; }
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 20px;
    min-width: 130px;
}
.stat .num { display: block; font-size: 26px; font-weight: 700; color: var(--brand); }
.stat .lbl { color: var(--ink-soft); font-size: 13px; }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.card h2 { margin: 0 0 16px; font-size: 17px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
label small { font-weight: 400; }
input[type=text], input[type=password], textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: #fbfbfe;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(91, 91, 214, .15);
    background: #fff;
}
textarea { resize: vertical; }
.req { color: var(--err); }

.slug-row {
    display: flex;
    align-items: stretch;
    margin-top: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fbfbfe;
}
.slug-row .slug-prefix {
    display: flex; align-items: center;
    padding: 0 10px;
    font-size: 12px;
    color: var(--ink-soft);
    background: #eef0f7;
    white-space: nowrap;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.slug-row input { border: 0; margin: 0; border-radius: 0; background: transparent; }
.slug-row input:focus { box-shadow: none; }

.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; margin: 0; }

/* File drop */
.file-drop {
    display: block;
    text-align: center;
    border: 2px dashed #c7cbe0;
    border-radius: 12px;
    padding: 22px 16px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    font-weight: 500;
}
.file-drop:hover, .file-drop.drag { border-color: var(--brand); background: #f5f5ff; }
.file-drop .file-icon { display: block; font-size: 22px; margin-bottom: 6px; }
.file-drop .file-text { display: block; }
.file-drop small { display: block; margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 18px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-dk); }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover { background: rgba(91,91,214,.08); }
.topbar .btn.ghost { color: #cfd2f4; border-color: #35396b; }
.topbar .btn.ghost:hover { background: #23264b; }
.btn.danger { background: #fff; color: var(--err); border-color: #f1c6c2; }
.btn.danger:hover { background: var(--err-bg); }
.btn.ok-flash { background: var(--ok); border-color: var(--ok); }
.upload-form .btn { width: 100%; margin-top: 4px; }

.row-btns { display: flex; gap: 10px; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert.ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid #bfe6d4; }
.alert.err  { background: var(--err-bg);  color: var(--err);  border: 1px solid #f3c6c2; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #ecdca6; }

/* ---------- Book list ---------- */
.empty { color: var(--ink-soft); padding: 24px 0; text-align: center; }
.book-list { display: flex; flex-direction: column; gap: 14px; }
.book {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fcfcff;
}
.book-main { min-width: 0; flex: 1; }
.book h3 { margin: 0 0 8px; font-size: 15px; }
.link-row { display: flex; gap: 8px; margin-bottom: 8px; }
.link-input {
    flex: 1;
    padding: 7px 10px;
    font-size: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink-soft);
    min-width: 0;
}
.book-meta { font-size: 12px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag {
    background: #e9f7f0; color: var(--ok);
    padding: 1px 8px; border-radius: 999px; font-weight: 600; font-size: 11px;
}
.tag.muted-tag { background: #eef0f7; color: var(--ink-soft); }
.book-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.inline-del { margin: 0; }
.inline-del .btn { width: 100%; }

/* ---------- Branding form ---------- */
.color-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.color-row input[type=color] {
    width: 46px; height: 38px; padding: 2px;
    border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer;
}
.hex-input { max-width: 140px; margin-top: 0 !important; }
.logo-preview {
    display: flex; align-items: center; gap: 14px;
    margin: 8px 0; padding: 12px;
    background: #f6f7fc; border: 1px solid var(--line); border-radius: 10px;
}
.logo-preview img { max-height: 46px; max-width: 180px; }
.remove-logo { margin: 0; font-weight: 500; font-size: 13px; }

/* ---------- Misc ---------- */
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
code { background: #eef0f7; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
a { color: var(--brand); }

/* ---- Upload progress (in-browser conversion) ---- */
.up-progress { margin-top: 14px; }
.up-progress.hidden { display: none; }
.up-track {
    height: 10px; border-radius: 999px;
    background: rgba(0,0,0,.08); overflow: hidden;
}
.up-bar {
    height: 100%; width: 0;
    background: linear-gradient(90deg, #5b5bd6, #8b8bf0);
    transition: width .25s ease;
}
.up-status { margin-top: 8px; font-size: 13px; color: #555; }
.up-result { margin-top: 10px; }
.up-ok   { font-size: 14px; color: #137333; }
.up-warn { font-size: 13px; color: #9a6700; margin-top: 6px; }
.up-links { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
