.hidden {
    display: none !important;
}

svg {
    fill: none;
}

body {
    overflow-x: hidden;
}

body.download-active {
    height: calc(100vh - 81px);
    overflow-y: visible;
}

body.selection-active {
    overflow-y: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-screen.active {
    opacity: 1;
    pointer-events: all;
}

.loading-bar-container {
    width: 300px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-bar {
    position: absolute;
    height: 100%;
    background: #ff6154;
    border-radius: 2px;
    width: 40%;
    will-change: transform;
    animation: loading 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(200%);
    }
    100% {
        transform: translateX(500%);
    }
}

.loading-text {
    font-size: 15px;
    color: #666;
    font-weight: 500;
}

.container {
    background-color: transparent;
    box-sizing: border-box;
    padding: 20px;
    border-radius: 16px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto 10px auto;
    overflow: visible;
}

/* Upload Area */
.upload-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 12px;
    flex-wrap: wrap;
}

.file-input-label {
    display: inline-block;
    padding: 16px 48px;
    background-color: #ff6154;
    color: white;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    text-align: center;
    flex-shrink: 0;
}

.file-input-label:hover {
    background: #e5554a;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.4);
    transform: translateY(-1px);
}

#upload-label.drag-over {
    background-color: #e5554a;
    transform: scale(1.05);
}

#upload-label {
    outline: none;
}

.upload-content {
    text-align: center;
}

