/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header styles */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo i {
    font-size: 3rem;
    color: #ff6b6b;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main content */
.main-content {
    flex: 1;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

/* Upload section */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    background: #fafafa;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #667eea;
    background: #e8f2ff;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.upload-area p {
    color: #666;
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.upload-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.browse-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.browse-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(102, 126, 234, 0.4);
}

.browse-btn:active {
    transform: translateY(0);
}

.quick-select-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
}

.quick-select-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(255, 107, 107, 0.4);
}

.upload-info {
    margin-top: 15px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.upload-info small {
    color: #667eea;
    font-weight: 500;
}

/* Quick Selection Panel */
.quick-selection-panel {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 20px;
    padding: 25px;
    margin-top: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #dee2e6;
}

.panel-header h4 {
    color: #333;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-quick-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-quick-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.quick-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

.quick-option {
    background: white;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.quick-option:hover {
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.option-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.option-content {
    flex: 1;
}

.option-content h5 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 1.1rem;
}

.option-content p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

.option-action .option-btn {
    background: #4ecdc4;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.option-action .option-btn:hover {
    background: #44a08d;
    transform: scale(1.1);
}

/* One-Click Selection Features */
.one-click-btn {
    background: linear-gradient(135deg, #ffa726, #ff7043);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.one-click-btn:hover {
    background: linear-gradient(135deg, #ff9800, #ff5722);
    transform: translateY(-1px);
}

.one-click-bar {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid #ffcc02;
    animation: slideDown 0.3s ease;
}

.selection-presets {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.preset-btn {
    background: white;
    color: #ff9800;
    border: 2px solid #ff9800;
    padding: 10px 15px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

.preset-btn:hover {
    background: #ff9800;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.3);
}

.preset-btn.active {
    background: #ff9800;
    color: white;
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.3);
}

.quick-range {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    border: 1px solid #ff9800;
}

.quick-range input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

.quick-range input:focus {
    outline: none;
    border-color: #ff9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.1);
}

.apply-range-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.apply-range-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
}

/* Files section */
.files-section {
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.section-header h3 {
    font-size: 1.3rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-controls {
    display: flex;
    gap: 10px;
}

.preview-all-btn {
    background: #4ecdc4;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-all-btn:hover {
    background: #44a08d;
    transform: translateY(-1px);
}

.clear-all-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.clear-all-btn:hover {
    background: #ff5252;
    transform: translateY(-1px);
}

.files-list {
    margin-bottom: 30px;
}

.file-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.file-item:hover {
    background: #e8f2ff;
    border-color: #667eea;
    transform: translateX(5px);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.file-icon {
    font-size: 2rem;
    color: #ff6b6b;
}

.file-details h4 {
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: #333;
}

.file-details p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.page-selection-info {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #4ecdc4;
    font-weight: 600;
    font-size: 0.85rem;
}

.file-page-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quick-page-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.quick-page-btn {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 40px;
    justify-content: center;
}

.quick-page-btn:hover {
    background: linear-gradient(135deg, #44a08d, #4ecdc4);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(78, 205, 196, 0.3);
}

.quick-page-btn:active {
    transform: translateY(0);
}

.quick-page-btn.selected {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    box-shadow: 0 3px 8px rgba(255, 107, 107, 0.3);
}

.file-actions {
    display: flex;
    gap: 10px;
}

.move-btn, .remove-btn, .preview-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
}

.move-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.remove-btn:hover {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

.preview-btn:hover {
    background: #4ecdc4;
    color: white;
    border-color: #4ecdc4;
}

/* Page Selection Panel */
.page-selection-panel {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin: 20px 0;
    border: 1px solid #e9ecef;
}

.page-selection-panel h4 {
    margin-bottom: 20px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.selection-options {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.radio-option:hover {
    background: #e8f2ff;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 50%;
    position: relative;
    transition: all 0.3s ease;
}

.radio-option input[type="radio"]:checked + .radio-custom {
    border-color: #667eea;
}

.radio-option input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
}

.page-inputs, .custom-pages {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-weight: 600;
    color: #555;
}

.input-group input, .custom-pages input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input:focus, .custom-pages input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.custom-pages {
    flex-direction: column;
    align-items: flex-start;
}

.custom-pages small {
    color: #666;
    font-style: italic;
}

/* Merge Options */
.merge-options {
    margin: 30px 0;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.option-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.option-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 8px;
}

.checkbox-option input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 4px;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-option input[type="checkbox"]:checked + .checkbox-custom {
    background: #667eea;
    border-color: #667eea;
}

.checkbox-option input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: white;
    font-weight: bold;
    font-size: 12px;
}

.option-card small {
    color: #666;
    font-size: 0.85rem;
    margin-left: 28px;
}

.advanced-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: 15px;
}

.advanced-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.merge-controls {
    text-align: center;
    padding: 30px 0;
}

.merge-btn {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    padding: 18px 40px;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 25px rgba(78, 205, 196, 0.3);
}

.merge-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(78, 205, 196, 0.4);
}

.merge-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Progress section */
.progress-section {
    margin-bottom: 30px;
}

.progress-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    text-align: center;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-weight: 600;
    color: #333;
}

.progress-bar {
    background: #e9ecef;
    border-radius: 25px;
    height: 12px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    background: linear-gradient(90deg, #4ecdc4, #44a08d);
    height: 100%;
    width: 0%;
    border-radius: 25px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Result section */
.result-section {
    text-align: center;
}

.result-card {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border-radius: 20px;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: sparkle 3s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(0.8) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.result-card h3 {
    font-size: 2rem;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.result-card p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.result-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.download-btn, .new-merge-btn {
    background: white;
    color: #4ecdc4;
    border: 2px solid white;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.download-btn:hover, .new-merge-btn:hover {
    background: transparent;
    color: white;
    transform: translateY(-2px);
}

/* Footer */
.footer {
    margin-top: 40px;
    text-align: center;
}

.features {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    color: white;
}

.feature {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    opacity: 0.9;
}

.feature i {
    font-size: 1.2rem;
    color: #4ecdc4;
}

/* Toast notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    font-weight: 600;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 350px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    background: #4ecdc4;
}

.toast.error {
    background: #ff6b6b;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .main-content {
        padding: 25px;
        border-radius: 15px;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .upload-area {
        padding: 40px 15px;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .upload-area h3 {
        font-size: 1.3rem;
    }
    
    .file-item {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }
    
    .file-info {
        grid-row: 1;
    }
    
    .file-page-selector {
        grid-row: 2;
        justify-self: start;
    }
    
    .file-actions {
        grid-row: 3;
        justify-self: end;
        width: auto;
    }
    
    .quick-page-actions {
        justify-content: flex-start;
    }
    
    .upload-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .upload-buttons .browse-btn,
    .upload-buttons .quick-select-btn {
        width: 100%;
        justify-content: center;
    }
    
    .quick-options {
        grid-template-columns: 1fr;
    }
    
    .header-controls {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .header-controls button {
        width: 100%;
        justify-content: center;
    }
    
    .result-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .features {
        flex-direction: column;
        gap: 20px;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .selection-options {
        flex-direction: column;
        gap: 10px;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
    }
    
    .page-inputs {
        flex-direction: column;
        align-items: stretch;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .preview-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .page-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
    
    .advanced-options {
        gap: 20px;
    }
    
    .input-row {
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 10px;
    }
    
    .browse-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }
    
    .merge-btn, .advanced-btn {
        padding: 15px 30px;
        font-size: 1.1rem;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .download-btn, .new-merge-btn {
        padding: 12px 25px;
        font-size: 1rem;
        width: 100%;
        justify-content: center;
    }
    
    .nav-btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .page-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
    
    .selection-summary {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .select-all-btn, .clear-selection-btn {
        width: 100%;
        justify-content: center;
    }
    
    #pdfCanvas {
        max-width: 100%;
        height: auto;
    }
}

/* Animation for file items */
.file-item {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    margin: 2% auto;
    border-radius: 20px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 30px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

/* Preview Modal Specific */
.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.file-info {
    font-weight: 600;
    color: #333;
}

.preview-container {
    text-align: center;
    background: #f0f0f0;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

#pdfCanvas {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.page-controls {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.page-btn {
    background: #4ecdc4;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-btn:hover {
    background: #44a08d;
    transform: scale(1.1);
}

.page-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.page-selection-preview {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
}

.page-selection-preview h4 {
    margin-bottom: 15px;
    color: #333;
}

.page-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.page-thumbnail {
    aspect-ratio: 3/4;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.page-thumbnail:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.page-thumbnail.selected {
    border-color: #4ecdc4;
    background: #e8f8f7;
}

.page-thumbnail::after {
    content: attr(data-page);
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.selection-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.select-all-btn, .clear-selection-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.clear-selection-btn {
    background: #ff6b6b;
}

.select-all-btn:hover {
    background: #5a67d8;
}

.clear-selection-btn:hover {
    background: #ff5252;
}

/* Advanced Modal Specific */
.advanced-options {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.option-group {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
}

.option-group h4 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.input-row label {
    font-weight: 600;
    color: #555;
}

.input-row input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-row input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.password-options {
    margin-top: 15px;
    padding: 15px;
    background: #fff3cd;
    border-radius: 8px;
    border: 1px solid #ffeaa7;
}

.password-options input {
    width: 100%;
    margin-bottom: 8px;
}

.password-options small {
    color: #856404;
}

.modal-actions {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.save-options-btn {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.save-options-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(78, 205, 196, 0.3);
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
