/* ============================================
   PAPER PAGE - COMPLETE STYLES
   ============================================ */

/* ============================================
   PREVENT HORIZONTAL SCROLL
   ============================================ */
html,
body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
    padding: 0;
}

* {
    max-width: 100%;
    box-sizing: border-box;
}

img,
canvas,
iframe,
video {
    max-width: 100%;
    height: auto;
}

.paper-page-wrapper {
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
}

/* ============================================
   PAPER HEADER
   ============================================ */
.paper-header {
    padding: 40px 0 24px;
    background: var(--cream);
    border-bottom: 1px solid rgba(30, 38, 64, 0.06);
}

.paper-header .container {
    max-width: 100%;
    overflow: hidden;
    padding-left: 24px;
    padding-right: 24px;
}

.paper-header .paper-title {
    font-family: var(--font-serif);
    font-size: 32px;
    color: var(--text-dark);
    font-weight: 600;
    margin-bottom: 4px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.paper-header .paper-meta {
    font-family: var(--font-sans);
    font-size: 18px;
    color: var(--text-dark);
    opacity: 0.7;
    margin-bottom: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.paper-header .download-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 100%;
}

.paper-header .download-actions .btn {
    flex: 0 1 auto;
    min-width: 160px;
    text-align: center;
}

.paper-header .file-hash {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-dark);
    opacity: 0.4;
    margin-top: 12px;
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* ============================================
   SUMMARY SECTION
   ============================================ */
.summary-section {
    padding: 40px 0;
    background: var(--cream);
}

.summary-section .container {
    max-width: 100%;
    overflow: hidden;
    padding-left: 24px;
    padding-right: 24px;
}

.summary-content {
    background: var(--text-light);
    padding: 32px 36px;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px var(--shadow);
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
}

.summary-content h3 {
    font-family: var(--font-serif);
    font-size: 22px;
    color: var(--text-dark);
    margin-top: 20px;
    margin-bottom: 8px;
    font-weight: 400;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.summary-content h3:first-child {
    margin-top: 0;
}

.summary-content p {
    font-family: var(--font-sans);
    font-size: 16px;
    color: var(--text-dark);
    opacity: 0.85;
    line-height: 1.8;
    margin-bottom: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.summary-content ul {
    padding-left: 24px;
    margin-bottom: 12px;
    overflow: hidden;
    word-wrap: break-word;
}

.summary-content ul li {
    font-family: var(--font-sans);
    font-size: 16px;
    color: var(--text-dark);
    opacity: 0.85;
    line-height: 1.8;
    list-style-type: disc;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* ============================================
   PDF VIEWER SECTION
   ============================================ */
.pdf-viewer-section {
    padding: 40px 0 60px;
    background: var(--cream);
}

.pdf-viewer-section .container {
    max-width: 100%;
    overflow: hidden;
    padding-left: 24px;
    padding-right: 24px;
}

.pdf-viewer-section .section-title {
    text-align: left;
}

/* PDF Controls */
.pdf-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    background: var(--text-light);
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px var(--shadow);
    max-width: 100%;
    overflow: hidden;
}

.pdf-controls .btn-sm {
    font-size: 14px;
    padding: 6px 16px;
}

.pdf-controls #page-num,
.pdf-controls #page-count {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 15px;
    color: var(--text-dark);
    min-width: 20px;
}

.pdf-controls .zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.pdf-controls .zoom-controls #zoom-level {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 14px;
    color: var(--text-dark);
    min-width: 48px;
    text-align: center;
}

/* PDF Container */
#pdf-container {
    height: 600px;
    max-height: 80vh;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative;
    background: #1a1a2e;
    border-radius: 8px;
    scroll-behavior: smooth;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

#pdf-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.pdf-page {
    display: block;
    margin: 0 auto;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    background: white;
    max-width: 100% !important;
    height: auto !important;
}

/* Scrollbar styling - Webkit (Chrome, Safari, Edge) */
#pdf-container::-webkit-scrollbar {
    width: 10px;
}

#pdf-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#pdf-container::-webkit-scrollbar-thumb {
    background: var(--primary, #DC9570);
    border-radius: 4px;
}

#pdf-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark, #c47a54);
}

/* Scrollbar styling - Firefox */
#pdf-container {
    scrollbar-width: thin;
    scrollbar-color: var(--primary, #DC9570) rgba(255, 255, 255, 0.05);
}

/* ============================================
   RELATED SECTION
   ============================================ */
.related-section {
    padding: 32px 0 64px;
    background: var(--cream);
}

.related-section .container {
    max-width: 100%;
    overflow: hidden;
    padding-left: 24px;
    padding-right: 24px;
}

.related-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.related-card {
    background: var(--text-light);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px var(--shadow);
    transition: all var(--transition);
    max-width: 100%;
    overflow: hidden;
}

.related-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px var(--shadow-hover);
}

