/* PDF Page Manager Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* Notification Styles */
.pdf-manager-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border-left: 4px solid rgba(255, 255, 255, 0.5);
}

.pdf-manager-notification .notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.pdf-manager-notification .notification-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: inherit;
    font-size: 12px;
    transition: background 0.2s ease;
}

.pdf-manager-notification .notification-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.notification-success {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border-left-color: #66bb6a;
}

.notification-error {
    background: linear-gradient(135deg, #f44336, #da190b);
    border-left-color: #ef5350;
}

.notification-info {
    background: linear-gradient(135deg, #2196F3, #0b7dda);
    border-left-color: #42a5f5;
}

.notification-warning {
    background: linear-gradient(135deg, #ff9800, #e68900);
    border-left-color: #ffa726;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.header {
    background: linear-gradient(135deg, #10ac84 0%, #00d2d3 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Upload Section */
.upload-section {
    padding: 40px;
}

.upload-section h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.upload-area {
    border: 3px dashed #10ac84;
    border-radius: 15px;
    padding: 60px 40px;
    text-align: center;
    background: #f8fafb;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.upload-area:hover {
    border-color: #00d2d3;
    background: #f0fff4;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #00c851;
    background: #e8f5e8;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #10ac84;
}

.upload-text h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

.upload-text p {
    color: #7f8c8d;
    font-size: 1rem;
}

.browse-button {
    background: linear-gradient(135deg, #10ac84 0%, #00d2d3 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 172, 132, 0.4);
}

.browse-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 172, 132, 0.6);
}

.file-info {
    text-align: center;
    margin-top: 15px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Toolbar Section */
.toolbar-section {
    padding: 30px 40px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    align-items: start;
}

.toolbar-group {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toolbar-group h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 2px solid #10ac84;
    padding-bottom: 8px;
}

.file-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-name {
    font-weight: 600;
    color: #2c3e50;
    word-break: break-word;
}

.page-count {
    color: #10ac84;
    font-weight: 600;
}

.view-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.view-controls label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.view-controls select {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.2s ease;
}

.view-controls select:focus {
    outline: none;
    border-color: #10ac84;
}

.bulk-actions,
.document-actions,
.export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Page Manager Section */
.page-manager-section {
    padding: 40px;
}

.manager-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.selection-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.selection-info span {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

.selection-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.manager-header h2 {
    color: #2c3e50;
}

.selection-info {
    display: flex;
    gap: 20px;
    font-weight: 600;
}

#selectionInfo {
    color: #10ac84;
}

#totalPagesInfo {
    color: #6c757d;
}

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.page-grid.large {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.page-grid.small {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.page-grid.list {
    grid-template-columns: 1fr;
    gap: 10px;
}

.page-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.page-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.page-item.selected {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.3);
    border: 2px solid #007bff;
}

.page-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-item:hover .page-checkbox,
.page-item.selected .page-checkbox {
    opacity: 1;
}

.page-checkbox-custom {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 4;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #007bff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.page-item:hover .page-checkbox-custom,
.page-item.selected .page-checkbox-custom {
    opacity: 1;
}

.page-checkbox:checked + .page-checkbox-custom {
    background: #007bff;
    border-color: #007bff;
}

.page-checkbox:checked + .page-checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.page-number {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #10ac84;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    min-width: 24px;
    text-align: center;
}

.page-thumbnail {
    width: 100%;
    max-width: 120px;
    height: 160px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.page-thumbnail canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    display: block;
    object-fit: contain;
}

.page-thumbnail.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, transparent 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.page-thumbnail.loading::after {
    content: 'Loading...';
    color: #6c757d;
    font-size: 0.8rem;
}

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

.page-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-item:hover .page-actions {
    opacity: 1;
}

.page-action-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-action-btn:hover {
    background: #495057;
    transform: translateY(-1px);
}

.page-action-btn.rotate {
    background: #007bff;
}

.page-action-btn.rotate:hover {
    background: #0056b3;
}

.page-action-btn.delete {
    background: #dc3545;
}

.page-action-btn.delete:hover {
    background: #c82333;
}

.page-item.list {
    display: flex;
    align-items: center;
    text-align: left;
    padding: 15px 20px;
}

.page-item.list .page-thumbnail {
    width: 60px;
    height: 80px;
    margin: 0 20px 0 0;
    flex-shrink: 0;
}

.page-item.list .page-info {
    flex: 1;
}

.page-item.list .page-actions {
    margin: 0;
    justify-content: flex-end;
}

.manager-footer {
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 150px;
    overflow: hidden;
}

.context-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.9rem;
}

.context-item:hover {
    background: #f8f9fa;
}

.context-divider {
    height: 1px;
    background: #e9ecef;
    margin: 4px 0;
}

/* Preview Modal */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
}

.modal-content {
    position: relative;
    background: white;
    width: 100%;
    max-width: 1000px;
    max-height: 90vh;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 30px;
    border-bottom: 1px solid #dee2e6;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    flex-shrink: 0;
}

.modal-title-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #6c757d;
    color: #2c3e50;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-weight: bold;
}

.close-btn:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
    transform: scale(1.1);
}

.modal-body {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 60;
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0;
}

.nav-btn {
    background: #10ac84;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    min-width: 100px;
}

.nav-btn:hover:not(:disabled) {
    background: #0e976f;
    transform: translateY(-1px);
}

.nav-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.preview-info {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
    min-width: 120px;
    text-align: center;
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8f9fa;
    overflow: auto;
    min-height: 400px;
    max-height: calc(90vh - 200px);
}

.preview-container canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    background: white;
    cursor: grab;
    object-fit: contain;
}

.preview-container canvas:active {
    cursor: grabbing;
}

.preview-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Processing Section */
.processing-section {
    padding: 60px 40px;
    background: #f8f9fa;
    text-align: center;
}

.processing-content {
    max-width: 400px;
    margin: 0 auto;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #e9ecef;
    border-top: 6px solid #10ac84;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#processingTitle {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

#processingDescription {
    color: #7f8c8d;
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10ac84, #00d2d3);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-weight: 600;
    color: #10ac84;
}

/* Results Section */
.results-section {
    padding: 60px 40px;
    background: #f8f9fa;
    text-align: center;
}

.results-content {
    max-width: 500px;
    margin: 0 auto;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.results-content h3 {
    font-size: 1.8rem;
    margin-bottom: 30px;
    color: #27ae60;
}

.result-summary {
    background: white;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f3f4;
}

.summary-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.summary-item .label {
    font-weight: 600;
    color: #2c3e50;
}

.summary-item .value {
    color: #10ac84;
    font-weight: 600;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.additional-actions {
    display: flex;
    justify-content: center;
}

/* Error Section */
.error-section {
    padding: 60px 40px;
    background: #f8f9fa;
    text-align: center;
}

.error-content {
    max-width: 500px;
    margin: 0 auto;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.error-content h3 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: #e74c3c;
}

.error-content p {
    color: #7f8c8d;
    margin-bottom: 30px;
    line-height: 1.6;
}

.error-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #10ac84 0%, #00d2d3 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 172, 132, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 172, 132, 0.6);
}

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.download-icon {
    font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 15px;
    }
    
    .header {
        padding: 30px 20px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .upload-section,
    .toolbar-section,
    .page-manager-section,
    .processing-section,
    .results-section,
    .error-section {
        padding: 30px 20px;
    }
    
    .upload-area {
        padding: 40px 20px;
    }
    
    .toolbar {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .toolbar-group {
        padding: 15px;
    }
    
    .bulk-actions,
    .document-actions,
    .export-actions {
        justify-content: center;
    }
    
    .page-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
    }
    
    .manager-header {
        flex-direction: column;
        text-align: center;
    }
    
    .selection-info {
        justify-content: center;
    }
    
    .result-actions,
    .error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 280px;
    }
    
    .modal-content {
        margin: 20px;
        max-width: calc(100% - 40px);
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .preview-controls {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .upload-text h3 {
        font-size: 1.2rem;
    }
    
    .page-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .page-item {
        padding: 10px;
    }
    
    .page-thumbnail {
        height: 120px;
    }
    
    .toolbar-group h3 {
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}

/* Enhanced Page Manager Styles */
.manager-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.selection-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.selection-info span {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

.selection-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.manager-header h2 {
    color: #2c3e50;
}

.selection-info {
    display: flex;
    gap: 20px;
    font-weight: 600;
}

#selectionInfo {
    color: #10ac84;
}

#totalPagesInfo {
    color: #6c757d;
}

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.page-grid.large {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.page-grid.small {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.page-grid.list {
    grid-template-columns: 1fr;
    gap: 10px;
}

.page-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.page-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.page-item.selected {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.3);
    border: 2px solid #007bff;
}

.page-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-item:hover .page-checkbox,
.page-item.selected .page-checkbox {
    opacity: 1;
}

.page-checkbox-custom {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 4;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #007bff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.page-item:hover .page-checkbox-custom,
.page-item.selected .page-checkbox-custom {
    opacity: 1;
}

.page-checkbox:checked + .page-checkbox-custom {
    background: #007bff;
    border-color: #007bff;
}

.page-checkbox:checked + .page-checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Enhanced Preview Modal Styles */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 30px;
    border-bottom: 1px solid #dee2e6;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.modal-title-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preview-page-selection {
    display: flex;
    align-items: center;
}

.page-select-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #6c757d;
    user-select: none;
}

.page-select-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkmark {
    position: relative;
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-wrap: wrap;
    gap: 15px;
}

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

.zoom-btn {
    padding: 4px 8px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s ease;
}

.zoom-btn:hover {
    background: #0056b3;
}

#zoomLevel {
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    min-width: 50px;
    text-align: center;
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8f9fa;
    overflow: auto;
    max-height: 70vh;
}

.preview-container canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    background: white;
    cursor: grab;
}

.preview-container canvas:active {
    cursor: grabbing;
}

.preview-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    flex-wrap: wrap;
}

