/* ==========================================================================
   Design System & Global Variables
   ========================================================================== */
:root {
    /* Color Palette */
    --primary-hue: 250;
    --primary: hsl(var(--primary-hue), 85%, 60%);
    --primary-light: hsl(var(--primary-hue), 85%, 70%);
    --primary-dark: hsl(var(--primary-hue), 85%, 45%);
    --primary-glow: hsla(var(--primary-hue), 85%, 60%, 0.3);
    
    --accent: hsl(330, 90%, 60%);
    --accent-glow: hsla(330, 90%, 60%, 0.3);

    --success: hsl(142, 70%, 45%);
    --warning: hsl(38, 92%, 50%);
    --danger: hsl(350, 80%, 55%);
    
    /* Font Stack */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* System Borders and Radii */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --border-glass: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   1. Dashboard Styling (Glassmorphic dark layout)
   ========================================================================== */
.dashboard-body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background: #060814;
    color: #e2e8f0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* Glowing background graphics */
.glow-bg {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-glow) 0%, rgba(6, 8, 20, 0) 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    animation: pulseGlow 10s infinite alternate ease-in-out;
}

@keyframes pulseGlow {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
    100% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

.dashboard-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 800px;
    padding: 24px;
    box-sizing: border-box;
    transition: max-width 0.3s ease;
}

/* Styles when logged in to display as a full viewport CMS dashboard */
.dashboard-body.logged-in {
    display: block;
    overflow: hidden;
}

/* Header */
.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--primary-light);
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.logo-text {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.accent-text {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: #94a3b8;
    font-size: 1.1rem;
    font-weight: 300;
    margin: 0;
}

/* Main Card */
.main-card {
    background: rgba(13, 17, 38, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary-light);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.icon-wrapper {
    width: 80px;
    height: 80px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    transition: transform 0.3s ease;
}

.upload-zone:hover .icon-wrapper {
    transform: translateY(-5px);
    background: rgba(99, 102, 241, 0.2);
}

.upload-icon {
    font-size: 2.2rem;
    color: var(--primary-light);
}

.upload-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    color: #f8fafc;
}

.file-limits {
    color: #64748b;
    font-size: 0.9rem;
    margin: 0;
}

/* Buttons */
.btn {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
    filter: brightness(1.1);
}

.btn-glow {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent) 100%);
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
    font-weight: 600;
}

.btn-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--accent-glow);
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #cbd5e1;
    color: white;
}

.btn-full-width {
    width: 100%;
    box-sizing: border-box;
}

/* Progress Box */
.progress-card {
    padding: 12px 0;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.file-name-text {
    font-weight: 500;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.percent-text {
    font-weight: 600;
    color: var(--primary-light);
}

.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 4px;
    transition: width 0.1s ease;
    box-shadow: 0 0 10px var(--primary-glow);
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 24px;
}

/* Success Card */
.success-card {
    text-align: center;
    animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.success-icon-wrapper {
    width: 72px;
    height: 72px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.success-check-icon {
    font-size: 2.5rem;
    color: var(--success);
}

.success-card h2 {
    font-size: 1.8rem;
    margin: 0 0 8px 0;
    color: white;
}

.success-sub {
    color: #94a3b8;
    margin: 0 0 32px 0;
}

/* Share Box */
.link-share-box {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    overflow: hidden;
    padding: 6px;
    margin-bottom: 32px;
}

.share-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    padding: 8px 12px;
    outline: none;
}

.btn-copy {
    padding: 8px 20px;
    border-radius: 4px;
}

.share-details-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: center;
    text-align: left;
}

.qr-code-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 20px;
}

