/* 图片裁剪功能样式 */

/* 裁剪按钮样式 - 与编辑按钮样式保持一致 */
.crop-image-btn {
    position: absolute;
    bottom: 4px;
    left: 4px; /* 左下角位置 */
    background-color: rgba(128, 128, 128, 0.6); /* 与编辑按钮一致的灰色背景 */
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: all 0.2s ease;
    z-index: 10;
}

.image-preview-item:hover .crop-image-btn {
    opacity: 1;
}

.crop-image-btn:hover {
    background-color: rgba(128, 128, 128, 0.8); /* 悬停时背景加深 */
    transform: scale(1.1);
}

.crop-image-btn svg {
    stroke: white;
    display: block;
    width: 10px; /* 与编辑按钮图标尺寸一致 */
    height: 10px;
}

/* 已裁切状态的裁切按钮 */
.crop-image-btn--cropped {
    background-color: rgba(255, 165, 0, 0.8) !important; /* 橙色背景表示已裁切 */
    box-shadow: 0 0 0 2px rgba(255, 165, 0, 0.3); /* 橙色光晕效果 */
}

.crop-image-btn--cropped:hover {
    background-color: rgba(255, 165, 0, 1) !important; /* 悬停时更鲜艳的橙色 */
    box-shadow: 0 0 0 2px rgba(255, 165, 0, 0.5); /* 悬停时光晕更明显 */
}

/* 裁剪弹窗样式 */
.crop-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.crop-modal.active {
    display: flex;
}

.crop-container {
    position: relative;
    background-color: #1a1a1a;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* 裁剪画布区域 */
.crop-canvas-wrapper {
    position: relative;
    width: 540px;
    height: 540px;
    margin: 0 auto 20px;
    overflow: hidden;
    background-color: #ffffff; /* 白色背景 */
    border: 2px solid #e0e0e0; /* 浅灰色边框 */
    border-radius: 8px;
}

/* 裁剪框 */
.crop-box {
    position: absolute;
    width: 540px;
    height: 540px;
    border: 2px solid #007bff;
    pointer-events: none;
    z-index: 2;
}

/* 裁剪框的四个角 */
.crop-box::before,
.crop-box::after,
.crop-corner-tl,
.crop-corner-tr,
.crop-corner-bl,
.crop-corner-br {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #007bff;
    content: '';
}

.crop-box::before {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
}

.crop-box::after {
    top: -2px;
    right: -2px;
    border-left: none;
    border-bottom: none;
}

.crop-corner-bl {
    bottom: -2px;
    left: -2px;
    border-right: none;
    border-top: none;
}

.crop-corner-br {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
}

/* 裁剪图片 */
.crop-image {
    position: absolute;
    cursor: move;
    user-select: none;
    transform-origin: center center;
    transition: none;
}

.crop-image.dragging {
    cursor: grabbing;
}

/* 工具栏 */
.crop-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 15px 0 0;
}

/* 缩放控制 */
.crop-zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 8px;
}

.crop-zoom-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.crop-zoom-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.crop-zoom-slider {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    outline: none;
}

.crop-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
}

.crop-zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.crop-zoom-value {
    color: white;
    font-size: 12px;
    min-width: 40px;
    text-align: center;
}

/* 操作按钮 */
.crop-actions {
    display: flex;
    gap: 10px;
}

.crop-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.crop-btn-save {
    background-color: #007bff;
    color: white;
}

.crop-btn-save:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.crop-btn-undo {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.crop-btn-undo:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.2);
}

.crop-btn-undo:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.crop-btn-cancel {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.crop-btn-cancel:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 快捷提示 */
.crop-tips {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    text-align: center;
    white-space: nowrap;
    margin-bottom: 15px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .crop-canvas-wrapper {
        width: 320px;
        height: 320px;
    }
    
    .crop-box {
        width: 320px;
        height: 320px;
    }
    
    .crop-tips {
        font-size: 11px;
        margin-bottom: 10px;
    }
    
    .crop-toolbar {
        flex-direction: column;
        gap: 10px;
    }
    
    .crop-zoom-controls {
        width: 100%;
        justify-content: center;
    }
}

/* 深色模式支持 */
body.dark-mode .crop-container {
    background-color: #2a2a2a;
}

body.dark-mode .crop-canvas-wrapper {
    background-color: #ffffff; /* 画布始终保持白色背景 */
    border-color: #ccc; /* 深色模式下使用稍浅的边框 */
}

body.dark-mode .crop-zoom-controls {
    background-color: rgba(255, 255, 255, 0.05);
}

/* 加载动画 */
.crop-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    display: none;
}

.crop-loading.active {
    display: block;
}

/* 裁剪预览 */
.crop-preview-result {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    display: none;
}

.crop-preview-result.active {
    display: block;
}

.crop-preview-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
}