/**
 * 图片裁剪旋转样式
 */

/* 布局 */
.crop-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    min-height: 500px;
}

/* 左侧工具栏 */
.crop-toolbar {
    width: 200px;
    flex-shrink: 0;
    background: var(--color-bg-secondary);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tool-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
}

/* 上传按钮 */
.btn-upload {
    width: 100%;
    justify-content: center;
}

/* 比例选项 */
.ratio-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.ratio-btn {
    padding: 8px 4px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 6px;
    font-size: 12px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.ratio-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.ratio-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* 旋转选项 */
.rotate-options {
    display: flex;
    gap: 8px;
}

.rotate-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.rotate-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.rotate-btn span:first-child {
    font-size: 20px;
}

.rotate-label {
    font-size: 11px;
    color: var(--color-text-secondary);
}

.angle-slider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.angle-slider input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--color-bg);
    border-radius: 2px;
    appearance: none;
    cursor: pointer;
}

.angle-slider input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
}

.angle-value {
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--color-primary);
    min-width: 36px;
    text-align: right;
}

/* 翻转选项 */
.flip-options {
    display: flex;
    gap: 8px;
}

.flip-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 8px;
    font-size: 12px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.flip-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.flip-btn span:first-child {
    font-size: 18px;
}

/* 裁剪信息 */
.crop-info {
    padding: 12px;
    background: var(--color-bg);
    border-radius: 8px;
    font-size: 12px;
}

.crop-info.hidden {
    display: none;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    color: var(--color-text-secondary);
}

.info-row span:last-child {
    font-family: 'JetBrains Mono', monospace;
    color: var(--color-text);
}

/* 操作按钮 */
.tool-section.actions {
    margin-top: auto;
    gap: 8px;
}

.tool-section.actions .btn {
    width: 100%;
    justify-content: center;
}

.btn-download:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 右侧编辑区 */
.crop-editor {
    flex: 1;
    background: var(--color-bg-secondary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

/* 占位符 */
.editor-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 60px;
    border-radius: 12px;
    transition: all 0.2s;
}

.editor-placeholder:hover {
    background: var(--color-bg);
}

.placeholder-icon {
    font-size: 64px;
}

.placeholder-text {
    font-size: 15px;
    color: var(--color-text-secondary);
}

/* 编辑画布 */
.editor-canvas {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-canvas.hidden {
    display: none;
}

#main-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* 裁剪框 */
.crop-box {
    position: absolute;
    border: 2px solid white;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
    transition: box-shadow 0.15s;
}

.crop-box-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px dashed rgba(255, 255, 255, 0.5);
}

/* 网格线 */
.crop-box::before,
.crop-box::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
}

.crop-box::before {
    top: 33.33%;
    left: 0;
    right: 0;
    height: 1px;
    box-shadow: 0 calc(33.33% * 2) 0 rgba(255, 255, 255, 0.3);
}

.crop-box::after {
    left: 33.33%;
    top: 0;
    bottom: 0;
    width: 1px;
    box-shadow: calc(33.33% * 2) 0 0 rgba(255, 255, 255, 0.3);
}

/* 裁剪手柄 */
.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 1px solid var(--color-primary);
    border-radius: 2px;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle.n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle.s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle.w { left: -6px; top: 50%; transform: translateY(-50%); cursor: w-resize; }
.crop-handle.e { right: -6px; top: 50%; transform: translateY(-50%); cursor: e-resize; }

/* 响应式 */
@media (max-width: 800px) {
    .crop-layout {
        flex-direction: column;
    }

    .crop-toolbar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .tool-section {
        min-width: 140px;
        flex: 1;
    }

    .tool-section.actions {
        width: 100%;
        flex-direction: row;
        margin-top: 0;
    }

    .tool-section.actions .btn {
        flex: 1;
    }
}