.qr-code-box {
    background: white;
    padding: 12px;
    border-radius: var(--radius-sm);
    display: inline-block;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.qr-code-box img {
    display: block;
    width: 150px;
    height: 150px;
}

.qr-label {
    margin: 12px 0 0 0;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
}

.action-buttons-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dashboard-footer {
    text-align: center;
    margin-top: 40px;
    color: #475569;
    font-size: 0.85rem;
}

@media (max-width: 640px) {
    .share-details-group {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .main-card {
        padding: 24px;
    }
}


/* ==========================================================================
   2. Viewer Page Theme System
   ========================================================================== */
.viewer-body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Light Theme */
.viewer-body.theme-light {
    --bg-color: #f1f5f9;
    --text-color: #1e293b;
    --toolbar-bg: rgba(255, 255, 255, 0.85);
    --border-color: rgba(0, 0, 0, 0.08);
    --btn-hover: rgba(0, 0, 0, 0.04);
    --dropdown-bg: #ffffff;
    --dropdown-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --canvas-filter: none;
    --canvas-shadow: 0 15px 35px rgba(0,0,0,0.1);
    --book-gap-color: #cbd5e1;
}

/* Sepia Theme */
.viewer-body.theme-sepia {
    --bg-color: #f4ecd8;
    --text-color: #433422;
    --toolbar-bg: rgba(244, 236, 216, 0.9);
    --border-color: rgba(67, 52, 34, 0.12);
    --btn-hover: rgba(67, 52, 34, 0.06);
    --dropdown-bg: #fdfaf2;
    --dropdown-shadow: 0 10px 30px rgba(67, 52, 34, 0.15);
    --canvas-filter: sepia(0.55) contrast(0.95) brightness(0.95);
    --canvas-shadow: 0 15px 35px rgba(67, 52, 34, 0.15);
    --book-gap-color: #d7c9a9;
}

/* Dark Theme (Obsidian) */
.viewer-body.theme-dark {
    --bg-color: #0b0c10;
    --text-color: #cbd5e1;
    --toolbar-bg: rgba(17, 19, 28, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --btn-hover: rgba(255, 255, 255, 0.06);
    --dropdown-bg: #131622;
    --dropdown-shadow: 0 10px 35px rgba(0, 0, 0, 0.5);
    --canvas-filter: invert(0.9) hue-rotate(180deg) contrast(0.95) brightness(0.9);
    --canvas-shadow: 0 15px 35px rgba(0,0,0,0.5);
    --book-gap-color: #1e293b;
}

/* Global Viewer Resets */
.viewer-body {
    background-color: var(--bg-color);
    color: var(--text-color);
}


/* ==========================================================================
   3. Viewer Layout Elements
   ========================================================================== */
.viewer-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: relative;
    z-index: 10;
}

/* Top Toolbar */
.viewer-toolbar {
    height: 56px;
    background-color: var(--toolbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
}

.toolbar-left, .toolbar-right, .toolbar-center {
    display: flex;
    align-items: center;
}

.toolbar-left {
    gap: 8px;
    flex: 1;
}

.toolbar-center {
    gap: 4px;
    justify-content: center;
    flex: 2;
}

.toolbar-right {
    gap: 4px;
    justify-content: flex-end;
    flex: 1;
}

.toolbar-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s ease;
    text-decoration: none;
}

.toolbar-btn:hover {
    background-color: var(--btn-hover);
}

.divider {
    width: 1px;
    height: 20px;
    background-color: var(--border-color);
    margin: 0 8px;
}

.book-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Page Navigation Box */
.nav-arrow-btn {
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

.nav-arrow-btn:hover {
    background-color: var(--btn-hover);
}

.page-indicator-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0 8px;
}

.page-num-input {
    width: 45px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.page-num-input::-webkit-outer-spin-button,
.page-num-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.total-pages-label {
    color: #64748b;
}

/* Zoom controls */
.zoom-controls {
    display: flex;
    align-items: center;
    background: var(--btn-hover);
    border-radius: 20px;
    padding: 2px;
    margin-right: 8px;
}

.zoom-value-text {
    font-size: 0.8rem;
    font-weight: 600;
    width: 45px;
    text-align: center;
}

/* Workspace containing Sidebar + Main Stage */
.viewer-workspace {
    flex: 1;
    display: flex;
    position: relative;
    z-index: 20;
    height: calc(100vh - 56px - 6px);
}

/* Sidebar */
.viewer-sidebar {
    width: 260px;
    background-color: var(--toolbar-bg);
    border-right: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 50;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
}

.viewer-sidebar.active {
    transform: translateX(0);
    position: relative;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.thumbnail-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    justify-items: center;
}

.thumbnail-wrapper {
    width: 130px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s ease;
}

.thumbnail-wrapper:hover {
    border-color: var(--primary-light);
}

.thumbnail-wrapper.active {
    border-color: var(--primary);
    background: var(--btn-hover);
}

.thumbnail-img-box {
    width: 100%;
    height: 170px;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.thumbnail-img-box canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thumbnail-page-num {
    margin-top: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
}

/* Settings Dropdown */
.dropdown-wrapper {
    position: relative;
}

.settings-dropdown {
    position: absolute;
    top: 48px;
    right: 0;
    width: 220px;
    background-color: var(--dropdown-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--dropdown-shadow);
    padding: 16px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-dropdown h4 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.theme-options {
    display: flex;
    gap: 12px;
}

.theme-opt {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.2), 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.theme-opt.active {
    border-color: var(--primary);
    transform: scale(1.1);
}

.theme-light-btn { background-color: #ffffff; }
.theme-sepia-btn { background-color: #f4ecd8; }
.theme-dark-btn { background-color: #0b0c10; }

.settings-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}


/* ==========================================================================
   4. E-Book Reader Stage (Sliding Canvas Viewport)
   ========================================================================== */
.book-stage {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

/* Viewport for clipping outside panels */
.book-viewport {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Sliding horizontal filmstrip containing 3 panels */
.book-slider {
    display: flex;
    width: 300%; /* 3 panels */
    height: 100%;
    position: absolute;
    left: -100%; /* Centered active panel */
    transform: translateX(0px);
    will-change: transform;
}

.book-slider.transitioning {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Individual Panel */
.slide-panel {
    width: 33.3333%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    padding: 20px;
    position: relative;
    flex-shrink: 0;
}

/* Layout modes inside panels */
.slide-panel.layout-single .right-page {
    display: none !important;
}

.slide-panel.layout-single .left-page {
    box-shadow: var(--canvas-shadow);
    border-radius: var(--radius-sm);
}

.slide-panel.layout-dual {
    gap: 0; /* Align pages side-by-side */
}

.slide-panel.layout-dual .page-container {
    box-shadow: var(--canvas-shadow);
}

.slide-panel.layout-dual .left-page {
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
}

.slide-page-gap-overlay {
    pointer-events: none;
}

.slide-panel.layout-dual .right-page {
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
}

/* Individual pages */
.page-container {
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    transition: width 0.2s, height 0.2s;
}

/* Drop shadow and border styling */
.left-page {
    border-right: 1px solid var(--border-color);
}

.right-page {
    border-left: 1px solid var(--border-color);
}

/* Apply filter directly on canvas for themes */
.page-container canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    filter: var(--canvas-filter);
    transition: filter 0.3s ease;
}

/* Dynamic Page Divider Line (For Dual Book mode) */
.slide-panel.layout-dual::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 20px;
    bottom: 20px;
    width: 2px;
    background: linear-gradient(to right, rgba(0,0,0,0.18) 0%, rgba(255,255,255,0.06) 50%, rgba(0,0,0,0.18) 100%);
    z-index: 10;
    pointer-events: none;
    transform: translateX(-50%);
}

/* Tap Zones */
.tap-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 15%;
    max-width: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s, background-color 0.3s;
}

.left-zone { left: 0; }
.right-zone { right: 0; }

.tap-zone:hover {
    opacity: 1;
    background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
}

.right-zone:hover {
    background: linear-gradient(to left, rgba(0,0,0,0.06), transparent);
}

.tap-arrow {
    font-size: 1.5rem;
    color: var(--text-color);
    background: var(--toolbar-bg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border-color);
}


/* ==========================================================================
   5. Footer Reading Progress
   ========================================================================== */
.viewer-footer {
    height: 6px;
    background-color: var(--border-color);
    position: relative;
    z-index: 100;
}

.progress-indicator-track {
    width: 100%;
    height: 100%;
    background-color: transparent;
}

.progress-indicator-fill {
    height: 100%;
    background-color: var(--primary);
    box-shadow: 0 0 6px var(--primary-glow);
    transition: width 0.3s ease;
}


/* ==========================================================================
   6. Loading Screens and overlays
   ========================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #0d0f17;
    color: white;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.spinner-wrapper {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#loading-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: #94a3b8;
    margin: 0;
}

.loading-progress-container {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
    transition: width 0.2s;
}

/* Beautiful Animated Book Spinner */
.book-spinner {
    width: 50px;
    height: 40px;
    position: relative;
    perspective: 150px;
}

.book-page {
    width: 25px;
    height: 36px;
    background-color: white;
    position: absolute;
    top: 0;
    right: 0;
    transform-origin: left center;
    border-radius: 0 4px 4px 0;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.15);
}

.book-page::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    border-left: 2px solid var(--primary-dark);
}

.page-1 {
    transform: rotateY(0deg);
    animation: flipBook 2.2s infinite ease-in-out;
}

.page-2 {
    transform: rotateY(-30deg);
    animation: flipBook2 2.2s infinite ease-in-out;
}

.page-3 {
    transform: rotateY(-180deg);
    background-color: #6366f1;
}

@keyframes flipBook {
    0% { transform: rotateY(0deg); z-index: 10; }
    40%, 100% { transform: rotateY(-180deg); z-index: 0; }
}

@keyframes flipBook2 {
    0%, 20% { transform: rotateY(0deg); z-index: 5; }
    60%, 100% { transform: rotateY(-180deg); z-index: 0; }
}

/* Error View styling */
.error-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #0b0c10;
    color: white;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.error-icon {
    font-size: 3.5rem;
    color: var(--danger);
    filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.2));
}

.error-view h2 {
    margin: 0;
    font-size: 1.6rem;
}

.error-view p {
    color: #64748b;
    margin: 0 0 16px 0;
}


/* ==========================================================================
   7. Premium Mobile & Tablet Optimization (Responsive CSS)
   ========================================================================== */
@media (max-width: 900px) {
    .zoom-controls {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* Toolbar scaling */
    .viewer-toolbar {
        height: 52px;
        padding: 0 8px;
    }
    
    .toolbar-left .divider {
        display: none;
    }
    
    .book-title {
        max-width: 110px;
        font-size: 0.85rem;
    }
    
    #sidebar-toggle {
        display: none !important;
    }

    #layout-toggle {
        display: none !important;
    }

    .page-indicator-wrapper {
        font-size: 0.85rem;
        padding: 0 4px;
    }
    
    .page-num-input {
        width: 38px;
        height: 26px;
        font-size: 0.85rem;
    }
    
    /* Workspace adjustments */
    .viewer-workspace {
        height: calc(100vh - 52px - 6px);
    }
    
    .slide-panel {
        padding: 10px;
    }

    .slide-panel.layout-dual::after {
        display: none !important; /* Hide central page gap line on mobile */
    }

    /* Swipe Zone hints */
    .tap-zone {
        width: 20%;
        max-width: 80px;
    }
    
    .tap-arrow {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    /* Settings dropdown transforms into a premium bottom sheet */
    .settings-dropdown {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border: none;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
        padding: 24px 20px;
        box-sizing: border-box;
        display: none;
        flex-direction: column;
        gap: 16px;
        animation: bottomSheetSlideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        z-index: 999;
    }

    .settings-dropdown.active {
        display: flex !important;
    }

    /* Bottom Sheet Header bar */
    .settings-dropdown::before {
        content: '';
        width: 40px;
        height: 5px;
        background: #cbd5e1;
        border-radius: 3px;
        align-self: center;
        margin-bottom: 8px;
    }

    .theme-opt {
        width: 44px;
        height: 44px;
    }
    
    .settings-dropdown h4 {
        font-size: 0.9rem;
        margin-bottom: 4px;
    }
}

@keyframes bottomSheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ==========================================================================
   8. 3D Page Turning Effect (Dual Book Layout)
   ========================================================================== */
/* ==========================================================================
   8. StPageFlip Library Integration Styles
   ========================================================================== */
.book-flip-container {
    margin: 0 auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    background-color: transparent;
    z-index: 10;
}

/* Page wrap classes required by StPageFlip */
.page {
    background-color: white;
    box-shadow: inset -10px 0 20px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* Hard cover pages density styling */
.page[data-density="hard"] {
    background-color: #f1f5f9;
}

.page-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    position: relative;
}

/* Page canvas centering and styling */
.page-content canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    filter: var(--canvas-filter);
    transition: filter 0.3s ease;
    pointer-events: none;
}

/* Dynamic Page creasing center shadow line overlay built by StPageFlip */
.page-content::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    pointer-events: none;
    z-index: 5;
}

.page:nth-child(even) .page-content::after {
    /* Left Page page-crease shadow shading right edge */
    background: linear-gradient(to right, rgba(0,0,0,0) 92%, rgba(0,0,0,0.06) 98%, rgba(0,0,0,0.15) 100%);
}

.page:nth-child(odd) .page-content::after {
    /* Right Page page-crease shadow shading left edge */
    background: linear-gradient(to left, rgba(0,0,0,0) 92%, rgba(0,0,0,0.06) 98%, rgba(0,0,0,0.15) 100%);
}


/* ==========================================================================
   9. Project Manager Dashboard Styles
   ========================================================================== */
.login-card-container {
    width: 100%;
    max-width: 420px;
    padding: 24px;
    box-sizing: border-box;
    z-index: 10;
}

.login-card {
    background: rgba(13, 17, 38, 0.7);
    backdrop-filter: blur(20px);
    border: var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.login-card h2 {
    font-size: 1.6rem;
    margin: 16px 0 8px 0;
    color: white;
}

.login-sub {
    color: #94a3b8;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: #64748b;
}

.input-group input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: white;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    padding: 12px 12px 12px 48px;
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus {
    border-color: var(--primary-light);
    background: rgba(255, 255, 255, 0.08);
}

.login-error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin: 16px 0 0 0;
    font-weight: 500;
}

.login-footer {
    margin-top: 32px;
    font-size: 0.75rem;
    color: #475569;
    letter-spacing: 0.02em;
}

/* CMS Layout Styles */
.cms-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: #060814;
    color: #e2e8f0;
    font-family: var(--font-sans);
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.cms-sidebar {
    width: 300px;
    height: 100%;
    background: rgba(10, 14, 30, 0.8);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 28px 24px;
    box-sizing: border-box;
    z-index: 10;
    flex-shrink: 0;
}

/* Sidebar Logo specific size styling to fit on a single line */
.cms-sidebar .logo {
    margin-bottom: 24px;
    gap: 8px;
    align-items: center;
}

.cms-sidebar .logo-icon {
    font-size: 1.6rem;
}

.cms-sidebar .logo-text {
    font-size: 1.4rem;
    white-space: nowrap;
}

.cms-main-content {
    flex: 1;
    height: 100%;
    padding: 32px 40px;
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 5;
    position: relative;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.04) 0%, rgba(6, 8, 20, 0) 65%);
}

