/* =========================================================================
   Adilisha Agenda 2049 – Flipbook Viewer
   Realistic page-flip PDF reader (PDF.js + StPageFlip).
   Scoped under .agenda-flipbook to avoid clashing with global styles.
   ========================================================================= */

:root {
    --agenda-primary: #0d78b8;
    --agenda-primary-dark: #095a8c;
    --agenda-ink: #1b2733;
    --agenda-surface: #eef2f6;
}

.agenda-flipbook {
    position: relative;
    width: 100%;
    background: radial-gradient(circle at 50% 0%, #f4f7fa 0%, var(--agenda-surface) 60%, #e2e8ee 100%);
    border-radius: 14px;
    padding: 1.5rem 1rem 2rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    overflow: hidden;
}

/* ---- Toolbar ---------------------------------------------------------- */
.agenda-flipbook__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
    padding: 0.5rem 0.65rem;
    background: #ffffff;
    border: 1px solid #e2e8ee;
    border-radius: 50px;
    box-shadow: 0 6px 18px rgba(13, 120, 184, 0.08);
    max-width: max-content;
    margin-left: auto;
    margin-right: auto;
}

.agenda-flipbook__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 40px;
    height: 40px;
    padding: 0 0.75rem;
    border: none;
    border-radius: 50px;
    background: transparent;
    color: var(--agenda-ink);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.agenda-flipbook__btn:hover:not(:disabled),
.agenda-flipbook__btn:focus-visible {
    background: var(--agenda-primary);
    color: #fff;
    outline: none;
}

.agenda-flipbook__btn:active:not(:disabled) {
    transform: translateY(1px);
}

.agenda-flipbook__btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.agenda-flipbook__btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.agenda-flipbook__divider {
    width: 1px;
    height: 24px;
    background: #e2e8ee;
    margin: 0 0.25rem;
}

.agenda-flipbook__pageinfo {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--agenda-ink);
    white-space: nowrap;
    padding: 0 0.35rem;
}

.agenda-flipbook__page-input {
    width: 52px;
    height: 32px;
    text-align: center;
    border: 1px solid #d4dde6;
    border-radius: 8px;
    font-weight: 700;
    color: var(--agenda-primary-dark);
    -moz-appearance: textfield;
}

.agenda-flipbook__page-input::-webkit-outer-spin-button,
.agenda-flipbook__page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---- Stage (book + thumbnails) ---------------------------------------- */
.agenda-flipbook__stage {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    justify-content: center;
}

.agenda-flipbook__book-area {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 440px;
    overflow: auto;
}

/* zoom wrapper – scaled via transform.
   Full width is required so StPageFlip measures the real available space
   (a shrink-wrapped flex child would collapse it to single-page mode). */
.agenda-flipbook__zoom {
    width: 100%;
    transform-origin: center center;
    transition: transform 0.25s ease;
    will-change: transform;
}

#agenda-book {
    width: 100%;
    margin: 0 auto;
}

/* StPageFlip page surface */
.agenda-flipbook .page {
    background: #fff;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.agenda-flipbook .page canvas,
.agenda-flipbook .page img {
    width: 100%;
    height: 100%;
    display: block;
}

/* per-page loading placeholder */
.agenda-flipbook .page__loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, #f3f6f9 25%, #e8edf2 50%, #f3f6f9 75%);
    background-size: 200% 100%;
    animation: agenda-shimmer 1.4s infinite;
}

.agenda-flipbook .page__loader::after {
    content: '';
    width: 28px;
    height: 28px;
    border: 3px solid rgba(13, 120, 184, 0.25);
    border-top-color: var(--agenda-primary);
    border-radius: 50%;
    animation: agenda-spin 0.8s linear infinite;
}

@keyframes agenda-spin {
    to { transform: rotate(360deg); }
}

@keyframes agenda-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Thumbnails sidebar ----------------------------------------------- */
.agenda-flipbook__thumbs {
    flex: 0 0 132px;
    max-height: 560px;
    overflow-y: auto;
    padding: 0.5rem;
    background: #ffffff;
    border: 1px solid #e2e8ee;
    border-radius: 12px;
    scrollbar-width: thin;
}

.agenda-flipbook__thumbs::-webkit-scrollbar { width: 6px; }
.agenda-flipbook__thumbs::-webkit-scrollbar-thumb {
    background: #c5d2dd;
    border-radius: 3px;
}

.agenda-flipbook__thumb {
    position: relative;
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    background: #f5f7f9;
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 3 / 4;
    transition: border-color 0.2s ease, transform 0.15s ease;
}

.agenda-flipbook__thumb:hover { transform: scale(1.03); }

.agenda-flipbook__thumb.is-active {
    border-color: var(--agenda-primary);
    box-shadow: 0 0 0 2px rgba(13, 120, 184, 0.2);
}

.agenda-flipbook__thumb canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.agenda-flipbook__thumb-num {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: rgba(27, 39, 51, 0.7);
    border-radius: 4px;
    padding: 0 5px;
}

/* ---- Global loader / error -------------------------------------------- */
.agenda-flipbook__status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 420px;
    text-align: center;
    color: var(--agenda-ink);
}

.agenda-flipbook__status .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(13, 120, 184, 0.2);
    border-top-color: var(--agenda-primary);
    border-radius: 50%;
    animation: agenda-spin 0.9s linear infinite;
}

.agenda-flipbook__status--error a {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.6rem 1.4rem;
    background: var(--agenda-primary);
    color: #fff;
    border-radius: 50px;
    font-weight: 600;
    text-decoration: none;
}

.agenda-flipbook__progress {
    font-size: 0.9rem;
    color: #5b6b78;
}

/* ---- Fullscreen ------------------------------------------------------- */
.agenda-flipbook:fullscreen,
.agenda-flipbook:-webkit-full-screen {
    padding: 1.5rem;
    background: #11181f;
}

.agenda-flipbook:fullscreen .agenda-flipbook__book-area {
    min-height: calc(100vh - 140px);
}

.agenda-flipbook:fullscreen .agenda-flipbook__toolbar {
    background: #1c252e;
    border-color: #2b3742;
}

.agenda-flipbook:fullscreen .agenda-flipbook__btn { color: #e8edf2; }
.agenda-flipbook:fullscreen .agenda-flipbook__pageinfo { color: #e8edf2; }
.agenda-flipbook:fullscreen .agenda-flipbook__thumbs { background: #1c252e; border-color: #2b3742; }

/* ---- Hint ------------------------------------------------------------- */
.agenda-flipbook__hint {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #6b7a87;
}

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 991.98px) {
    .agenda-flipbook__thumbs { flex-basis: 108px; }
}

@media (max-width: 767.98px) {
    .agenda-flipbook { padding: 1rem 0.5rem 1.5rem; }
    .agenda-flipbook__thumbs { display: none; }
    .agenda-flipbook__book-area { min-height: 460px; }
    .agenda-flipbook__btn { min-width: 38px; height: 38px; padding: 0 0.5rem; }
    .agenda-flipbook__btn-label { display: none; }
    .agenda-flipbook__toolbar { gap: 0.2rem; }
}
