.pdf-crop-tool {
    max-width: 800px;
    margin: 20px auto 40px;
    padding: 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tool-title {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 10px;
    margin-top: 0;
    font-weight: 500;
}

.pdf-selection-area {
    border: 2px dashed #2573a7;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

.pdf-loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 5;
}

.pdf-loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2573a7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

.pdf-selection-area:hover,
.pdf-selection-area.dragover {
    border-color: #2573a7;
    background: rgba(52, 152, 219, 0.05);
}

#pdf-file-input {
    display: none;
}

.pdf-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.pdf-drop-zone p {
    margin: 10px 0 0;
    color: #535A5B;
}

.pdf-file-info {
    margin-top: 15px;
    font-size: 14px;
    color: #27ae60;
    font-weight: 500;
}

.btn-select-file {
    background: #2573a7;
    color: white;
    padding: 9px 13px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 15px;
    transition: background-color 0.2s, transform 0.1s ease;
}

.pdf-crop-tool .btn-select-file:hover {
    background: #1f618d;
}

/* Editor Section */
.pdf-editor {
    margin-top: 0;
}

.pdf-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pdf-canvas-container {
    position: relative;
    margin-bottom: 20px;
    overflow: hidden;
    background: #f5f5f5;
    max-width: 100%;
}

.page-loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 245, 245, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    /* Below crop box but above canvas */
}

.page-loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2573a7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#pdf-canvas {
    max-width: 100%;
    display: block;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-box {
    position: absolute;
    border: 2px dashed rgba(52, 152, 219, 0.8);
    background: rgba(52, 152, 219, 0.1);
    cursor: move;
    pointer-events: auto;
    box-sizing: border-box;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #3498db;
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: auto;
}