/* Custom thin scrollbar */
.sidebar-project-list::-webkit-scrollbar,
.cms-main-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.sidebar-project-list::-webkit-scrollbar-track,
.cms-main-content::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-project-list::-webkit-scrollbar-thumb,
.cms-main-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.sidebar-project-list::-webkit-scrollbar-thumb:hover,
.cms-main-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin: 20px 0;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    padding-left: 4px;
}

.sidebar-search {
    margin-bottom: 16px;
    width: 100% !important;
    position: relative;
    box-sizing: border-box;
}

.sidebar-search input {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 10px 12px 10px 36px !important;
    font-size: 0.85rem !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: var(--radius-sm);
    color: white;
    outline: none;
}

.sidebar-search .search-icon {
    position: absolute !important;
    left: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #64748b !important;
    font-size: 0.9rem !important;
    pointer-events: none !important;
    z-index: 5 !important;
}

.sidebar-project-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
    padding-right: 2px;
}

.empty-sidebar-msg {
    color: #475569;
    font-size: 0.8rem;
    text-align: center;
    padding: 24px 0;
    font-weight: 500;
}

.sidebar-proj-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

.sidebar-proj-item i {
    font-size: 1rem;
    color: #475569;
    flex-shrink: 0;
    transition: color 0.2s;
}

