/* ===== eBook Admin – modern UI ===== */
:root {
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --bg: #f5f6fb;
    --surface: #ffffff;
    --line: #e8eaf2;
    --text: #1e2235;
    --muted: #6b7189;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
    --sidebar-w: 260px;
    --bs-primary: var(--brand);
    --bs-primary-rgb: 79, 70, 229;
    --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
[data-bs-theme="dark"] {
    --bg: #0f1220;
    --surface: #171b2e;
    --line: #262b45;
    --text: #e6e8f2;
    --muted: #9298b3;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
}
body { background: var(--bg); color: var(--text); font-family: var(--bs-body-font-family); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
.min-w-0 { min-width: 0; }

.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; box-shadow: 0 4px 14px rgba(79, 70, 229, .25); }
.btn-light { --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line); --bs-btn-color: var(--text); --bs-btn-hover-bg: var(--bg); --bs-btn-hover-border-color: var(--line); --bs-btn-hover-color: var(--text); }
.btn-icon { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; border-radius: 10px; color: var(--muted); border: 0; background: transparent; }
.btn-icon:hover { background: var(--bg); color: var(--brand); }
.btn-icon.btn-sm { width: 28px; height: 28px; }
.form-control, .form-select { border-radius: 10px; border-color: var(--line); background-color: var(--surface); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }
.form-label { font-weight: 600; font-size: .875rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.modal-content { border: 0; border-radius: 18px; box-shadow: 0 24px 60px rgba(16, 24, 40, .25); background: var(--surface); }
.modal-header, .modal-footer { border-color: var(--line); }

/* ===== Layout ===== */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--line); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040; transition: transform .25s; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.4rem 1.4rem 1rem; font-size: 1.2rem; color: var(--text); font-weight: 600; }
.brand b { color: var(--brand); font-weight: 800; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 6px 16px rgba(79, 70, 229, .35); }
.brand-logo.lg { width: 60px; height: 60px; font-size: 1.7rem; border-radius: 16px; }
.side-nav { padding: .5rem .9rem; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-label { text-transform: uppercase; letter-spacing: .08em; font-size: .68rem; color: var(--muted); padding: 1rem .75rem .4rem; font-weight: 700; }
.side-nav a { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: .93rem; }
.side-nav a i { font-size: 1.05rem; }
.side-nav a:hover { background: var(--bg); color: var(--text); }
.side-nav a.active { background: rgba(79, 70, 229, .1); color: var(--brand); font-weight: 600; }
.side-foot { display: flex; gap: .7rem; align-items: center; padding: 1rem 1.2rem; border-top: 1px solid var(--line); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--brand); background: rgba(79, 70, 229, .12); flex-shrink: 0; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .85rem 2rem; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); }
.top-search { flex: 1; max-width: 560px; position: relative; }
.top-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-search input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: .6rem 1rem .6rem 2.5rem; color: var(--text); outline: none; }
.top-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }
.topbar #themeToggle { margin-left: auto; }
.content { padding: .5rem 2rem 3rem; }
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; }
    .sidebar-open .sidebar { transform: none; }
    .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 1030; }
    .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
}

/* ===== Page parts ===== */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .85rem; margin: .5rem 0 1rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }
.crumbs > * + *::before { content: '›'; margin-right: .4rem; color: var(--line); }
.crumbs span { color: var(--text); font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.6rem; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.page-head p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }

.card-x { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-x-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-x-head h5 { margin: 0; font-size: 1rem; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.search-inline { position: relative; width: 100%; max-width: 320px; }
.search-inline i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-inline input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .8rem .5rem 2.2rem; background: var(--bg); color: var(--text); outline: none; }
.search-inline input:focus { border-color: var(--brand); background: var(--surface); }
.search-hero { display: flex; gap: .5rem; position: relative; max-width: 720px; }
.search-hero i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.1rem; }
.search-hero input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem .8rem 2.8rem; background: var(--surface); color: var(--text); font-size: 1.05rem; outline: none; }

/* ===== Stats ===== */
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); height: 100%; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 1.15rem; margin-bottom: .8rem; color: var(--t); background: color-mix(in srgb, var(--t) 12%, transparent); }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.tone-indigo { --t: #4f46e5; } .tone-teal { --t: #0d9488; } .tone-rose { --t: #e11d48; }
.tone-amber { --t: #d97706; } .tone-sky { --t: #0284c7; } .tone-violet { --t: #7c3aed; }

/* ===== Lists ===== */
.list-x-item { display: flex; align-items: center; gap: .9rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--line); color: var(--text); }
.list-x-item:last-child { border-bottom: 0; }
a.list-x-item:hover { background: var(--bg); }
.rank { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--bg); color: var(--muted); }
.list-head { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem .6rem 3.3rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); background: var(--bg); }

