/* ========== 图片编辑器（米色报纸风） ========== */

body.image-editor-active {
    background: linear-gradient(135deg, #F5F0E8 0%, #EDE4D3 50%, #E8DCC8 100%);
}

#image-editor {
    background: linear-gradient(135deg, #F5F0E8 0%, #EDE4D3 50%, #E8DCC8 100%);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #2C3E50;
}

#image-editor .footer {
    display: none;
}

#image-editor .app-header h1 {
    color: #3E2723;
}

#image-editor .back-button {
    color: #3E2723;
}

/* ---------- 内容容器 ---------- */
.image-editor-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 20px;
}

.ie-tool-description {
    text-align: center;
    padding: 0 0 20px;
}

.ie-tool-description p {
    color: #6D4C41;
    font-size: 14px;
    margin: 0;
}

/* ---------- 上传框（空态） ---------- */
.ie-drop-zone {
    border: 2px dashed #8B7355;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    margin-bottom: 20px;
    background: rgba(139, 115, 85, 0.06);
}

.ie-drop-zone:hover {
    border-color: #D4A017;
    background-color: rgba(212, 160, 23, 0.08);
}

.ie-drop-zone.ie-drag-over {
    border-color: #D4A017;
    box-shadow: 0 0 20px rgba(212, 160, 23, 0.25);
}

.ie-drop-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.ie-drop-text {
    font-size: 16px;
    margin: 0 0 8px;
    color: #5D4037;
}

.ie-drop-sub {
    font-size: 13px;
    margin: 0;
    color: #8D6E63;
}

/* ---------- 编辑区（有态） ---------- */
.ie-editor-area {
    margin-bottom: 20px;
}

/* 裁剪容器：报纸风棋盘格 */
#ie-crop-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 2px dashed #8B7355;
    border-radius: 8px;
    background-color: #E8DCC8;
    background-image:
        linear-gradient(45deg, #D7C8A8 25%, transparent 25%),
        linear-gradient(-45deg, #D7C8A8 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #D7C8A8 75%),
        linear-gradient(-45deg, transparent 75%, #D7C8A8 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

#ie-crop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* calculator 同款裁剪框（白边 + 暗色遮罩） */
#ie-crop-box {
    position: absolute;
    border: 2px solid #ffffff;
    background: transparent;
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(62, 39, 35, 0.55);
    display: none;
}

/* 四角白色圆点手柄（最上层，斜向缩放） */
.crop-corner-nw,
.crop-corner-ne,
.crop-corner-sw,
.crop-corner-se {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #ffffff;
    border-radius: 50%;
    z-index: 3;
}

.crop-corner-nw { top: -5px; left: -5px; cursor: nw-resize; }
.crop-corner-ne { top: -5px; right: -5px; cursor: ne-resize; }
.crop-corner-sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.crop-corner-se { bottom: -5px; right: -5px; cursor: se-resize; }

/* 四条边整条热区（透明，除角点外全长可拖，单边平移裁剪） */
.crop-edge-n,
.crop-edge-s,
.crop-edge-w,
.crop-edge-e {
    position: absolute;
    background-color: transparent;
    z-index: 2;
}

/* 上下边：横向撑满（两端各让 12px 给角点），纵向 12px 热区 */
.crop-edge-n,
.crop-edge-s {
    left: 12px;
    right: 12px;
    height: 12px;
}

.crop-edge-n { top: -6px; cursor: ns-resize; }
.crop-edge-s { bottom: -6px; cursor: ns-resize; }

/* 左右边：纵向撑满（两端各让 12px 给角点），横向 12px 热区 */
.crop-edge-w,
.crop-edge-e {
    top: 12px;
    bottom: 12px;
    width: 12px;
}

.crop-edge-w { left: -6px; cursor: ew-resize; }
.crop-edge-e { right: -6px; cursor: ew-resize; }

/* ---------- 文件信息 ---------- */
.ie-file-info {
    text-align: center;
    font-size: 13px;
    color: #6D4C41;
    margin-top: 12px;
}

.ie-file-info span {
    margin: 0 8px;
}

/* ---------- 裁剪后信息（输出尺寸 + 估算占用大小） ---------- */
.ie-crop-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #5D4037;
    background: rgba(212, 160, 23, 0.10);
    border: 1px solid rgba(212, 160, 23, 0.40);
    border-radius: 8px;
}

.ie-crop-info span {
    margin: 0 10px;
}

.ie-crop-info .ie-crop-label {
    color: #8D6E63;
}

.ie-crop-info .ie-crop-dims {
    color: #3E2723;
    font-variant-numeric: tabular-nums;
}

.ie-crop-info .ie-crop-size {
    color: #B8860B;
    font-variant-numeric: tabular-nums;
}

/* ---------- 工具栏按钮（暖色调） ---------- */
.ie-toolbar-wrapper {
    position: relative;
    margin-top: 16px;
}

.ie-toolbar-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

/* 模块二：绝对定位覆盖模块一 */
.ie-toolbar-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(135deg, #F5F0E8 0%, #EDE4D3 50%, #E8DCC8 100%);
    border-radius: 8px;
    padding: 4px 0;
}

.ie-btn {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.15s, transform 0.1s;
}

.ie-btn:active {
    transform: scale(0.97);
}

.ie-btn-secondary {
    background-color: #A1887F;
    color: #FFF8E1;
}

.ie-btn-secondary:hover {
    background-color: #8D6E63;
}

/* 图标按钮（旋转 ↺ ↻ SVG） */
.ie-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
}

.ie-btn-icon svg {
    display: block;
}

/* 模块二预留空白按键 */
.ie-btn-blank {
    min-width: 96px;
}

.ie-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ie-btn-primary {
    background-color: #D4A017;
    color: #3E2723;
}

.ie-btn-primary:hover {
    background-color: #B8860B;
}

/* ---------- 详情查看模态 ---------- */
.ie-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ie-modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(62, 39, 35, 0.88);
}

.ie-modal-content {
    position: relative;
    max-width: 92vw;
    max-height: 92vh;
    z-index: 1;
}

#ie-modal-canvas {
    display: block;
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 6px;
}

.ie-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background-color: #8D6E63;
    color: #FFF8E1;
    font-size: 16px;
    cursor: pointer;
}

.ie-modal-close:hover {
    background-color: #6D4C41;
}

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
    .ie-drop-zone {
        padding: 40px 20px;
    }

    .ie-toolbar-buttons {
        flex-direction: column;
    }

    .ie-btn {
        width: 100%;
    }
}