.crop-handle.top-left {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.crop-handle.top {
    top: -6px;
    left: 50%;
    margin-left: -6px;
    cursor: ns-resize;
}

.crop-handle.top-right {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.crop-handle.right {
    top: 50%;
    right: -6px;
    margin-top: -6px;
    cursor: ew-resize;
}

.crop-handle.bottom-right {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.crop-handle.bottom {
    bottom: -6px;
    left: 50%;
    margin-left: -6px;
    cursor: ns-resize;
}

.crop-handle.bottom-left {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.crop-handle.left {
    top: 50%;
    left: -6px;
    margin-top: -6px;
    cursor: ew-resize;
}

.page-navigation {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    justify-content: center;
}

.page-navigation button {
    background: #ecf0f1;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    color: #212529;
    transition: background-color 0.2s, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-navigation button svg {
    /* Set size via CSS for better control */
    width: 1em;
    height: 1em;
    /* Prevents the SVG from shrinking inside the flex container (the button) */
    flex-shrink: 0;
}

.pdf-crop-tool .page-navigation button:hover {
    background: #d1d5d8;
}

.page-navigation button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-input-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.page-input-error {
    color: #e74c3c;
    font-size: 16px;
    text-align: center;
    margin-bottom: 5px;
}

.page-number-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: #333;
}

input[type="number"].page-number-input {
    width: 55px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    font-size: 16px;
    background-color: #fff;
    -moz-appearance: textfield;
    /* Firefox */
    appearance: textfield;
}

input[type="number"].page-number-input::-webkit-outer-spin-button,
input[type="number"].page-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pdf-crop-tool .page-number-input:focus,
.pdf-crop-tool .page-number-input:active {
    background-color: #fff;
    border-color: #2573a7;
    box-shadow: 0 0 0 1px rgba(37, 115, 167, 0.2);
    outline: none;
}

/* Controls */
.crop-controls {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    border-bottom: 1px solid #eee;
    padding: 15px 0;
    margin-bottom: 20px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.action-buttons button {
    padding: 9px 13px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-buttons button:not(.primary) {
    background: #ecf0f1;
    color: #212529;
}

.pdf-crop-tool .action-buttons button:not(.primary):hover {
    background: #d1d5d8;
}

.primary {
    background: #2573a7;
    color: white;
}

.pdf-crop-tool .primary:hover {
    background: #1f618d;
}

.crop-notification {
    text-align: center;
    color: #27ae60;
    font-weight: 500;
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    overflow: hidden;
    transition: opacity 0.3s, max-height 0.3s, margin-top 0.3s ease;
}

.crop-notification.show {
    opacity: 1;
    max-height: 50px;
    margin-top: 15px;
}

/* Result Section */
.pdf-result {
    margin-top: 30px;
    text-align: center;
}

.result-content {
    border-radius: 8px;
    margin-left: auto;
    margin-right: auto;
}

.success-icon {
    width: 60px;
    height: 60px;
    display: block;
    margin: 0 auto 15px;
}

.success-icon path {
    fill: #27ae60;
}

.result-content h3 {
    margin-bottom: 15px;
    margin: 0 0 20px;
    color: #2c3e50;
}

.btn-result {
    padding: 9px 13px;
    margin: 3px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-download {
    background-color: #1e8449;
    /* Darker Green */
    color: white;
}

.pdf-crop-tool .btn-download:hover {
    background-color: #196f3d;
}

.btn-clear {
    background-color: #6c7677;
    /* Darker Grey */
    color: white;
}

.pdf-crop-tool .btn-clear:hover {
    background-color: #4a5764;
}

.btn-back {
    background-color: #6c7677;
    color: white;
}

.pdf-crop-tool .btn-back:hover {
    background-color: #6c7677;
}

.spinner-icon {
    animation: spin 1s linear infinite;
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.2em;
    margin-right: 8px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Override theme focus/active styles to prevent conflicts */
.pdf-crop-tool button:focus,
.pdf-crop-tool button:active {
    /* Apply transform only on active click */
    outline: none;
    box-shadow: none;
}

.pdf-crop-tool button:active {
    transform: scale(0.97);
}

.pdf-crop-tool .btn-select-file:focus,
.pdf-crop-tool .primary:active,
.pdf-crop-tool .primary:focus {
    background: #1f618d;
}

.pdf-crop-tool .page-navigation button:active,
.pdf-crop-tool .page-navigation button:focus,
.pdf-crop-tool .action-buttons button:not(.primary):active,
.pdf-crop-tool .action-buttons button:not(.primary):focus {
    background: #d1d5d8;
}

.pdf-crop-tool .btn-download:active,
.pdf-crop-tool .btn-download:focus {
    background-color: #196f3d;
}

.pdf-crop-tool .btn-clear:active,
.pdf-crop-tool .btn-clear:focus {
    background-color: #4a5764;
}

.pdf-crop-tool .btn-back:active,
.pdf-crop-tool .btn-back:focus {
    background-color: #717f80;
}

/* --- Static Button Styles to Override Theme --- */
/* Primary buttons (Select File, Crop PDF) */
.pdf-crop-tool .btn-select-file:hover,
.pdf-crop-tool .btn-select-file:active,
.pdf-crop-tool .btn-select-file:focus,
.pdf-crop-tool .primary:hover,
.pdf-crop-tool .primary:active,
.pdf-crop-tool .primary:focus {
    background-color: #2573a7;
    color: white;
}

/* Secondary buttons (Clear in editor, Page Navigation) */
.pdf-crop-tool .page-navigation button:hover,
.pdf-crop-tool .page-navigation button:active,
.pdf-crop-tool .page-navigation button:focus,
.pdf-crop-tool .action-buttons button:not(.primary):hover,
.pdf-crop-tool .action-buttons button:not(.primary):active,
.pdf-crop-tool .action-buttons button:not(.primary):focus {
    background: #ecf0f1;
    color: #212529;
}

/* Download button */
.pdf-crop-tool .btn-download:hover,
.pdf-crop-tool .btn-download:active,
.pdf-crop-tool .btn-download:focus {
    background-color: #1e8449;
    color: white;
}

/* Clear button (result section) */
.pdf-crop-tool .btn-clear:hover,
.pdf-crop-tool .btn-clear:active,
.pdf-crop-tool .btn-clear:focus {
    background-color: #6c7677;
    color: white;
}

/* Back button */
.pdf-crop-tool .btn-back:hover,
.pdf-crop-tool .btn-back:active,
.pdf-crop-tool .btn-back:focus {
    background-color: #6c7677;
    color: white;
}

/* Ensure disabled buttons are not affected by theme hover */
.pdf-crop-tool .page-navigation button:disabled:hover {
    background: #ecf0f1;
    opacity: 0.5;
}

.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: 767px) {
    .pdf-crop-tool {
        margin: 0 auto 50px;
        padding: 20px 0;
        box-shadow: none;
        border-radius: 0;
        border-top: 1px solid #eee;
        border-bottom: 1px solid #eee;
    }

    .action-buttons button {
        padding: 8px;
    }

    .btn-result {
        padding: 8px;
    }

    .action-buttons,
    .btn-result {
        gap: 10px;
    }
}