/**
 * Crop PDF tool-specific styles.
 *
 * v1.9.3 adds crop box selection, move/resize handles, and undo/redo controls.
 */

.localpdf-edit-crop-pdf-tool [data-localpdf-edit-start-icon="crop-pdf"] .localpdf-start-illustration-pdf {
    letter-spacing: 0.04em;
}

.localpdf-edit-crop-pdf-tool [data-localpdf-edit-start-icon="crop-pdf"] .localpdf-edit-illustration-number {
    font-size: 0;
}

.localpdf-edit-crop-pdf-tool [data-localpdf-edit-start-icon="crop-pdf"] .localpdf-edit-illustration-number::after {
    content: 'CP';
    font-size: 13px;
    letter-spacing: 0.08em;
}

.localpdf-edit-crop-pdf-tool.is-crop-reading .localpdf-dropzone {
    pointer-events: none;
    opacity: 0.78;
}

.localpdf-crop-settings {
    display: grid;
    gap: 18px;
}

.localpdf-crop-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.localpdf-crop-custom-margins {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 18px;
    background: rgba(248, 250, 252, 0.82);
}

.localpdf-crop-custom-margins[hidden] {
    display: none;
}

.localpdf-crop-custom-margins .localpdf-field {
    position: relative;
}

.localpdf-crop-custom-margins .localpdf-field em {
    position: absolute;
    right: 12px;
    bottom: 12px;
    color: #64748b;
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
}

.localpdf-crop-custom-margins input[type="number"] {
    padding-right: 28px;
}

.localpdf-crop-custom-margins > p {
    grid-column: 1 / -1;
    margin: 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}

.localpdf-crop-style-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 14px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.96), rgba(241, 245, 249, 0.82));
}

.localpdf-crop-style-preview__page {
    position: relative;
    display: inline-flex;
    width: 46px;
    height: 58px;
    flex: 0 0 auto;
    border: 2px solid rgba(15, 23, 42, 0.18);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.localpdf-crop-style-preview__page span {
    position: absolute;
    inset: 8px;
    border: 2px dashed #2563eb;
    border-radius: 5px;
    background: rgba(37, 99, 235, 0.08);
}

.localpdf-crop-style-preview strong {
    color: #0f172a;
    font-size: 13px;
    line-height: 1.45;
}

.localpdf-crop-field-help,
.localpdf-crop-scope-status,
.localpdf-crop-validation-note {
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
}

.localpdf-crop-scope-status {
    margin: 14px 0 0;
    padding: 12px 14px;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 16px;
    background: rgba(37, 99, 235, 0.07);
    color: #1d4ed8;
    font-weight: 700;
}

.localpdf-crop-scope-status.is-warning {
    border-color: rgba(217, 119, 6, 0.24);
    background: rgba(245, 158, 11, 0.10);
    color: #92400e;
}

.localpdf-crop-validation-note {
    margin: 10px 0 0;
}

.localpdf-edit-crop-pdf-tool .localpdf-process-export-button.is-disabled,
.localpdf-edit-crop-pdf-tool .localpdf-process-export-button[disabled] {
    cursor: not-allowed;
    opacity: .72;
    box-shadow: none;
}

.localpdf-edit-crop-pdf-tool .localpdf-page-chip.is-skipped {
    opacity: .52;
}

@media (max-width: 860px) {
    .localpdf-crop-settings-grid,
    .localpdf-crop-custom-margins {
        grid-template-columns: 1fr;
    }
}

/* v1.9.2 live crop box overlay preview. */
.localpdf-edit-crop-pdf-tool .localpdf-preview-page {
    position: relative;
}

.localpdf-crop-overlay-layer {
    position: absolute;
    inset: 0;
    z-index: 8;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
}

.localpdf-crop-overlay-layer.is-disabled {
    cursor: not-allowed;
}

.localpdf-crop-overlay-layer:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.36);
    outline-offset: 4px;
    border-radius: 10px;
}

.localpdf-crop-overlay-box {
    position: absolute;
    min-width: 8px;
    min-height: 8px;
    border: 2px dashed #2563eb;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.10);
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.18), 0 18px 36px rgba(15, 23, 42, 0.16);
    pointer-events: none;
}

.localpdf-crop-overlay-box.is-active {
    border-style: solid;
}

.localpdf-crop-overlay-box::before,
.localpdf-crop-overlay-box::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(37, 99, 235, 0.34);
    border-radius: 5px;
    pointer-events: none;
}

.localpdf-crop-overlay-box::after {
    inset: 50% 0 auto;
    height: 0;
    border-width: 1px 0 0;
    border-radius: 0;
}

.localpdf-crop-overlay-box__label {
    position: absolute;
    left: 10px;
    top: 10px;
    max-width: calc(100% - 20px);
    overflow: hidden;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(37, 99, 235, 0.92);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.localpdf-edit-crop-pdf-tool.is-crop-page-outside-scope .localpdf-crop-overlay-layer::before,
.localpdf-crop-overlay-layer.is-disabled::before {
    content: 'Outside crop scope';
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 2;
    transform: translate(-50%, -50%);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    pointer-events: none;
}

.localpdf-crop-overlay-layer.is-disabled::before {
    content: 'Margin crop mode';
}

.localpdf-edit-crop-pdf-tool.is-crop-page-outside-scope .localpdf-crop-overlay-layer.is-disabled::before {
    content: 'Outside crop scope';
}

.localpdf-crop-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.localpdf-crop-actions .localpdf-secondary-button[disabled],
.localpdf-crop-actions .localpdf-secondary-button.is-disabled {
    cursor: not-allowed;
    opacity: .58;
}

.localpdf-crop-control-note,
.localpdf-crop-count {
    margin: 10px 0 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
}

.localpdf-crop-count {
    font-weight: 800;
    color: #1d4ed8;
}

.localpdf-edit-crop-pdf-tool .localpdf-page-chip.has-crop-box {
    position: relative;
    border-color: rgba(37, 99, 235, 0.42);
    color: #1d4ed8;
    font-weight: 900;
}

.localpdf-crop-page-badge {
    position: absolute;
    right: -5px;
    top: -7px;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    padding: 0 4px;
    background: #2563eb;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

/* v1.9.3 crop box selection, move/resize, and undo/redo controls. */
.localpdf-crop-overlay-layer.is-select-mode {
    cursor: default;
}

.localpdf-crop-overlay-layer.is-select-mode .localpdf-crop-overlay-box {
    pointer-events: auto;
    cursor: move;
}

.localpdf-crop-overlay-box.is-selected {
    border-color: #1d4ed8;
    border-style: solid;
    background: rgba(37, 99, 235, 0.14);
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.20), 0 20px 42px rgba(37, 99, 235, 0.22);
}

.localpdf-crop-resize-handle {
    position: absolute;
    z-index: 3;
    width: 12px;
    height: 12px;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: #2563eb;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.34);
    pointer-events: auto;
}

.localpdf-crop-resize-handle--nw { left: -7px; top: -7px; cursor: nwse-resize; }
.localpdf-crop-resize-handle--n { left: 50%; top: -7px; transform: translateX(-50%); cursor: ns-resize; }
.localpdf-crop-resize-handle--ne { right: -7px; top: -7px; cursor: nesw-resize; }
.localpdf-crop-resize-handle--e { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.localpdf-crop-resize-handle--se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.localpdf-crop-resize-handle--s { left: 50%; bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
.localpdf-crop-resize-handle--sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.localpdf-crop-resize-handle--w { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.localpdf-edit-crop-pdf-tool .localpdf-page-chip.has-selected-crop-box {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
