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

/* 裁剪按钮样式 - 与编辑按钮样式保持一致 */
.crop-image-btn {
    bottom: 6px;
    left: 6px; /* 左下角位置 */
}

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

/* 已裁切状态的裁切按钮 */
.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: #0f0f0f; /* 更深的黑色 */
    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;
    box-sizing: border-box; /* 防止边框溢出容器 */
    pointer-events: none;
    z-index: 2;
    /* 亮窗+暗遮罩：使用极大外阴影形成外部变暗效果 */
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.55);
}

/* 裁剪框的四个角 */
/* 使用虚线边框，不再显示四角修饰，避免溢出 */
.crop-box::before,
.crop-box::after,
.crop-corner-tl,
.crop-corner-tr,
.crop-corner-bl,
.crop-corner-br { display: 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-ratio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
    color: white;
    position: relative; /* 作为菜单定位的参照 */
}

.crop-ratio-label {
    font-size: 12px;
    opacity: 0.8;
}

/* 触发按钮 */
.crop-ratio-button {
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

/* 左侧弹出菜单 */
.crop-ratio-menu {
    position: absolute;
    right: 100%; /* 向左弹出 */
    bottom: 0;   /* 与按钮底部对齐，向上展开 */
    transform: translateX(-8px);
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 6px 0;
    list-style: none;
    margin: 0;
    min-width: 120px;
    max-height: 60vh; /* 防止超出视口 */
    overflow-y: auto;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 3;
}

#cropRatioControls.open .crop-ratio-menu {
    display: block;
}

.crop-ratio-item {
    padding: 8px 12px;
    color: #eaeaea;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.crop-ratio-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.crop-ratio-item.active {
    color: #fff;
    background: rgba(0, 123, 255, 0.25);
}

/* 缩放控制 */
.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;
    }
    .crop-ratio-controls {
        width: 100%;
        justify-content: center;
        position: relative;
    }
}

/* 深色模式支持 */
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;
}
