/* Crop PDF Tool - Custom Styles */

.toolInput:invalid,
.toolInput:valid {
    border-color: #ced4da !important;
    box-shadow: none !important;
}

.toolInput:focus {
    border-color: #80bdff !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

/* Crop Canvas Container */
.crop-canvas-container {
    position: relative;
    display: inline-block;
    background-color: #525659;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.375rem;
    padding: 20px;
    overflow: hidden;
    min-height: 300px;
    width: 100%;
    text-align: center;
}

.crop-canvas-container canvas {
    display: block;
    margin: 0 auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

/* Crop Box */
.crop-box {
    position: absolute;
    border: 2px dashed #28a745;
    background-color: rgba(40, 167, 69, 0.1);
    cursor: grab;
    pointer-events: auto;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.crop-box:active {
    cursor: grabbing;
}

/* Crop Handles */
.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: #28a745;
    border: 2px solid #fff;
    border-radius: 2px;
    pointer-events: auto;
}

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

.crop-handle:hover {
    background-color: #218838;
    transform: scale(1.2);
}

.crop-handle.n:hover,
.crop-handle.s:hover {
    transform: translateX(-50%) scale(1.2);
}

.crop-handle.e:hover,
.crop-handle.w:hover {
    transform: translateY(-50%) scale(1.2);
}

/* Crop Dimensions Label */
.crop-dimensions {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 5px;
    font-family: monospace;
}

/* Page Navigation */
#prevPageBtn:disabled,
#nextPageBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Preset Buttons */
.preset-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.preset-btn:hover {
    background-color: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary);
}

/* Result Info Alert */
#resultInfo {
    background-color: rgba(13, 110, 253, 0.1);
    border: 1px solid rgba(13, 110, 253, 0.2);
}

/* PDF Preview */
.pdf-preview-wrapper {
    width: 100%;
    height: 600px;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.375rem;
    overflow: hidden;
    background-color: #525659;
}

.pdf-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Fullscreen */
.viewer-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    background-color: var(--bs-body-bg);
    padding: 1rem;
    overflow-y: auto;
    margin: 0 !important;
}

.viewer-fullscreen .pdf-preview-wrapper {
    height: calc(100vh - 100px) !important;
}

/* Dark mode */
[data-bs-theme="dark"] .crop-canvas-container {
    background-color: #2c2c2c;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .crop-box {
    border-color: #5cb85c;
    background-color: rgba(92, 184, 92, 0.15);
}

[data-bs-theme="dark"] .crop-handle {
    background-color: #5cb85c;
}

[data-bs-theme="dark"] .pdf-preview-wrapper {
    border-color: rgba(255, 255, 255, 0.1);
    background-color: #2c2c2c;
}

[data-bs-theme="dark"] #resultInfo {
    background-color: rgba(13, 110, 253, 0.15);
    border-color: rgba(13, 110, 253, 0.3);
}

[data-bs-theme="dark"] .viewer-fullscreen {
    background-color: var(--dark-bg-primary);
}

/* Button hover effects */
#downloadBtn:hover,
#previewBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.5rem 1rem rgba(25, 135, 84, 0.25);
}

.form-label {
    cursor: default;
    user-select: none;
}

/* Margin inputs */
.input-group-sm .unit-label {
    min-width: 35px;
    justify-content: center;
    font-size: 0.75rem;
}

/* Responsive */
@media (max-width: 991px) {
    .crop-canvas-container {
        min-height: 250px;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .crop-canvas-container {
        min-height: 200px;
        padding: 10px;
    }

    .crop-handle {
        width: 18px;
        height: 18px;
    }

    .crop-handle.nw { top: -9px; left: -9px; }
    .crop-handle.ne { top: -9px; right: -9px; }
    .crop-handle.sw { bottom: -9px; left: -9px; }
    .crop-handle.se { bottom: -9px; right: -9px; }
    .crop-handle.n { top: -9px; }
    .crop-handle.s { bottom: -9px; }
    .crop-handle.e { right: -9px; }
    .crop-handle.w { left: -9px; }

    .pdf-preview-wrapper {
        height: 500px;
    }

    .preset-btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

@media (max-width: 576px) {
    .crop-canvas-container {
        min-height: 180px;
        padding: 8px;
    }

    .pdf-preview-wrapper {
        height: 400px;
    }

    .crop-dimensions {
        font-size: 10px;
        padding: 1px 6px;
    }
}