.sidebar-proj-item span {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    line-height: 1.4;
}

.sidebar-proj-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: white;
}

.sidebar-proj-item:hover i {
    color: #94a3b8;
}

.sidebar-proj-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.sidebar-proj-item.active i {
    color: var(--primary-light);
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.new-project-sidebar-btn {
    padding: 10px 16px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
}

/* CMS View Cards */
.cms-view-card {
    background: rgba(13, 17, 38, 0.25);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    padding: 32px;
    box-sizing: border-box;
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
    animation: fadeIn 0.25s ease;
    width: 100%;
}

/* Welcome View */
.welcome-view {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    flex: 1;
}

.welcome-icon {
    font-size: 3rem;
    color: var(--primary-light);
    margin-bottom: 20px;
    background: rgba(99, 102, 241, 0.08);
    padding: 20px;
    border-radius: 50%;
}

.welcome-view h2 {
    font-size: 1.6rem;
    color: white;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.welcome-view p {
    color: #94a3b8;
    max-width: 500px;
    margin: 0 0 40px 0;
    line-height: 1.6;
    font-size: 0.9rem;
}

.welcome-guide-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    max-width: 900px;
    width: 100%;
}

.guide-item {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
}

.guide-icon {
    font-size: 1.5rem;
    color: var(--primary-light);
    margin-bottom: 12px;
}

.guide-item h4 {
    margin: 0 0 6px 0;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
}

.guide-item p {
    font-size: 0.78rem;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
}

/* Create Project View (Spacious layout updates) */
.create-project-view {
    max-width: 720px; /* Wider card */
    margin: 0 auto;
    align-self: center;
    padding: 48px 56px !important; /* Generous internal padding */
}

.view-header {
    margin-bottom: 36px; /* Larger gap */
}

.view-header h2 {
    font-size: 1.6rem;
    color: white;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.view-header p {
    color: #64748b;
    margin: 0;
    font-size: 0.9rem;
}

.project-form {
    display: flex;
    flex-direction: column;
    gap: 24px; /* More spacing between elements */
}

.project-form .form-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
}

.project-form .form-group label {
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    color: #cbd5e1 !important;
    text-align: left !important;
}

.project-form .form-group input {
    width: 100% !important;
    box-sizing: border-box !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: var(--radius-sm) !important;
    color: white !important;
    font-family: var(--font-sans) !important;
    font-size: 0.95rem !important;
    padding: 14px 18px !important; /* Taller input for premium feel */
    outline: none !important;
    transition: all 0.2s !important;
}

.project-form .form-group input:focus {
    border-color: var(--primary-light) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15) !important;
}

