/* ==========================================================================
   Digital Flipbook — Global stylesheet
   Covers: public site, admin panel, auth, components.
   ========================================================================== */

:root {
    --dfb-primary: #3b5bfd;
    --dfb-primary-dark: #2a3fd0;
    --dfb-primary-soft: #eef1ff;
    --dfb-ink: #0f172a;
    --dfb-muted: #64748b;
    --dfb-line: #e2e8f0;
    --dfb-bg: #f6f8fc;
    --dfb-card: #ffffff;
    --dfb-radius: 14px;
    --dfb-radius-sm: 10px;
    --dfb-shadow: 0 10px 30px rgba(15, 23, 42, .08);
    --dfb-shadow-sm: 0 4px 14px rgba(15, 23, 42, .06);
    --dfb-sidebar: #0f172a;
    --dfb-sidebar-2: #16213b;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over component display rules. */
[hidden] { display: none !important; }

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--dfb-ink);
    background: var(--dfb-bg);
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ============================== PUBLIC NAVBAR ============================= */
.dfb-navbar {
    background: linear-gradient(90deg, #0f172a 0%, #1e2a4a 100%);
    box-shadow: var(--dfb-shadow-sm);
}
.dfb-navbar .navbar-brand { letter-spacing: .3px; }
.dfb-navbar .nav-link { color: rgba(255, 255, 255, .82); font-weight: 500; }
.dfb-navbar .nav-link:hover { color: #fff; }

.dfb-main { min-height: 60vh; }

.dfb-footer {
    background: #0f172a;
    color: #94a3b8;
}

/* ============================== HERO ===================================== */
.dfb-hero {
    position: relative;
    padding: 4rem 0 3rem;
    background:
        radial-gradient(1200px 500px at 85% -10%, rgba(59, 91, 253, .18), transparent 60%),
        radial-gradient(900px 400px at 0% 0%, rgba(14, 165, 233, .12), transparent 55%),
        linear-gradient(180deg, #ffffff 0%, #f6f8fc 100%);
    overflow: hidden;
}
.dfb-hero-eyebrow {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--dfb-primary-soft); color: var(--dfb-primary-dark);
    padding: .4rem .9rem; border-radius: 999px; font-size: .82rem; font-weight: 600;
}
.dfb-hero-title {
    font-size: clamp(2rem, 4vw, 3.1rem);
    font-weight: 800; line-height: 1.1; margin: 1rem 0;
}
.dfb-hero-title span {
    background: linear-gradient(90deg, var(--dfb-primary), #0ea5e9);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dfb-hero-sub { color: var(--dfb-muted); font-size: 1.08rem; max-width: 34rem; }
.dfb-hero-search {
    display: flex; align-items: center; gap: .5rem;
    background: #fff; border: 1px solid var(--dfb-line);
    border-radius: 999px; padding: .35rem .35rem .35rem 1rem;
    box-shadow: var(--dfb-shadow-sm); margin: 1.5rem 0; max-width: 34rem;
}
.dfb-hero-search i { color: var(--dfb-muted); }
.dfb-hero-search input {
    border: none; outline: none; flex: 1; padding: .5rem; background: transparent; font-size: 1rem;
}
.dfb-hero-search .btn { border-radius: 999px; padding: .55rem 1.4rem; }
.dfb-hero-stats { display: flex; gap: 2rem; margin-top: 1rem; }
.dfb-hero-stats strong { display: block; font-size: 1.5rem; font-weight: 800; }
.dfb-hero-stats span { color: var(--dfb-muted); font-size: .85rem; }

.dfb-hero-visual {
    display: flex; align-items: center; gap: 1.5rem;
    background: #fff; border-radius: 22px; padding: 1.5rem;
    box-shadow: var(--dfb-shadow);
}
.dfb-hero-book { flex: 0 0 170px; }
.dfb-hero-book img {
    width: 170px; height: 250px; object-fit: cover;
    border-radius: 12px; box-shadow: 0 18px 40px rgba(15, 23, 42, .28);
}
.dfb-hero-info h3 { font-weight: 700; margin: .6rem 0 .4rem; font-size: 1.25rem; }
.dfb-hero-empty { text-align: center; width: 100%; color: var(--dfb-muted); }
.dfb-hero-empty i { font-size: 3rem; color: var(--dfb-primary); }

/* ============================== SECTIONS ================================= */
.dfb-section { padding: 2.5rem 0; }
.dfb-section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.4rem;
}
.dfb-section-head h2 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.dfb-section-head h2 i { color: var(--dfb-primary); }
.dfb-link-more { color: var(--dfb-primary); font-weight: 600; font-size: .92rem; }
.dfb-link-more:hover { color: var(--dfb-primary-dark); }

/* ============================== BOOK GRID / CARD ========================= */
.dfb-book-grid {
    display: grid; gap: 1.4rem;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.dfb-book-grid-3 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.dfb-book-card {
    background: var(--dfb-card); border-radius: var(--dfb-radius);
    overflow: hidden; box-shadow: var(--dfb-shadow-sm);
    display: flex; flex-direction: column;
    transition: transform .22s ease, box-shadow .22s ease;
}
.dfb-book-card:hover { transform: translateY(-6px); box-shadow: var(--dfb-shadow); }

.dfb-book-cover {
    position: relative; display: block; aspect-ratio: 3 / 4; overflow: hidden; background: #eef1f7;
}
.dfb-book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dfb-book-badge {
    position: absolute; top: .6rem; right: .6rem;
    background: rgba(15, 23, 42, .78); color: #fff;
    font-size: .72rem; padding: .22rem .55rem; border-radius: 999px;
    backdrop-filter: blur(4px);
}
.dfb-cover-placeholder {
    width: 100%; height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: .5rem;
    background: linear-gradient(135deg, #1e293b, #334155); color: #cbd5e1;
    text-align: center; padding: 1rem;
}
.dfb-cover-placeholder i { font-size: 2.4rem; }
.dfb-cover-placeholder span { font-size: .82rem; font-weight: 600; }
.dfb-cover-placeholder-lg { border-radius: 14px; min-height: 320px; }
.dfb-cover-placeholder-lg i { font-size: 4rem; }

.dfb-book-body { padding: .9rem 1rem 1.1rem; display: flex; flex-direction: column; flex: 1; }
.dfb-book-cat {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    color: var(--dfb-primary); margin-bottom: .3rem; display: inline-block;
}
.dfb-book-title { font-size: 1rem; font-weight: 700; margin: 0 0 .35rem; line-height: 1.3; }
.dfb-book-title a { color: var(--dfb-ink); }
.dfb-book-title a:hover { color: var(--dfb-primary); }
.dfb-book-author { color: var(--dfb-muted); font-size: .85rem; margin: 0 0 .8rem; }
.dfb-book-actions { margin-top: auto; display: flex; gap: .5rem; }

/* ============================== CATEGORY CHIPS ========================== */
.dfb-category-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.dfb-category-chip {
    display: flex; flex-direction: column; gap: .2rem;
    background: #fff; border: 1px solid var(--dfb-line); border-radius: var(--dfb-radius);
    padding: 1.1rem; color: var(--dfb-ink); transition: all .2s ease;
}
.dfb-category-chip:hover { border-color: var(--dfb-primary); box-shadow: var(--dfb-shadow-sm); transform: translateY(-3px); }
.dfb-category-chip i { font-size: 1.6rem; color: var(--dfb-primary); }
.dfb-category-name { font-weight: 700; }
.dfb-category-count { color: var(--dfb-muted); font-size: .82rem; }

/* ============================== PAGE HEAD =============================== */
.dfb-page-head {
    background: linear-gradient(90deg, #0f172a, #1e2a4a);
    color: #fff; padding: 2.5rem 0;
}
.dfb-page-head h1 { font-weight: 800; }
.dfb-page-head .text-muted { color: #cbd5e1 !important; }
.dfb-page-head .breadcrumb-item a { color: #93c5fd; }
.dfb-page-head .breadcrumb-item.active { color: #cbd5e1; }

.dfb-inline-search { display: flex; gap: .5rem; max-width: 520px; }

/* ============================== FILTER ================================== */
.dfb-filter-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.dfb-filter-title i { color: var(--dfb-primary); }

/* ============================== BOOK DETAIL ============================= */
.dfb-book-detail { padding: 2rem 0; }
.dfb-detail-cover img {
    width: 100%; border-radius: 14px; box-shadow: var(--dfb-shadow);
}
.dfb-detail-title { font-size: 2rem; font-weight: 800; margin: .4rem 0; }
.dfb-detail-author { color: var(--dfb-muted); font-size: 1.02rem; }
.dfb-detail-meta {
    display: flex; flex-wrap: wrap; gap: 1.5rem;
    padding: 1rem 0; margin: 1rem 0; border-top: 1px solid var(--dfb-line); border-bottom: 1px solid var(--dfb-line);
}
.dfb-detail-meta div { color: var(--dfb-muted); font-size: .92rem; }
.dfb-detail-meta i { color: var(--dfb-primary); margin-right: .3rem; }
.dfb-detail-meta strong { color: var(--dfb-ink); }
.dfb-detail-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.2rem 0; }
.dfb-detail-desc h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: .6rem; }
.dfb-detail-desc p { color: #334155; line-height: 1.75; }

/* ============================== EMPTY STATE ============================= */
.dfb-empty-state {
    text-align: center; padding: 3.5rem 1rem;
    background: #fff; border: 1px dashed var(--dfb-line); border-radius: var(--dfb-radius);
}
.dfb-empty-state i { font-size: 3rem; color: var(--dfb-primary); }
.dfb-empty-state h3 { font-size: 1.2rem; font-weight: 700; margin: 1rem 0 .4rem; }

/* ============================== CARDS / GENERIC ========================= */
.dfb-card { border: 1px solid var(--dfb-line); border-radius: var(--dfb-radius); box-shadow: var(--dfb-shadow-sm); }
.dfb-card .card-header { background: #fff; border-bottom: 1px solid var(--dfb-line); font-weight: 700; }

/* ============================== AUTH ==================================== */
.dfb-auth {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(900px 500px at 80% 10%, rgba(59, 91, 253, .25), transparent 60%),
        linear-gradient(135deg, #0f172a, #1e293b);
    padding: 2rem 1rem;
}
.dfb-auth-card {
    width: 100%; max-width: 420px; background: #fff; border-radius: 20px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .4); padding: 2.2rem;
}
.dfb-auth-brand { text-align: center; margin-bottom: 1.5rem; }
.dfb-auth-brand i { font-size: 2.6rem; color: var(--dfb-primary); }
.dfb-auth-brand h1 { font-size: 1.4rem; font-weight: 800; margin: .5rem 0 0; }
.dfb-auth-brand p { color: var(--dfb-muted); font-size: .9rem; }

/* ============================== ADMIN LAYOUT ============================ */
.dfb-admin { background: var(--dfb-bg); }
.dfb-admin-layout { display: flex; min-height: 100vh; }

.dfb-sidebar {
    width: 260px; flex: 0 0 260px; background: var(--dfb-sidebar);
    color: #cbd5e1; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column;
}
.dfb-sidebar-brand {
    display: flex; align-items: center; gap: .6rem; padding: 1.2rem 1.4rem;
    font-weight: 800; color: #fff; font-size: 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.dfb-sidebar-brand i { color: #60a5fa; font-size: 1.4rem; }
.dfb-sidebar-nav { padding: 1rem .8rem; display: flex; flex-direction: column; gap: .15rem; }
.dfb-nav-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: 1px;
    color: #64748b; margin: 1rem .6rem .35rem; font-weight: 700;
}
.dfb-nav-item {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem;
    border-radius: 10px; color: #cbd5e1; font-size: .92rem; font-weight: 500;
    border: none; background: none; width: 100%; text-align: left; cursor: pointer;
}
.dfb-nav-item i { font-size: 1.05rem; width: 1.2rem; }
.dfb-nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.dfb-nav-item.active { background: var(--dfb-primary); color: #fff; box-shadow: 0 6px 16px rgba(59, 91, 253, .4); }
.dfb-nav-logout { color: #fca5a5; }
.dfb-nav-logout:hover { background: rgba(239, 68, 68, .15); color: #fecaca; }

.dfb-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dfb-topbar {
    display: flex; align-items: center; gap: 1rem;
    background: #fff; padding: .9rem 1.4rem; border-bottom: 1px solid var(--dfb-line);
    position: sticky; top: 0; z-index: 20;
}
.dfb-page-title { font-size: 1.2rem; font-weight: 700; margin: 0; }
.dfb-main-content { padding: 1.5rem; flex: 1; }
.dfb-admin-footer { padding: 1rem 1.5rem; color: var(--dfb-muted); font-size: .85rem; }

/* ============================== STAT CARDS ============================== */
.dfb-stat-card {
    background: #fff; border-radius: var(--dfb-radius); padding: 1.1rem 1.2rem;
    border: 1px solid var(--dfb-line); border-left: 4px solid var(--dfb-primary);
    box-shadow: var(--dfb-shadow-sm); height: 100%;
}
.dfb-stat-icon { font-size: 1.6rem; margin-bottom: .4rem; }
.dfb-stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.dfb-stat-label { color: var(--dfb-muted); font-size: .82rem; }

.dfb-rank {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--dfb-primary-soft); color: var(--dfb-primary-dark);
    font-weight: 700; font-size: .8rem;
}

/* ============================== MINI COVER ============================== */
.dfb-mini-cover {
    width: 42px; height: 56px; border-radius: 6px; overflow: hidden;
    background: #eef1f7; display: flex; align-items: center; justify-content: center;
    color: var(--dfb-muted);
}
.dfb-mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.dfb-cover-preview { max-width: 150px; border-radius: 8px; box-shadow: var(--dfb-shadow-sm); }

/* ============================== RESPONSIVE ============================== */
@media (max-width: 991.98px) {
    .dfb-sidebar {
        position: fixed; left: -280px; z-index: 1050; transition: left .25s ease; height: 100vh;
    }
    .dfb-sidebar.open { left: 0; }
    .dfb-hero-visual { flex-direction: column; text-align: center; }
    .dfb-hero-book { flex: none; }
    .dfb-hero-stats { justify-content: center; }
}
@media (max-width: 575.98px) {
    .dfb-book-grid { grid-template-columns: repeat(2, 1fr); gap: .9rem; }
    .dfb-book-title { font-size: .9rem; }
    .dfb-hero { padding: 2.5rem 0 2rem; }
    .dfb-hero-stats { gap: 1.2rem; }
}

/* Backdrop for mobile sidebar */
.dfb-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
    z-index: 1040; display: none;
}
.dfb-backdrop.show { display: block; }

/* ============================ PROCESS / RENDER ============================ */
.dfb-process-card { border: 1px solid var(--dfb-line); }
.dfb-process-card .card-header { background: #fff; font-weight: 600; }

/* Horizontal stepper */
.dfb-steps {
    list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1.25rem;
    counter-reset: dfbstep;
}
.dfb-steps li {
    flex: 1; display: flex; align-items: center; gap: .55rem;
    padding: .6rem .8rem; border-radius: var(--dfb-radius-sm);
    background: var(--dfb-bg); border: 1px solid var(--dfb-line);
    color: var(--dfb-muted); font-size: .86rem; font-weight: 600;
    transition: all .2s ease;
}
.dfb-step-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
    background: #e2e8f0; color: var(--dfb-muted); font-size: .95rem;
    transition: all .2s ease;
}
.dfb-steps li.is-active {
    background: var(--dfb-primary-soft); border-color: var(--dfb-primary);
    color: var(--dfb-primary-dark);
}
.dfb-steps li.is-active .dfb-step-dot { background: var(--dfb-primary); color: #fff; }
.dfb-steps li.is-done { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.dfb-steps li.is-done .dfb-step-dot { background: #10b981; color: #fff; }

/* Progress bar */
.dfb-progress-track { height: 1.15rem; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.dfb-progress-track .progress-bar { border-radius: 999px; transition: width .3s ease; }
.dfb-progress-stage { font-weight: 600; color: var(--dfb-ink); }
.dfb-progress-pct { font-weight: 700; color: var(--dfb-primary-dark); }
.dfb-progress-detail { margin-top: .5rem; font-size: .84rem; color: var(--dfb-muted); min-height: 1.2em; }

/* Spinner */
.dfb-spinner {
    width: 1.15rem; height: 1.15rem; border-radius: 50%;
    border: 2.5px solid rgba(59, 91, 253, .25); border-top-color: var(--dfb-primary);
    animation: dfb-spin .7s linear infinite;
}
@keyframes dfb-spin { to { transform: rotate(360deg); } }

.dfb-process-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Render-status badge in the book list */
.dfb-render-badge { font-size: .72rem; }