.sort-list { list-style: none; margin: 0; padding: 0; }
.sort-item { display: flex; align-items: center; gap: .9rem; padding: .85rem 1.25rem .85rem .6rem; border-bottom: 1px solid var(--line); background: var(--surface); transition: background .15s; }
.sort-item:last-child { border-bottom: 0; }
.sort-item:hover { background: color-mix(in srgb, var(--brand) 3%, var(--surface)); }
.sort-item.selected { background: color-mix(in srgb, var(--brand) 7%, var(--surface)); }
.drag-handle { cursor: grab; color: var(--muted); opacity: .5; padding: .3rem; font-size: 1.1rem; }
.sort-item:hover .drag-handle { opacity: 1; }
:not([data-sortable]) > .sort-item .drag-handle { visibility: hidden; }
.sort-ghost { opacity: .4; background: rgba(79, 70, 229, .08) !important; }
.sort-chosen { box-shadow: 0 10px 30px rgba(16, 24, 40, .15); border-radius: 12px; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); cursor: pointer; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-main:hover .item-title { color: var(--brand); }
.item-actions { display: flex; gap: 2px; }
.chips { gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.cat-icon { --c: #4f46e5; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; font-size: 1.15rem; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.cat-icon.lg { width: 56px; height: 56px; font-size: 1.5rem; border-radius: 15px; }
.num-badge { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: rgba(79, 70, 229, .1); color: var(--brand); flex-shrink: 0; }
.file-badge { width: 40px; height: 46px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; font-size: .66rem; font-weight: 800; letter-spacing: .04em; color: #fff; background: linear-gradient(160deg, #f43f5e, #be123c); box-shadow: 0 4px 10px rgba(225, 29, 72, .25); }
.file-badge.sm { width: 28px; height: 32px; font-size: .55rem; }

.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty-state > i { font-size: 2.8rem; display: inline-grid; place-items: center; width: 84px; height: 84px; border-radius: 24px; background: var(--bg); color: var(--brand); margin-bottom: 1rem; }
.empty-state.small { padding: 2rem 1rem; }
.empty-state.small > i { width: 60px; height: 60px; font-size: 1.8rem; }
.empty-state h5 { color: var(--text); font-weight: 700; }

/* ===== Icon picker ===== */
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-picker input { display: none; }
.icon-picker span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); cursor: pointer; color: var(--muted); }
.icon-picker input:checked + span { border-color: var(--brand); background: rgba(79, 70, 229, .1); color: var(--brand); }

/* ===== Upload zone ===== */
.dropzone-x { border: 2px dashed color-mix(in srgb, var(--brand) 35%, var(--line)); border-radius: var(--radius); background: color-mix(in srgb, var(--brand) 3%, var(--surface)); padding: 1.75rem; transition: .2s; }
.dropzone-x.drag { border-color: var(--brand); background: rgba(79, 70, 229, .08); transform: scale(1.005); }
.dz-idle { text-align: center; color: var(--muted); }
.dz-idle > i { font-size: 2.4rem; color: var(--brand); display: block; margin-bottom: .4rem; }
.dz-idle b { color: var(--text); }
.dz-files { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow: auto; }
.dz-files li { display: flex; align-items: center; gap: .7rem; padding: .45rem .6rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 6px; }
.pdf-frame { width: 100%; height: 78vh; border: 0; display: block; border-radius: 0 0 18px 18px; }

/* ===== Toasts ===== */
.toast-x { border: 0; border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 24, 40, .18); background: var(--surface); min-width: 280px; }
.toast-x i.bi { font-size: 1.15rem; }
.toast-success i.bi { color: #16a34a; }
.toast-danger i.bi { color: #e11d48; }
.swal2-popup { border-radius: 18px !important; font-family: var(--bs-body-font-family) !important; }

/* ===== Login ===== */
.login-page { background: var(--surface); }
.login-wrap { display: flex; min-height: 100vh; }
.login-art { flex: 1; display: flex; align-items: center; padding: 4rem; color: #fff; background: radial-gradient(circle at 20% 20%, #6366f1, transparent 50%), radial-gradient(circle at 80% 80%, #a855f7, transparent 50%), #312e81; }
.login-art h1 { font-weight: 800; font-size: 2.6rem; letter-spacing: -.03em; }
.login-art p, .login-art li { opacity: .85; max-width: 380px; }
.login-art .brand-logo { background: rgba(255, 255, 255, .15); box-shadow: none; }
.login-form { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon .form-control { padding-left: 2.6rem; font-size: 1rem; }
@media (max-width: 767.98px) { .login-art { display: none; } }
