/**
 * Secure Paid Flipbook - Frontend Flipbook Viewer Styles
 * @package SecurePaidFlipbook
 */

.spf-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
    box-sizing: border-box;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
}

/* Document Header */
.spf-doc-header {
    margin-bottom: 24px;
    text-align: center;
}

.spf-doc-meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 9999px;
    margin-bottom: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.spf-doc-title {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.3;
    margin: 0 0 12px 0;
    letter-spacing: -0.02em;
}

.spf-doc-desc {
    font-size: 15px;
    color: #475569;
    max-width: 750px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Flipbook Main Card */
.spf-flipbook-card {
    background: #0f172a;
    border-radius: 14px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

/* Toolbar */
.spf-toolbar {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 10px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ffffff;
}

.spf-toolbar-left,
.spf-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spf-toolbar-divider {
    width: 1px;
    height: 20px;
    background: #475569;
    margin: 0 4px;
}

.spf-zoom-level-badge {
    background: #0f172a;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 0.03em;
    min-width: 48px;
    text-align: center;
    cursor: pointer;
    border: 1px solid #334155;
    transition: all 0.2s ease;
}

.spf-zoom-level-badge:hover {
    border-color: #38bdf8;
    background: #1e293b;
}

.spf-mode-toggle-btn {
    background: #0284c7 !important;
    border-color: #0369a1 !important;
    color: #ffffff !important;
}

.spf-mode-toggle-btn:hover {
    background: #0369a1 !important;
    border-color: #0284c7 !important;
}

.spf-btn-tool {
    background: #334155;
    border: 1px solid #475569;
    color: #f8fafc;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.spf-btn-tool:hover {
    background: #475569;
    color: #ffffff;
    border-color: #64748b;
}

.spf-btn-tool:focus {
    outline: 2px solid #38bdf8;
    outline-offset: 2px;
}

.spf-btn-tool:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.spf-download-btn {
    background: #166534 !important;
    border-color: #15803d !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

.spf-download-btn:hover {
    background: #15803d !important;
    border-color: #22c55e !important;
}

.spf-page-indicator {
    background: #0f172a;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 0.05em;
    min-width: 80px;
    text-align: center;
}

/* Flipbook Stage */
.spf-stage {
    position: relative;
    min-height: 750px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    padding: 24px 30px;
    box-sizing: border-box;
    overflow: hidden;
    outline: none;
}

.spf-stage.spf-is-zoomed {
    overflow: auto;
}

.spf-stage:fullscreen,
.spf-stage:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    padding: 40px;
}

/* Loader */
.spf-loader {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    color: #f8fafc;
    font-size: 14px;
}

.spf-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: spf-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

/* Flipbook Viewport & 3D Realistic Page-Turn Spread */
.spf-book-viewport {
    perspective: 2500px;
    -webkit-perspective: 2500px;
    perspective-origin: 50% 50%;
    transition: transform 0.2s ease-out;
    transform-origin: center center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spf-page-spread {
    display: flex;
    align-items: stretch;
    background: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65), 0 0 20px rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    position: relative;
}

/* Single Page Mode Override */
.spf-single-mode .spf-page-left,
.spf-single-mode .spf-book-spine {
    display: none !important;
}

.spf-single-mode .spf-page-right {
    width: clamp(540px, 58vw, 920px) !important;
    height: clamp(760px, 83vh, 1280px) !important;
    border-radius: 6px !important;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.6);
}

.spf-page {
    background: #ffffff;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 520px;
    height: 730px;
    box-sizing: border-box;
    cursor: pointer;
}

.spf-page-left {
    border-radius: 4px 0 0 4px;
    box-shadow: inset -18px 0 25px -12px rgba(0, 0, 0, 0.3);
}

.spf-page-right {
    border-radius: 0 4px 4px 0;
    box-shadow: inset 18px 0 25px -12px rgba(0, 0, 0, 0.3);
}

.spf-page.spf-empty-page,
.spf-page.spf-empty-page canvas {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    max-width: 0 !important;
    height: 0 !important;
    max-height: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    pointer-events: none !important;
    cursor: default;
}

.spf-page-spread.has-empty-page {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

.spf-page-spread.has-empty-page .spf-book-spine {
    display: none !important;
}

.spf-page-spread.has-empty-page .spf-page-right,
.spf-page-spread.has-empty-page .spf-page-left {
    border-radius: 6px !important;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.6) !important;
}

.spf-page canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
    -webkit-font-smoothing: antialiased;
}

.spf-page-number {
    position: absolute;
    bottom: 10px;
    font-size: 11px;
    color: #64748b;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 8px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 5;
}

.spf-page-num-left {
    left: 16px;
}

.spf-page-num-right {
    right: 16px;
}

.spf-book-spine {
    width: 6px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.35) 0%, rgba(255, 255, 255, 0.2) 50%, rgba(0, 0, 0, 0.35) 100%);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
    z-index: 25;
}

/* 3D Dynamic Turning Sheet */
.spf-turning-sheet {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    z-index: 40;
    pointer-events: none;
    will-change: transform;
}

.spf-sheet-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.25);
}

.spf-sheet-face canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.spf-sheet-front {
    z-index: 2;
    transform: rotateY(0deg);
}

.spf-sheet-back {
    z-index: 1;
    transform: rotateY(180deg);
}

/* Dynamic Page Turning Shadows */
.spf-sheet-shadow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.spf-shadow-front {
    background: linear-gradient(to right, rgba(0, 0, 0, 0.35) 0%, rgba(255, 255, 255, 0.15) 15%, rgba(0, 0, 0, 0.05) 100%);
}

