:root {
    --primary-color: #8b3dff;
    --primary-hover: #7326e6;
    --bg-light: #f4f7f6;
    --border-color: #e2e8f0;
    --text-dark: #0f172a;
    --text-muted: #64748b;
}

/* Container Workspace Layout */
.crop-tool-container {
    display: flex;
    flex-direction: row;
    gap: 20px;
    margin-top: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--text-dark);
}

/* Sidebar Layout */
.crop-sidebar {
    width: 320px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.crop-sidebar h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--text-dark);
}

.crop-sidebar h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 14px 0;
}

/* Dimension Settings Layout */
.crop-input-group {
    display: grid;
    grid-template-columns: 1fr auto 1fr 1fr;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 20px;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.input-field input, 
.input-field select,
.config-field select {
    width: 100%;
    height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #fff;
    font-size: 0.875rem;
    box-sizing: border-box;
}

/* Lock Button */
.lock-btn {
    height: 40px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}
.lock-btn:hover:not(:disabled) {
    background: var(--bg-light);
}

.panel-divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
}

/* Export Configs */
.config-field {
    margin-bottom: 16px;
}
.config-field label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.slider-label-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}
.slider-label-row label { margin-bottom: 0; }
#quality-val { font-size: 0.875rem; font-weight: 600; color: var(--primary-color); }

#crop-quality {
    width: 100%;
    accent-color: var(--primary-color);
}

/* Buttons */
.browse-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}
.download-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    height: 44px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}
.download-btn:hover:not(:disabled) { background: var(--primary-hover); }
.download-btn:disabled, .lock-btn:disabled, .input-field input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Right Main Canvas Workspace */
.crop-workspace {
    flex: 1;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
    overflow: hidden;
}

/* Upload Drop Box */
.upload-box {
    border: 2px dashed #cbd5e1;
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-sizing: border-box;
}
.upload-icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.upload-box p { color: var(--text-muted); margin: 0 0 16px 0; font-size: 0.95rem; }

/* Interactive Canvas Image Preview Container */
.canvas-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 70vh;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: inline-block;
}

#source-image-preview {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    user-select: none;
    -webkit-user-drag: none;
}

/* Interactive Bounding Crop Box Overlay */
.crop-box {
    position: absolute;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    cursor: move;
    z-index: 10;
}

/* Bounding crop box corners handles */
.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
}
.crop-handle.tl { top: -6px; left: -6px; cursor: nwse-resize; }
.crop-handle.tr { top: -6px; right: -6px; cursor: nesw-resize; }
.crop-handle.bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.crop-handle.br { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Mobile Specific Media Query Adjustments Rules */
@media (max-width: 768px) {
    .crop-tool-container {
        flex-direction: column-reverse;
    }
    .crop-sidebar {
        width: 100%;
        box-sizing: border-box;
    }
    .crop-workspace {
        min-height: 350px;
    }
}