.cms-zone {
    padding: 56px 32px !important; /* Much more vertical padding inside upload zone */
}

.cms-zone .upload-icon {
    font-size: 3rem !important;
    color: var(--primary-light);
    margin-bottom: 16px !important;
    transition: transform 0.25s ease;
}

.upload-zone:hover .upload-icon {
    transform: translateY(-6px);
}

.cms-zone h3 {
    margin: 0 0 8px 0;
    font-size: 1.05rem;
    color: white;
    font-weight: 600;
}

.file-limits {
    font-size: 0.8rem;
    color: #64748b;
    display: block;
    margin-bottom: 24px;
}

/* Details View */
.project-details-view {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.details-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 20px;
    margin-bottom: 24px;
    gap: 20px;
}

.details-title-area h2 {
    font-size: 1.4rem;
    color: white;
    margin: 0 0 6px 0;
    font-weight: 700;
}

.details-action-buttons {
    display: flex;
    gap: 10px;
}

.details-dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 28px;
    align-items: start;
    flex: 1;
}

.details-metadata-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.details-metadata-card h3,
.details-preview-card h3 {
    font-size: 0.9rem;
    color: #cbd5e1;
    margin: 0;
    font-weight: 600;
}

.link-share-box {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color 0.2s;
}

.link-share-box:focus-within {
    border-color: var(--primary-light);
}

.share-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 0.8rem;
    padding: 10px 12px;
    outline: none;
    font-family: var(--font-sans);
}

.btn-copy {
    background: var(--primary);
    border: none;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0;
}

.btn-copy:hover {
    background: var(--primary-light);
}

.details-qr-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 20px;
    border-radius: var(--radius-sm);
}

.details-qr-box .qr-code-box {
    background: white;
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.details-qr-box .qr-label {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 500;
    margin: 0;
}

.details-preview-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.iframe-preview-container {
    flex: 1;
    width: 100%;
    min-height: 480px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    background: #03040b;
    margin-top: 14px;
}

.project-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

@media (max-width: 1024px) {
    .details-dashboard-grid {
        grid-template-columns: 1fr;
    }
    .iframe-preview-container {
        min-height: 380px;
    }
}

@media (max-width: 768px) {
    .cms-container {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }
    
    .cms-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: var(--border-glass);
        padding: 20px 16px;
    }
    
    .sidebar-project-list {
        max-height: 140px;
    }
    
    .cms-main-content {
        padding: 20px;
        height: auto;
        overflow-y: visible;
    }
    
    .cms-view-card {
        padding: 20px;
    }
    
    .welcome-guide-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .details-top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}