/* Processing Section */
.processing-section {
    padding: 60px 40px;
    background: #f8f9fa;
    text-align: center;
}

.processing-content {
    max-width: 400px;
    margin: 0 auto;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #e9ecef;
    border-top: 6px solid #10ac84;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#processingTitle {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

#processingDescription {
    color: #7f8c8d;
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10ac84, #00d2d3);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-weight: 600;
    color: #10ac84;
}

/* Results Section */
.results-section {
    padding: 60px 40px;
    background: #f8f9fa;
    text-align: center;
}

.results-content {
    max-width: 500px;
    margin: 0 auto;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.results-content h3 {
    font-size: 1.8rem;
    margin-bottom: 30px;
    color: #27ae60;
}

.result-summary {
    background: white;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f3f4;
}

.summary-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.summary-item .label {
    font-weight: 600;
    color: #2c3e50;
}

.summary-item .value {
    color: #10ac84;
    font-weight: 600;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.additional-actions {
    display: flex;
    justify-content: center;
}

/* Error Section */
.error-section {
    padding: 60px 40px;
    background: #f8f9fa;
    text-align: center;
}

.error-content {
    max-width: 500px;
    margin: 0 auto;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.error-content h3 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: #e74c3c;
}

.error-content p {
    color: #7f8c8d;
    margin-bottom: 30px;
    line-height: 1.6;
}

.error-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #10ac84 0%, #00d2d3 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 172, 132, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 172, 132, 0.6);
}

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.download-icon {
    font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 15px;
    }
    
    .header {
        padding: 30px 20px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .upload-section,
    .toolbar-section,
    .page-manager-section,
    .processing-section,
    .results-section,
    .error-section {
        padding: 30px 20px;
    }
    
    .upload-area {
        padding: 40px 20px;
    }
    
    .toolbar {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .toolbar-group {
        padding: 15px;
    }
    
    .bulk-actions,
    .document-actions,
    .export-actions {
        justify-content: center;
    }
    
    .page-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
    }
    
    .manager-header {
        flex-direction: column;
        text-align: center;
    }
    
    .selection-info {
        justify-content: center;
    }
    
    .result-actions,
    .error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 280px;
    }
    
    .modal-content {
        margin: 20px;
        max-width: calc(100% - 40px);
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .preview-controls {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .selection-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .btn-sm {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }
    
    .zoom-controls {
        order: -1;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .upload-text h3 {
        font-size: 1.2rem;
    }
    
    .page-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .page-item {
        padding: 10px;
    }
    
    .page-thumbnail {
        height: 120px;
    }
    
    .toolbar-group h3 {
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}
