/* 모달 */
body.ebook-modal-open {
    overflow: hidden;
}

.ebook-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
}

.ebook-modal.is-open {
    display: block;
}

.ebook-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    cursor: pointer;
}

.ebook-modal-dialog {
    position: relative;
    z-index: 2;
    width: 96%;
    max-width: 1280px;
    height: 92vh;
    margin: 4vh auto 0;
    background: #2b2b2b;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.ebook-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: #1f1f1f;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ebook-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 16px;
}

.ebook-modal-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ebook-modal-download {
    display: inline-block;
    padding: 6px 12px;
    background: #035790;
    color: #fff !important;
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none !important;
}

.ebook-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.ebook-modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #333;
}

#ebook-modal-viewer {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ebook-modal-book-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ebook-modal-book {
    margin: 0 auto;
}

.ebook-modal-footer {
    padding: 10px 16px;
    background: #1f1f1f;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#ebook-modal-controls {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

#ebook-modal-controls button {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background: rgba(0, 123, 255, 0.85);
    color: #fff;
    cursor: pointer;
}

#ebook-modal-controls button:hover {
    background: #0056b3;
}

.ebook-pages-counter,
#ebook-modal-zoom-level {
    color: #fff;
    font-size: 14px;
    min-width: 48px;
    text-align: center;
}

/* 플립북 페이지 */
.page {
    background: #fff;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.page-content {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #fff;
    position: relative;
}

.page-content .page-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.ebook-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 58px;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    z-index: 5;
}

.ebook-nav.prev { left: 8px; border-radius: 0 6px 6px 0; }
.ebook-nav.next { right: 8px; border-radius: 6px 0 0 6px; }
.ebook-nav:hover { background: rgba(0, 0, 0, 0.7); }

/* 로딩 / 오류 */
.ebook-loading,
.ebook-error,
.ebook-download-link {
    text-align: center;
    color: #fff;
    padding: 30px;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.ebook-loading-text {
    margin: 0 0 14px;
    font-size: 15px;
}

.ebook-loading-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    overflow: hidden;
}

.ebook-loading-bar-fill {
    height: 100%;
    background: #4da3ff;
    transition: width 0.25s ease;
}

.page-pending {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    color: #888;
    font-size: 13px;
}

.page-pending-label {
    padding: 12px;
}

/* 새 창 뷰어 */
body.ebook-page-body {
    margin: 0;
    background: #2b2b2b;
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.ebook-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: #1f1f1f;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.ebook-page-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ebook-page-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ebook-page-btn {
    display: inline-block;
    padding: 7px 12px;
    background: #035790;
    color: #fff !important;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none !important;
    cursor: pointer;
}

.ebook-page-viewer {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
    min-height: 0;
}

.ebook-book-stage,
#book-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 2000px;
    -webkit-perspective: 2000px;
    overflow: visible;
}

#book-container.is-zoomed-view {
    overflow: hidden;
}

#book-zoom-wrap {
    transform-origin: center center;
    cursor: zoom-in;
}

#book-zoom-wrap.is-zoomed {
    cursor: grab;
    will-change: transform;
}

#book-zoom-wrap.is-dragging {
    cursor: grabbing;
}

#book {
    margin: 0 auto;
    position: relative;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    cursor: zoom-in;
}

#book .page {
    background: #fff;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.15);
}

#book .page-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    overflow: hidden;
}

#book .page-content canvas,
#book .page-content .page-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto !important;
    height: auto !important;
    margin: 0 auto;
    image-rendering: auto;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

#book .turn-page-wrapper {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.ebook-page-footer {
    padding: 10px 16px;
    background: #1f1f1f;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.ebook-page-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ebook-page-controls button {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background: rgba(0, 123, 255, 0.85);
    color: #fff;
    cursor: pointer;
}

#ebook-page-zoom-level {
    color: #fff;
    font-size: 14px;
    min-width: 48px;
    text-align: center;
}

.ebook-keyboard-hint {
    text-align: center;
    color: rgba(255,255,255,0.55);
    font-size: 12px;
    margin-top: 6px;
}

.ebook-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 72px;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    z-index: 30;
    pointer-events: auto;
}

.ebook-nav.prev { left: 8px; border-radius: 0 6px 6px 0; }
.ebook-nav.next { right: 8px; border-radius: 6px 0 0 6px; }

.ebook-page-controls button {
    pointer-events: auto;
    position: relative;
    z-index: 20;
}

.spinner {
    margin: 0 auto 16px;
    width: 70px;
    text-align: center;
}

.spinner > div {
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    display: inline-block;
    animation: ebook-bounce 1.4s infinite ease-in-out both;
}

.spinner .bounce1 { animation-delay: -0.32s; }
.spinner .bounce2 { animation-delay: -0.16s; }

@keyframes ebook-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.ebook-error {
    background: rgba(248, 215, 218, 0.15);
    border-radius: 6px;
    color: #f8d7da;
}

/* 목록 호버 */
.newsletter_list li .pic-wrap {
    position: relative;
    cursor: pointer;
}

.newsletter_list li .ebook-read-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    opacity: 0;
    transition: opacity 0.25s ease;
    font-size: 15px;
    font-weight: 600;
}

.newsletter_list li .pic-wrap:hover .ebook-read-overlay {
    opacity: 1;
}

.newsletter_list li.no-pdf .pic-wrap {
    cursor: default;
}

.newsletter_list li .thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f4f8;
    color: #035790;
    font-size: 48px;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

@media (max-width: 768px) {
    .ebook-modal-dialog {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .ebook-nav {
        width: 34px;
        height: 48px;
        font-size: 16px;
    }
}
