.doh-ebook {
    --control-ebook-bg: #4361ee;
    --control-ebook-hover: #3a56d4;
    --doh-ebook-primary: #0054A6;
}
/* =================================================
   Ebook Controls (Classic Style – ของเดิม)
================================================= */
.ebook-controls {
    position: relative;
    margin: 24px auto 0;
    padding: 12px 20px;
    max-width: 900px;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;

    background: #ffffff;
    border-radius: 50px;
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
}

/* กลุ่มปุ่ม */
.ebook-controls .control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =================================================
   Buttons (กลม แบบเดิม)
================================================= */
.ebook-controls button,
.ctrl-btn {
    width: 47px;
    height: 47px;
    border-radius: 50%;
    border: none;

    background: var(--control-ebook-bg);
    color: #fff;
    font-size: 18px;
    font-weight: 600;

    cursor: pointer;
    transition: all .25s ease;

    box-shadow: 0 4px 12px rgba(67,97,238,.4);
}

/* Hover */
.ebook-controls button:hover:not(:disabled),
.ctrl-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    background: var(--control-ebook-hover);
    box-shadow: 0 6px 16px rgba(67,97,238,.55);
}

/* Disabled */
.ebook-controls button:disabled,
.ctrl-btn:disabled {
    background: #b0b0b0;
    cursor: not-allowed;
    box-shadow: none;
}

/* =================================================
   Page Indicator (pill แบบเดิม)
================================================= */
.page-indicator {
    padding: 6px 14px;
    background: #ffffff;
    border-radius: 20px;

    font-weight: 600;
    font-size: 14px;

    border: 1px solid #ddd;
    color: var(--doh-ebook-primary);

    min-width: 90px;
    text-align: center;
}

/* =================================================
   Responsive
================================================= */
@media (max-width: 768px) {
    .ebook-controls {
        flex-wrap: wrap;
        gap: 10px;
        padding: 14px;
    }

    .ebook-controls .control-group.center {
        width: 100%;
        justify-content: center;
        order: 3;
    }
}

.flipbook-container {
    width: 100%;
    min-height: 80vh;

    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
}

.flipbook-wrapper {
    position: relative;
    width: 100%;
    max-width: 900px;

    aspect-ratio: 3 / 4;      /* สัดส่วนหนังสือ */
    min-height: 400px;
    max-height: 80vh;

    display: flex;
    justify-content: center;
    align-items: center;

    perspective: 1800px;
    overflow: visible;

    --zoom:1;
    --tx:0px;
    --ty:0px;
}

#ebook-loading {
    position: absolute;
    inset: 0;                /* 👈 เต็มพื้นที่ wrapper */
    z-index: 999;

    display: flex;
    flex-direction: column;
    justify-content: center; /* 👈 กลางแนวตั้ง */
    align-items: center;     /* 👈 กลางแนวนอน */
    gap: 12px;

    background: rgba(255,255,255,0.95);
    text-align: center;
}

#ebook-loading .loading-percent {
    font-size: 18px;
    font-weight: 600;
    color: #3f6cff;


}

.flipbook-wrapper:fullscreen {
    background: #000;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: auto;
}

/* ตัวหนังสือ */
.flipbook-wrapper:fullscreen #flipbook {
    width: 100%;
    height: 100%;
}

.flipbook-wrapper:fullscreen .ebook-controls {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    background: rgba(0,0,0,0.45);
    padding: 8px 12px;
    border-radius: 10px;
    z-index: 9999;
}

#flipbook {
    max-width:100%;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;

    transform: translate(var(--tx), var(--ty)) scale(var(--zoom));
    transform-origin: center center;
    transition: transform .1s;
    cursor: grab;
}

#flipbook.dragging{
    cursor: grabbing;
}

/* ปกติ */
.flipbook-wrapper:not(:fullscreen) .stf__block {
    transform: scale(var(--zoom));
    transform-origin: center center;
}

/* fullscreen → ปล่อยให้ JS / PageFlip คุม */
.flipbook-wrapper:fullscreen .stf__block {
    transform: none !important;
}

/* ตอน fullscreen */
.flipbook-wrapper.is-fullscreen {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.flipbook-wrapper canvas {
    display: block;
    margin: auto;
}

.stats-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: -35px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #ffffff;
    padding: 18px 22px;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    min-width: 260px;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #0d6efd;
}

.bg-soft-primary {
    background: #eaf2ff;
}

.stat-content {
    line-height: 1.2;
}

.stat-number {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0d6efd;
}

.stat-label {
    font-size: 0.95rem;
    color: #6c757d;
    margin-top: 4px;
}

/* mobile */
@media (max-width: 768px) {
    .stats-container {
        flex-direction: column;
    }

    .stat-card {
        width: 100%;
    }
}

.content-tag-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.content-tag {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #dee2e6;
    background: #0dcaf026;
    color: #0d6efd;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: default;
    transition: all .2s ease;
    user-select: none;
}

.content-tag:hover {
    background: #0054A6;
    border-color: #0d6efd;
    cursor: pointer;
    color: #fff;
}

@media (max-width:768px){

    .flipbook-wrapper{
         max-width:420px !important;
        aspect-ratio: 3 / 4;   /* หน้าเดียว */
    }

}

@media (min-width:769px){

    .flipbook-wrapper{
        max-width:900px;
        aspect-ratio: 6 / 4;   /* 2 หน้า */
    }

}

