.pdf-extract-container {
    max-width: 800px;
    margin: 20px auto 40px;
    padding: 15px 30px 30px 30px;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.loading-text {
    text-align: center;
    font-size: 16px;
    color: #5a6a7a;
    margin-top: 10px;
    width: 100%;
    /* Ensure it takes full width to be centered */
}

.extract-title {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 20px;
    margin-top: 0;
}

.extract-dropzone {
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 30px;
    background-color: #f8f9fa;
    /* Matched color from 2.html */
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 450px;
    margin: 0 auto 20px;
    /* Center the dropzone */
}

.extract-dropzone:hover,
.extract-dropzone.dragover {
    border-color: #3498db;
    background-color: #f0f7fd;
}

.dropzone-text {
    font-size: 18px;
    color: #34495e;
    margin-bottom: 0;
}

.dropzone-or {
    color: #34495e;
    margin: 10px 0;
}

.extract-btn {
    padding: 9px 12px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s, box-shadow 0.5s ease-out, transform 0.1s ease;
}

.extract-btn:active {
    transform: scale(0.98);
}

.select-btn {
    background-color: #2563eb;
    color: white;
}

.select-btn:hover,
.select-btn:active,
.select-btn:focus {
    background-color: #2563eb;
}

.action-btn {
    background-color: #15803d;
    color: white;
}

.action-btn:hover,
.action-btn:active,
.action-btn:focus {
    background-color: #15803d;
}

.action-btn:disabled {
    background-color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
}

.download-btn {
    background-color: #15803d;
    color: white;
}

.download-btn:hover,
.download-btn:active,
.download-btn:focus {
    background-color: #15803d;
}

/* Spinner for buttons */
.extract-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.reset-btn {
    background-color: #64748b;
    color: white;
}

.reset-btn:hover,
.reset-btn:active,
.reset-btn:focus {
    background-color: #64748b;
}

.back-btn {
    background-color: #64748b;
    color: white;
}

.back-btn:hover,
.back-btn:active,
.back-btn:focus {
    background-color: #64748b;
}


.page-range-container {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
    /* Make the control bar sticky */
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 5;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.page-action-buttons {
    display: flex;
    gap: 10px;
}

.range-label {
    font-weight: 500;
    color: #2c3e50;
}

.pdf-extract-container .range-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    min-width: 200px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
    /* Ensure white background to override theme */
}

.pdf-extract-container .range-input:focus,
.pdf-extract-container .range-input:active {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.25);
    background-color: #fff;
    /* Keep background white on focus/active */
}

.select-all-container {
    margin-bottom: 15px;
    padding-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    /* Allow items to wrap */
    align-items: center;
}

.select-all-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.select-all-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: #2c3e50;
    cursor: pointer;
}

.thumbnail-loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

.progress-container {
    flex-grow: 1;
    /* Take remaining space */
    height: 20px;
    background-color: #ecf0f1;
    border-radius: 10px;
    margin-left: 15px;
    position: relative;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    width: 0%;
    background-color: #3498db;
    transition: width 0.1s linear;
    border-radius: 10px;
}

.progress-percentage-text {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 500;
    margin-left: 10px;
    min-width: 40px;
    /* Reserve space to prevent layout shift */
    text-align: left;
}

.page-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.extract-progress-view {
    padding: 20px 0;
}

.progress-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.progress-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 15px;
}

.page-thumbnail {
    width: 120px;
    height: 168px;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.page-thumbnail.selected {
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed #3498db;
}

.page-thumbnail:hover .thumbnail-actions {
    opacity: 1;
}

.thumbnail-actions {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 3;
    pointer-events: none;
    /* Let clicks pass through to thumbnail */
}

.action-icon {
    pointer-events: auto;
    /* Make icons clickable */
    position: absolute;
    top: 5px;
    color: white;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.5s ease-out;
    background-color: rgba(44, 62, 80, 0.7);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Reset button styles */
    border: none;
    padding: 0;
}

.preview-icon {
    left: 5px;
}

.rotate-icon {
    left: 38px;
    /* Positioned next to the preview icon */
}

.action-icon svg {
    width: 18px;
    height: 18px;
}

.action-icon.clicked-zoom {
    /* Class for temporary zoom on click */
    transform: scale(1.2);
}

.action-icon:active,
.action-icon:hover,
.action-icon:focus {
    /* Prevent theme from applying an active background color */
    background-color: rgba(44, 62, 80, 0.7);
}

.page-number {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.selection-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background-color: #3498db;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    transform: scale(0);
    transform-origin: top right;
    transition: transform 0.2s ease;
    z-index: 2;
}

.page-thumbnail.selected .selection-icon {
    transform: scale(1);
}

/* Result Section */
.extract-success-view {
    text-align: center;
    margin-top: 0;
}

.extract-result {
    padding: 10px;
    margin-top: 0;
}

.result-preview {
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    padding: 30px 20px;
    background-color: #f9fafb;
    max-width: 400px;
    text-align: center;
    /* Ensure content is centered on all screen sizes */
    margin: 0 auto 20px auto;
}

.result-pdf-icon {
    width: 50px;
    height: 50px;
    fill: #dc2626;
    /* Red color to match download button */
    margin-bottom: 15px;
}

.result-title {
    font-size: 18px;
    color: #2c3e50;
    margin: 0 0 5px 0;
    word-break: break-all;
}

.result-size {
    font-size: 14px;
    color: #455758;
    margin: 0;
    text-align: center;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.faq-list {
    margin-top: 1rem;
}

.faq-list dt {
    font-weight: 500;
    font-size: 1.1em;
    margin-top: 1rem;
}

.faq-list dd {
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

.preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.preview-overlay.pdf-extract-hidden {
    opacity: 0;
    pointer-events: none;
}

.close-preview {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 45px;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
    background-color: rgba(44, 62, 80, 0.7);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: none;
    padding: 0;
    outline: none;
    transition: transform 0.2s, background-color 0.2s;
}

.close-preview:hover {
    transform: scale(1.1);
}

.close-preview:active {
    transform: scale(0.95);
}

.preview-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-content canvas {
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
}

.pdf-extract-hidden {
    display: none !important;
}

/* Spinner for the thumbnail preview area */
.preview-area-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f0f0f0;
    /* Light grey */
    border-top: 5px solid #3498db;
    /* Blue */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
    /* Center and add spacing */
}

.faq-list {
    margin-top: 1rem;
}

.faq-list dt {
    font-weight: 500;
    font-size: 1.1em;
}

.faq-list dd {
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

/* Responsive Styles */
@media (max-width: 600px) {
    .pdf-extract-container {
        padding: 15px 0;
        margin: 10px 0 30px;
        border-radius: 0;
        box-shadow: none;
        border-left: none;
        border-right: none;
        border-color: #e0e0e0;
    }

    .preview-container {
        padding-left: 0;
        padding-right: 0;
    }

    .extract-dropzone {
        padding: 30px 15px;
    }

    .page-range-container {
        flex-direction: column;
        align-items: center;
    }

    .range-input {
        width: 90%;
        max-width: 300px;
    }

    .extract-btn {
        padding: 9px;
    }

    .rotate-icon {
        font-size: 26px;
    }

    .thumbnail-actions {
        opacity: 1;
    }
}