.spf-shadow-back {
    background: linear-gradient(to left, rgba(0, 0, 0, 0.35) 0%, rgba(255, 255, 255, 0.15) 15%, rgba(0, 0, 0, 0.05) 100%);
}

/* Floating Navigation Arrows */
.spf-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.spf-nav-arrow:hover {
    background: rgba(2, 132, 199, 0.9);
    border-color: #38bdf8;
    transform: translateY(-50%) scale(1.1);
}

.spf-nav-prev {
    left: 15px;
}

.spf-nav-next {
    right: 15px;
}

.spf-preview-banner {
    background: #0284c7;
    color: #ffffff;
    padding: 8px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .spf-turning-sheet {
        display: none !important;
    }
    .spf-page-spread,
    .spf-book-viewport {
        transition: none !important;
    }
}

/* Mobile & Tablet Responsive Layout */
@media (max-width: 860px) {
    .spf-page-spread {
        flex-direction: column;
    }
    
    .spf-page-left {
        display: none !important;
    }

    .spf-book-spine {
        display: none;
    }

    .spf-page {
        width: 100%;
        max-width: 440px;
        height: auto;
        min-height: 480px;
    }
    
    .spf-nav-arrow {
        width: 40px;
        height: 40px;
    }
}

/* ==========================================================================
   PUBLIC FLIPBOOK CATALOG & GRID STYLES
   ========================================================================== */

.spf-catalog-wrapper {
    max-width: 1200px;
    margin: 30px auto 60px auto;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
}

.spf-catalog-header {
    text-align: center;
    margin-bottom: 36px;
}

.spf-catalog-badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.spf-catalog-title {
    font-size: 32px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 10px 0;
    letter-spacing: -0.02em;
}

.spf-catalog-desc {
    font-size: 15px;
    color: #475569;
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Filter & Search Bar */
.spf-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    background: #ffffff;
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04);
    margin-bottom: 20px;
    align-items: center;
    justify-content: space-between;
}

.spf-search-box {
    position: relative;
    flex: 1 1 320px;
}

.spf-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.spf-search-box input {
    width: 100%;
    padding: 10px 36px 10px 38px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    background: #f8fafc;
}

.spf-search-box input:focus {
    border-color: #0284c7;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

#spf-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
}

.spf-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.spf-select-wrap select {
    padding: 9px 32px 9px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    background: #f8fafc url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 10px center;
    background-size: 14px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.spf-select-wrap select:focus {
    border-color: #0284c7;
    background-color: #ffffff;
}

.spf-btn-reset-filters {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.spf-btn-reset-filters:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.spf-results-info {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 24px;
    font-weight: 500;
}

/* Catalog Grid */
.spf-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}

/* Flipbook Card Item */
.spf-card-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.spf-card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -3px rgba(0, 0, 0, 0.09), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    border-color: #cbd5e1;
}

/* Card Cover Box */
.spf-card-cover-box {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #0f172a;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spf-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.spf-card-item:hover .spf-card-img {
    transform: scale(1.04);
}

.spf-card-fallback-cover {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    box-sizing: border-box;
}

.spf-fallback-title {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    margin-top: 10px;
    max-width: 200px;
}

.spf-fallback-tag {
    color: #38bdf8;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 4px;
}

.spf-card-cat-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    color: #38bdf8;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border-radius: 9999px;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Card Content Body */
.spf-card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.spf-card-heading {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
    margin: 0 0 10px 0;
}

.spf-card-heading a {
    color: #0f172a;
    text-decoration: none;
    transition: color 0.2s;
}

.spf-card-heading a:hover {
    color: #0284c7;
}

.spf-card-summary {
    font-size: 13px;
    color: #64748b;
    line-height: 1.6;
    margin: 0 0 16px 0;
    flex: 1;
}

.spf-card-meta-row {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f1f5f9;
}

.spf-card-date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Action Button */
.spf-card-action-row {
    margin-top: auto;
}

.spf-btn-view-flipbook {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: #0284c7;
    color: #ffffff !important;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    padding: 11px 18px;
    border-radius: 8px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.spf-btn-view-flipbook:hover {
    background: #0369a1;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

/* Empty State & Error Wrappers */
.spf-empty-state,
.spf-no-filter-results {
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    margin: 30px 0;
}

.spf-empty-state h3,
.spf-no-filter-results h4 {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 8px 0;
}

.spf-empty-state p,
.spf-no-filter-results p {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 16px 0;
}

.spf-error-wrapper {
    max-width: 650px;
    margin: 60px auto;
    text-align: center;
}

.spf-error-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 40px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

/* Single Viewer Navigation Bar */
.spf-viewer-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.spf-btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #0284c7;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    transition: all 0.2s;
}

.spf-btn-back:hover {
    background: #0284c7;
    color: #ffffff;
}

.spf-viewer-cat-pill {
    background: #f1f5f9;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 9999px;
    text-transform: uppercase;
}

.spf-viewer-meta-info {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: 13px;
    color: #64748b;
}

.spf-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Overview Card */
.spf-overview-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    margin: 24px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.spf-overview-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 12px 0;
}

.spf-overview-body {
    font-size: 14px;
    color: #475569;
    line-height: 1.7;
}

/* Responsive Grid Breakpoints */
@media (max-width: 1024px) {
    .spf-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 22px;
    }
}

@media (max-width: 640px) {
    .spf-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .spf-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .spf-filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .spf-select-wrap select {
        width: 100%;
    }

    .spf-btn-reset-filters {
        justify-content: center;
    }

    .spf-catalog-title {
        font-size: 24px;
    }
}