.upload-icon {
    display: none;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

input[type="file"] {
    display: none;
}

/* Selection Panel - General */
.selection-panel {
    margin-top: 0;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    position: fixed;
    top: 81px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 81px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.selection-panel.active {
    opacity: 1;
    visibility: visible;
}

.selection-content {
    display: flex;
    gap: 0;
    align-items: stretch;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Left side - Content Section */
.pages-preview-section {
    flex: 1;
    background: none;
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    overflow-y: auto;
    margin-right: 420px;
    box-sizing: border-box;
}

.pages-header {
    margin-bottom: 48px;
    max-width: 900px;
    width: 100%;
    text-align: center;
}

.pages-header h2 {
    margin: 0 0 8px 0;
    font-size: 1.75rem;
    color: #1f2937;
    font-weight: 700;
}

.selection-subtitle {
    margin: 0;
    font-size: 1rem;
    color: #6b7280;
    font-weight: 400;
}

/* Arrange Grid - Dynamic columns based on image count */
.arrange-grid {
    display: grid;
    gap: 16px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

/* 1-2 images: 3 columns */
.arrange-grid[data-count="1"],
.arrange-grid[data-count="2"] {
    grid-template-columns: repeat(3, 1fr);
}

/* 3 images: 3 columns */
.arrange-grid[data-count="3"] {
    grid-template-columns: repeat(3, 1fr);
}

/* 4-8 images: 4 columns */
.arrange-grid[data-count="4"],
.arrange-grid[data-count="5"],
.arrange-grid[data-count="6"],
.arrange-grid[data-count="7"],
.arrange-grid[data-count="8"] {
    grid-template-columns: repeat(4, 1fr);
}

/* 9-15 images: 5 columns */
.arrange-grid[data-count="9"],
.arrange-grid[data-count="10"],
.arrange-grid[data-count="11"],
.arrange-grid[data-count="12"],
.arrange-grid[data-count="13"],
.arrange-grid[data-count="14"],
.arrange-grid[data-count="15"] {
    grid-template-columns: repeat(5, 1fr);
}

/* 16+ images: 6 columns */
.arrange-grid[data-count]:not([data-count="1"]):not([data-count="2"]):not([data-count="3"]):not([data-count="4"]):not([data-count="5"]):not([data-count="6"]):not([data-count="7"]):not([data-count="8"]):not([data-count="9"]):not([data-count="10"]):not([data-count="11"]):not([data-count="12"]):not([data-count="13"]):not([data-count="14"]):not([data-count="15"]) {
    grid-template-columns: repeat(6, 1fr);
}

.arrange-item {
    position: relative;
    aspect-ratio: 3/4;
    border-radius: 12px;
    overflow: hidden;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.arrange-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.arrange-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.arrange-number {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    background: #ff6154;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(255, 97, 84, 0.4);
}

/* Add More Images Card */
.add-more-card {
    position: relative;
    aspect-ratio: 3/4;
    border: 3px dashed #d1d5db;
    border-radius: 12px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
}

.add-more-card:hover {
    border-color: #ff6154;
    background: #fff5f4;
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(255, 97, 84, 0.15);
}

.add-more-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    padding: 20px;
    width: 100%;
    height: 100%;
}

.add-more-label svg {
    width: 32px;
    height: 32px;
    stroke: #9ca3af;
    transition: all 0.3s ease;
}

.add-more-card:hover .add-more-label svg {
    stroke: #ff6154;
    transform: scale(1.1);
}

.add-more-label span {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    transition: color 0.3s ease;
}

.add-more-card:hover .add-more-label span {
    color: #ff6154;
}

/* Live Preview Container */
.live-preview-container {
    background: white;
    border: none;
    border-radius: 16px;
    padding: 32px;
    max-width: 700px;
    width: 100%;
    box-shadow: none;
}

.preview-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.preview-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-page-info {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.preview-nav-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.preview-nav-btn:hover:not(:disabled) {
    border-color: #ff6154;
    background: #fff5f4;
}

.preview-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.preview-nav-btn svg {
    width: 16px;
    height: 16px;
    stroke: #374151;
}

.preview-canvas-wrapper {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.preview-canvas-wrapper canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

/* Configuration Sections */
.config-sections {
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.config-section-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.config-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 24px 0;
}

.config-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.config-row:last-child {
    margin-bottom: 0;
}

.config-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.config-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    background: white;
    color: #1f2937;
}

.config-input:focus {
    outline: none;
    border-color: #ff6154;
}

/* Settings Toggle Switch */
.settings-toggle-container {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 10px;
}

.settings-toggle-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.2s ease;
}

.settings-toggle-btn.active {
    background: white;
    color: #ff6154;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.settings-toggle-btn:hover:not(.active) {
    color: #374151;
}

/* Custom Select */
.custom-select {
    position: relative;
    width: 100%;
}

.select-trigger {
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    white-space: nowrap;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1f2937;
    font-weight: 500;
    position: relative;
    text-align: left;
}

.select-trigger::after {
    content: '';
    position: absolute;
    display: none;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #9ca3af;
    transition: transform 0.2s ease;
}

.select-trigger:hover {
    border-color: #ffc9c3;
    background: #fff5f4;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
}

.toggle-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.toggle-group:first-child {
    padding-top: 0;
}

.toggle-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.toggle-switch.active {
    background: #ff6154;
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: none;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(20px);
}

/* Right side - Controls Panel (Fixed Overlay) */
.controls-panel {
    position: fixed;
    right: 0;
    top: 81px;
    width: 420px;
    box-sizing: border-box;
    padding: 24px;
    height: calc(100vh - 81px);
    background: white;
    border-left: 2px solid #e5e7eb;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.controls-sticky {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Control Sections */
.control-section {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.control-section:last-child {
    margin-bottom: 0;
}

.control-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 14px 0;
}

/* Summary Card */
.summary-card {
    background: linear-gradient(135deg, #fff5f4 0%, #ffffff 100%);
    border: 2px solid #ffe5e2;
    border-radius: 14px;
    padding: 0;
    overflow: hidden;
}

.summary-details {
    padding: 16px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.summary-item:first-child {
    padding-top: 0;
}

.summary-item:last-child {
    padding-bottom: 0;
}

.summary-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.summary-value {
    font-size: 0.9rem;
    color: #1f2937;
    font-weight: 700;
}

.summary-value.format-badge {
    background: #ff6154;
    color: white;
    padding: 4px 16px;
    border-radius: 16px;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.summary-divider {
    height: 1px;
    background: none;
    margin: 0;
}

/* Controls Divider */
.controls-divider {
    height: 2px;
    background: linear-gradient(to right, #e5e7eb 0%, #e5e7eb 50%, transparent 50%);
    background-size: 8px 2px;
    margin: 20px 0;
    flex-shrink: 0;
}

/* Extract Actions Vertical */
.extract-actions-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-extract {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.btn-extract.single {
    background-color: #ff6154;
    color: white;
}

.btn-extract.single:hover:not(:disabled) {
    background: #e5554a;
    box-shadow: 0 6px 16px rgba(255, 97, 84, 0.4);
    transform: translateY(-2px);
}

.btn-extract:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-extract svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.btn-extract.single:hover:not(:disabled) svg {
    transform: translateX(4px);
}

.btn-extract-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.btn-extract-title {
    font-size: 1rem;
    font-weight: 700;
}

.btn-extract-desc {
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 400;
}

/* Back to Arrange Button */
.back-to-arrange-btn {
    background: transparent;
    color: #6b7280;
    border: none;
    padding: 10px 0;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-to-arrange-btn:hover {
    color: #ff6154;
    transform: translateX(-2px);
}

.back-to-arrange-btn svg {
    width: 18px;
    height: 18px;
}

/* Download Screen Styles */
.download-screen {
    display: none;
    padding: 0;
    max-width: 100%;
    margin: 0;
    min-height: calc(100vh - 81px);
    background: #f8f9fa;
}

.download-screen.active {
    display: block;
}

.download-content {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 81px);
}

/* Left side - PDF Preview (scrollable) - DOWNLOAD SCREEN ONLY */
.download-screen .pdf-preview-section {
    flex: 1;
    background: #f8f9fa;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    margin-right: 450px;
    height: calc(100vh - 81px);
    box-sizing: border-box;
}

.download-screen .preview-canvas-container {
    width: 100%;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    margin-bottom: 20px;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.download-screen .preview-page-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    position: relative;
}

.download-screen .preview-page-wrapper canvas {
    width: 100%;
    height: auto;
    display: block;
}

.download-screen .page-number-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10;
}

.download-screen .preview-controls {
    display: none;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .download-screen .preview-canvas-container {
        gap: 0;
    }
    
    .download-screen .preview-page-wrapper {
        display: none;
    }
    
    .download-screen .preview-page-wrapper.active {
        display: block;
    }
    
    .download-screen .page-number-badge {
        display: none;
    }
    
    .download-screen .preview-controls {
        display: flex;
    }
}

.download-screen .preview-controls button {
    padding: 10px 18px;
    font-size: 0.9rem;
    background: white;
    border: 2px solid #e5e7eb;
    color: #374151;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    cursor: pointer;
}

.download-screen .preview-controls button svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.download-screen .preview-controls button:hover:not(:disabled) {
    border-color: #ff6154;
    background: #fff5f4;
    color: #ff6154;
}

.download-screen .preview-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.download-screen .preview-page-info {
    color: #374151;
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* Right side - Actions (Fixed Panel) */
.download-actions-section {
    position: fixed;
    right: 0;
    top: 81px;
    width: 450px;
    height: calc(100vh - 81px);
    background: white;
    border-left: 2px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 40px 32px;
    overflow-y: auto;
    box-sizing: border-box;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
}

.back-button {
    background: transparent;
    color: #6b7280;
    border: none;
    padding: 12px 20px;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-weight: 500;
    position: absolute;
    margin-top: -10px;
    left: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: none;
    color: #ff6154;
    box-shadow: none;
    transform: translateX(-2px);
    border-radius: 8px;
}

.back-button svg {
    width: 18px;
    height: 18px;
}

/* Files Preview List */
#files-preview-list {
    margin-top: 50px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Single File Card */
.single-file-card {
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.single-file-icon {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.single-file-icon svg {
    width: 28px;
    height: 28px;
    stroke: #ff6154;
    fill: none;
}

.single-file-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.single-file-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.single-file-info {
    font-size: 0.775rem;
    color: #6b7280;
}

.done-button {
    background: #10b981;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.done-button svg {
    width: 16px;
    height: 16px;
    stroke: white;
    fill: none;
}

/* Download Button */
.download-button-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.download-primary {
    width: 100%;
    padding: 16px 32px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #ff6154;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.download-primary:hover {
    background: #e5554a;
    box-shadow: 0 6px 16px rgba(255, 97, 84, 0.4);
    transform: translateY(-2px);
}

.download-primary svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
}

/* Action buttons - Share button larger than Print and Delete */
.action-buttons-grid {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    margin-top: -6px;
    margin-bottom: 10px;
}

.action-button {
    background: #f7f8f9;
    border: none;
    color: #374151;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 48px;
    height: 48px;
}

/* Share button takes more space */
.action-button.action-share {
    flex: 2;
}

.action-button:hover {
    background: #fff5f4;
}

.action-button svg {
    width: 24px;
    height: 24px;
    stroke: #6b7280;
}

.action-button:hover svg {
    stroke: #ff6154;
}

/* Convert Another Button */
.merge-another {
    background: transparent;
    color: #ff6154;
    border: 2px solid #ff6154;
    width: 100%;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.merge-another:hover {
    background: #fff5f4;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.2);
}

/* Custom scrollbar for PDF preview section (download screen only) */
.download-screen .pdf-preview-section::-webkit-scrollbar {
    width: 6px;
}

.download-screen .pdf-preview-section::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.download-screen .pdf-preview-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.download-screen .pdf-preview-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Custom scrollbar for download actions section */
.download-actions-section::-webkit-scrollbar {
    width: 6px;
}

.download-actions-section::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.download-actions-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.download-actions-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Hide elements when showing download screen */
.content-hidden {
    display: none !important;
}

/* Body state when download screen is active */
body.download-active {
    overflow: hidden;
}

/* Responsive Design for Download Screen */
@media (max-width: 1200px) {
    .download-actions-section {
        width: 380px;
    }
    
    .download-screen .pdf-preview-section {
        margin-right: 380px;
    }
}

@media (max-width: 968px) {
    .download-screen {
        position: relative;
        height: auto;
        min-height: calc(100vh - 81px);
    }
    
    .download-content {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 81px);
    }
    
    .download-actions-section {
        position: relative;
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 2px solid #e5e7eb;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06);
    }
    
    .download-screen .pdf-preview-section {
        margin-right: 0;
        padding: 100px 20px 20px 20px;
        height: auto;
        min-height: 50vh;
    }
    
    .back-button {
        top: 20px;
        left: 20px;
    }
}

@media (max-width: 768px) {
    .download-screen .pdf-preview-section {
        padding: 80px 16px 24px 16px;
    }
    
    .download-actions-section {
        padding: 24px 16px;
    }
    
    .back-button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

/* Selection Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.selection-modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

.selection-modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.selection-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.selection-modal-body {
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
}

.selection-option {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: white;
}

.selection-option:hover {
    background: #f8f9fa;
}

.selection-option.selected {
    background: #fff5f4;
    border-left: 3px solid #ff6154;
}

.selection-option:last-child {
    border-bottom: none;
}

.option-title {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}

.option-desc {
    font-size: 12px;
    color: #9ca3af;
}

.selection-option.selected .option-title {
    color: #ff6154;
}

.selection-option.selected .option-desc {
    color: #ff6154;
    opacity: 0.8;
}

/* Preview Modal */
.preview-modal-large {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    max-height: 90%;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.preview-modal-header {
    padding: 20px;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
}

.preview-modal-body {
    padding: 20px;
    height: 600px;
}

.preview-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

/* Hide elements when showing download screen */
.content-hidden {
    display: none !important;
}

/* Custom scrollbars */
.controls-panel::-webkit-scrollbar,
.pages-preview-section::-webkit-scrollbar,
.pdf-preview-section::-webkit-scrollbar,
.download-actions-section::-webkit-scrollbar,
.selection-modal-body::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-track,
.pages-preview-section::-webkit-scrollbar-track,
.pdf-preview-section::-webkit-scrollbar-track,
.download-actions-section::-webkit-scrollbar-track,
.selection-modal-body::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.controls-panel::-webkit-scrollbar-thumb,
.pages-preview-section::-webkit-scrollbar-thumb,
.pdf-preview-section::-webkit-scrollbar-thumb,
.download-actions-section::-webkit-scrollbar-thumb,
.selection-modal-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.controls-panel::-webkit-scrollbar-thumb:hover,
.pages-preview-section::-webkit-scrollbar-thumb:hover,
.pdf-preview-section::-webkit-scrollbar-thumb:hover,
.download-actions-section::-webkit-scrollbar-thumb:hover,
.selection-modal-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: scale(0.9) translateY(-20px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .controls-panel {
        width: 380px;
    }
    
    .pages-preview-section {
        margin-right: 380px;
    }
    
    .download-actions-section {
        width: 380px;
    }
    
    .pdf-preview-section {
        margin-right: 380px;
    }
    
    .config-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 968px) {
    body.selection-active {
        overflow-y: auto;
    }
    
    .selection-panel {
        position: relative;
        height: auto;
        min-height: calc(100vh - 81px);
    }
    
    .selection-content {
        flex-direction: column;
        height: auto;
    }
    
    .controls-panel {
        position: relative;
        width: 100%;
        height: auto;
        top: 0;
        border-left: none;
        border-bottom: 2px solid #e5e7eb;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
        order: 2;
    }
    
    .controls-sticky {
        padding: 32px 24px;
    }
    
    .pages-preview-section {
        margin-right: 0;
        height: auto;
        order: 1;
        padding: 32px 24px;
        overflow-y: visible;
    }
    
    .download-screen {
        position: relative;
        height: auto;
        min-height: calc(100vh - 81px);
    }
    
    .download-content {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 81px);
    }
    
    .download-actions-section {
        position: relative;
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 2px solid #e5e7eb;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06);
    }
    
    .pdf-preview-section {
        margin-right: 0;
        padding: 100px 20px 20px 20px;
        height: auto;
        min-height: 50vh;
    }
    
    .back-button {
        top: 20px;
        left: 20px;
    }
    
    .arrange-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .back-to-arrange-btn {
        margin-bottom: 16px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .pages-preview-section {
        padding: 24px 16px 40px 16px;
    }
    
    .pages-header {
        margin-bottom: 32px;
    }
    
    .pages-header h2 {
        font-size: 1.5rem;
    }
    
    .selection-subtitle {
        font-size: 0.9rem;
    }
    
    .controls-sticky {
        padding: 24px 16px;
    }
    
    .config-section-card {
        padding: 20px;
    }
    
    .config-row {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .pdf-preview-section {
        padding: 80px 16px 24px 16px;
    }
    
    .download-actions-section {
        padding: 24px 16px;
    }
    
    .back-button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .arrange-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .live-preview-container {
        padding: 20px;
    }
    
    .preview-canvas-wrapper {
        min-height: 300px;
    }
}

@media (max-width: 640px) {
    .config-section-title {
        font-size: 1.1rem;
    }
    
    .config-label {
        font-size: 0.85rem;
    }
    
    .toggle-label {
        font-size: 0.85rem;
    }
    
    .btn-extract {
        padding: 12px 14px;
    }
    
    .btn-extract-title {
        font-size: 0.95rem;
    }
    
    .btn-extract-desc {
        font-size: 0.75rem;
    }
    
    .preview-info-card {
        padding: 40px 24px;
    }
    
    .preview-title {
        font-size: 1.5rem;
    }
    
    .preview-subtitle {
        font-size: 0.9rem;
    }
    
    .arrange-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
    }
    
    .arrange-number {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .settings-toggle-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .live-preview-container {
        padding: 16px;
    }
    
    .preview-canvas-wrapper {
        padding: 15px;
        min-height: 250px;
    }
    
    .preview-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .preview-controls {
        width: 100%;
        justify-content: center;
    }
    
    .back-to-arrange-btn {
        font-size: 0.85rem;
        padding: 8px 0;
    }
}