.related-card .book-title {
    font-size: 18px;
    margin-bottom: 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.related-card .book-author {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 992px) {
    .related-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .paper-header .paper-title {
        font-size: 28px;
    }
    
    .summary-content {
        padding: 24px 28px;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    .paper-header {
        padding: 32px 0 20px;
    }
    
    .paper-header .container,
    .summary-section .container,
    .pdf-viewer-section .container,
    .related-section .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .paper-header .paper-title {
        font-size: 24px;
    }
    
    .paper-header .paper-meta {
        font-size: 16px;
    }
    
    .paper-header .download-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .paper-header .download-actions .btn {
        min-width: 100%;
        width: 100%;
        font-size: 15px;
        padding: 12px 20px;
        text-align: center;
    }
    
    .paper-header .file-hash {
        font-size: 10px;
    }
    
    .summary-content {
        padding: 20px;
    }
    
    .summary-content h3 {
        font-size: 19px;
    }
    
    .summary-content p,
    .summary-content ul li {
        font-size: 15px;
    }
    
    .related-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .related-card {
        padding: 20px;
    }
    
    .pdf-controls {
        gap: 10px;
        padding: 10px 14px;
        border-radius: 6px;
    }
    
    .pdf-controls .btn-sm {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .pdf-controls .zoom-controls {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
    }
    
    #pdf-container {
        height: 450px;
        max-height: 70vh;
        border-radius: 6px;
    }
    
    .pdf-page {
        max-width: 98% !important;
    }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE
   ============================================ */
@media (max-width: 480px) {
    .paper-header {
        padding: 24px 0 16px;
    }
    
    .paper-header .container,
    .summary-section .container,
    .pdf-viewer-section .container,
    .related-section .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .paper-header .paper-title {
        font-size: 20px;
    }
    
    .paper-header .paper-meta {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .paper-header .download-actions .btn {
        font-size: 13px;
        padding: 10px 16px;
    }
    
    .paper-header .file-hash {
        font-size: 9px;
        margin-top: 8px;
    }
    
    .summary-section {
        padding: 24px 0;
    }
    
    .summary-content {
        padding: 16px;
        border-radius: 6px;
    }
    
    .summary-content h3 {
        font-size: 17px;
        margin-top: 16px;
    }
    
    .summary-content p,
    .summary-content ul li {
        font-size: 14px;
        line-height: 1.6;
    }
    
    .summary-content ul {
        padding-left: 18px;
    }
    
    .pdf-viewer-section {
        padding: 24px 0 40px;
    }
    
    .pdf-controls {
        padding: 8px 10px;
        gap: 6px;
        border-radius: 4px;
    }
    
    .pdf-controls .btn-sm {
        font-size: 11px;
        padding: 4px 10px;
    }
    
    .pdf-controls #page-num,
    .pdf-controls #page-count {
        font-size: 13px;
        min-width: 16px;
    }
    
    .pdf-controls .zoom-controls #zoom-level {
        font-size: 12px;
        min-width: 32px;
    }
    
    #pdf-container {
        height: 350px;
        max-height: 60vh;
        border-radius: 4px;
    }
    
    .pdf-page {
        max-width: 96% !important;
    }
    
    .related-section {
        padding: 24px 0 40px;
    }
    
    .related-card {
        padding: 16px;
    }
    
    .related-card .book-title {
        font-size: 16px;
    }
    
    .related-card .book-author {
        font-size: 13px;
    }
}

/* ============================================
   RESPONSIVE - VERY SMALL MOBILE
   ============================================ */
@media (max-width: 360px) {
    .paper-header .paper-title {
        font-size: 18px;
    }
    
    .paper-header .paper-meta {
        font-size: 13px;
    }
    
    .summary-content {
        padding: 12px;
    }
    
    .summary-content h3 {
        font-size: 15px;
    }
    
    .summary-content p,
    .summary-content ul li {
        font-size: 13px;
    }
    
    #pdf-container {
        height: 280px;
        max-height: 55vh;
    }
}
/* ============================================
   PAPER PAGE - EMERGENCY HORIZONTAL SCROLL FIX
   ============================================ */

/* Force everything to stay within viewport */
.paper-page-wrapper,
.paper-header,
.summary-section,
.pdf-viewer-section,
.related-section,
.paper-header .container,
.summary-section .container,
.pdf-viewer-section .container,
.related-section .container,
.paper-header .container *,
.summary-section .container *,
.pdf-viewer-section .container *,
.related-section .container * {
    max-width: 100% !important;
    overflow-x: hidden !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
}

/* Specifically target the PDF container */
#pdf-container {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

/* Target PDF canvas elements directly */
#pdf-container canvas,
#pdf-container .pdf-page {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* Target any potential overflow from code or long strings */
.paper-header .file-hash,
.summary-content code,
.summary-content pre,
.summary-content .long-text {
    max-width: 100% !important;
    overflow-x: auto !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
}

/* Force all buttons to stay contained */
.btn {
    max-width: 100% !important;
    white-space: normal !important;
    word-wrap: break-word !important;
}

/* Fix for the download actions */
.paper-header .download-actions {
    max-width: 100% !important;
    flex-wrap: wrap !important;
}

.paper-header .download-actions .btn {
    flex: 0 1 auto !important;
    min-width: 140px !important;
    max-width: 100% !important;
}

/* Force mobile viewport */
@media (max-width: 768px) {
    .paper-page-wrapper {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .paper-header .download-actions .btn {
        min-width: 100% !important;
        width: 100% !important;
    }
}
