/* image-cropper.html 私有样式 */
.container {
    max-width: 1400px;
}

/* ---- 上传区 ---- */
.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area.dragover {
    border-color: #667eea;
    background: #eef2ff;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-text {
    color: #6b7280;
    font-size: 14px;
}

.upload-text strong {
    color: #667eea;
}

/* ---- 裁剪画布区 ---- */
.cropper-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    background: #1a1a1a;
    border-radius: 6px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.cropper-wrap canvas {
    display: block;
    max-width: 100%;
}

/* ---- 裁剪框遮罩 ---- */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.crop-mask {
    position: absolute;
    background: rgba(0, 0, 0, 0.55);
}

.crop-box {
    position: absolute;
    border: 2px solid #fff;
    cursor: move;
    pointer-events: all;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
}

.crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid #667eea;
    border-radius: 2px;
    pointer-events: all;
    z-index: 2;
}

.crop-handle.tl { top: -5px; left: -5px; cursor: nw-resize; }
.crop-handle.tr { top: -5px; right: -5px; cursor: ne-resize; }
.crop-handle.bl { bottom: -5px; left: -5px; cursor: sw-resize; }
.crop-handle.br { bottom: -5px; right: -5px; cursor: se-resize; }
.crop-handle.tm { top: -5px; left: 50%; margin-left: -5px; cursor: n-resize; }
.crop-handle.bm { bottom: -5px; left: 50%; margin-left: -5px; cursor: s-resize; }
.crop-handle.ml { top: 50%; margin-top: -5px; left: -5px; cursor: w-resize; }
.crop-handle.mr { top: 50%; margin-top: -5px; right: -5px; cursor: e-resize; }

/* ---- 裁剪信息 ---- */
.crop-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 13px;
    color: #6b7280;
}

.crop-info .size {
    font-weight: 600;
    color: #374151;
    font-variant-numeric: tabular-nums;
}

/* ---- 比例选择 ---- */
.ratio-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ratio-bar .btn {
    padding: 5px 12px;
    font-size: 12px;
}

.ratio-bar .btn.active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

/* ---- 缩略图列表 ---- */
.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    padding: 4px 0;
}

.thumb-item {
    position: relative;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 1;
}

.thumb-item:hover {
    border-color: #667eea;
}

.thumb-item.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 10px;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumb-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.9);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.thumb-item:hover .thumb-del {
    opacity: 1;
}

/* ---- 弹窗预览 ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    border-radius: 10px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
    color: #374151;
    gap: 12px;
}

.modal-header span:first-child {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
}

.modal-nav .btn {
    padding: 4px 10px;
    font-size: 12px;
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.modal-close:hover {
    background: #e5e7eb;
}

.modal-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
    background: #f9fafb;
}

.modal-body img {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    border-radius: 4px;
}

.modal-footer {
    display: flex;
    justify-content: center;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
}

@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .ratio-bar {
        gap: 4px;
    }
    .ratio-bar .btn {
        padding: 4px 8px;
        font-size: 11px;
    }
}
