/* ==========================================================
   Online flipbook-style PDF reader (reader.php)
   ========================================================== */
html, body.reader-body {
    height: 100%;
    margin: 0;
    background: #14202e;
}

.reader-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #14202e;
    color: #fff;
    font-family: var(--font-th, 'Sarabun', sans-serif);
}

/* ---------- top bar ---------- */
.reader-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    background: #0b2545;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex: 0 0 auto;
}
.reader-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff !important;
    font-weight: 600;
    font-size: 14px;
    opacity: 0.9;
}
.reader-back:hover { opacity: 1; color: var(--color-accent, #c9a24b) !important; }
.reader-back svg { width: 18px; height: 18px; }
.reader-close svg { width: 20px; height: 20px; }
.reader-doc-title {
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 10px;
}

/* ---------- body row: thumbs + stage ---------- */
.reader-body-row {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.reader-thumbs {
    width: 150px;
    flex: 0 0 150px;
    background: #0e1c2c;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: margin-left 0.2s ease, opacity 0.2s ease;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.reader-app.thumbs-hidden .reader-thumbs {
    margin-left: -170px;
    opacity: 0;
    pointer-events: none;
}
.reader-thumbs-loading {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}
.reader-thumb {
    cursor: pointer;
    text-align: center;
    border-radius: 6px;
    padding: 6px;
    border: 2px solid transparent;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.reader-thumb:hover { background: rgba(255,255,255,0.06); }
.reader-thumb.active { border-color: var(--color-accent, #c9a24b); background: rgba(201,162,75,0.12); }
.reader-thumb-canvas-wrap {
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}
.reader-thumb-canvas-wrap canvas { max-width: 100%; display: block; }
.reader-thumb span {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    margin-top: 4px;
}

.reader-stage {
    flex: 1 1 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: radial-gradient(ellipse at center, #1b2c40 0%, #0d1723 100%);
    padding: 20px;
}
.reader-status {
    color: rgba(255,255,255,0.85);
    font-size: 15px;
    text-align: center;
}
.reader-error p { margin-bottom: 14px; max-width: 360px; }

.reader-pages {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.reader-pages[hidden] { display: none; }
.reader-canvas {
    display: block;
    background: #fff;
    box-shadow: 0 10px 40px rgba(0,0,0,0.55);
    border-radius: 2px;
}
.reader-canvas[hidden] { display: none; }
.reader-canvas-b {
    position: absolute;
    top: 0;
    left: 0;
}

/* simple slide + fade "page turn" transition */
.reader-canvas.flip-out-left { transform: translateX(-36px); opacity: 0; transition: transform 0.3s ease, opacity 0.3s ease; }
.reader-canvas.flip-out-right { transform: translateX(36px); opacity: 0; transition: transform 0.3s ease, opacity 0.3s ease; }
.reader-canvas.flip-in-right { transform: translateX(36px); opacity: 0; transition: none; }
.reader-canvas.flip-in-left { transform: translateX(-36px); opacity: 0; transition: none; }
.reader-canvas.flip-settle { transform: translateX(0); opacity: 1; transition: transform 0.3s ease, opacity 0.3s ease; }

/* ---------- bottom toolbar ---------- */
.reader-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: #0b2545;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-wrap: wrap;
}
.reader-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.reader-btn svg { width: 18px; height: 18px; }
.reader-btn:hover { background: rgba(255,255,255,0.18); }
.reader-btn:active { transform: scale(0.94); }
.reader-btn[data-playing="1"], .reader-btn[data-on="0"] { background: var(--color-accent, #c9a24b); color: #0b2545; }
.reader-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.reader-btn-download {
    width: auto;
    padding: 0 16px;
    background: var(--color-accent, #c9a24b);
    color: #0b2545 !important;
    font-weight: 700;
    font-size: 13px;
}
.reader-btn-download:hover { background: var(--color-accent-dark, #a9822f); }

.reader-pagecount {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    margin: 0 8px;
    white-space: nowrap;
}
.reader-page-input {
    width: 44px;
    text-align: center;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    border-radius: 6px;
    padding: 6px 4px;
    font-size: 13px;
}

@media (max-width: 720px) {
    .reader-thumbs { width: 110px; flex-basis: 110px; }
    .reader-doc-title { font-size: 13px; }
    .reader-btn { width: 34px; height: 34px; }
    .reader-btn-download span { display: none; }
    .reader-btn-download { width: 34px; padding: 0; }
    .reader-pagecount { font-size: 12px; margin: 0 4px; }
}
