/* =====================================================
   图片局部马赛克工具 - image_local_mosaic.css
   ===================================================== */

/* 容器 */
.ilm-container {
    padding: 0 !important;
}

/* ===== Tab 导航 ===== */
.ilm-tab-nav {
    display: flex;
    border-bottom: 2px solid #e8eaf6;
    background: #f8f9ff;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ilm-tab-btn {
    padding: 13px 26px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.2s;
    font-weight: 500;
}

.ilm-tab-btn:hover {
    color: #1976D2;
    background: rgba(25, 118, 210, 0.06);
}

.ilm-tab-btn.active {
    color: #1976D2;
    border-bottom-color: #1976D2;
    font-weight: 600;
}

/* ===== Tab 内容 ===== */
.ilm-tab-content {
    padding: 20px;
}

.ilm-hidden {
    display: none !important;
}

/* ===== 上传区域 ===== */
.ilm-upload-area {
    border: 2px dashed #90CAF9;
    border-radius: 14px;
    padding: 64px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fbff;
    user-select: none;
}

.ilm-upload-area:hover,
.ilm-upload-area.drag-over {
    border-color: #1976D2;
    background: #e3f2fd;
    transform: scale(1.005);
    box-shadow: 0 6px 20px rgba(25, 118, 210, 0.12);
}

.ilm-upload-icon {
    font-size: 60px;
    margin-bottom: 14px;
    line-height: 1;
}

.ilm-upload-text {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.ilm-upload-hint {
    font-size: 13px;
    color: #8a9bb0;
    margin-bottom: 22px;
}

#fileInput {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== 工作区 ===== */
.ilm-workspace {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== 工具栏 ===== */
.ilm-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
    background: #f5f7fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.ilm-toolbar-row {
    display: flex;
    align-items: center;
    gap: 10px 14px;
    flex-wrap: wrap;
    width: 100%;
}

.ilm-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* 操作区分隔线 */
.ilm-toolbar-sep {
    width: 1px;
    height: 26px;
    background: #d8dce4;
    flex-shrink: 0;
    margin: 0 2px;
}

.ilm-toolbar-label {
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    font-weight: 500;
}

.ilm-slider {
    width: 130px;
    height: 4px;
    cursor: pointer;
    accent-color: #1976D2;
    vertical-align: middle;
}

.ilm-size-display {
    font-size: 13px;
    font-weight: 700;
    color: #1976D2;
    min-width: 40px;
    text-align: left;
    background: #e3f2fd;
    padding: 2px 8px;
    border-radius: 12px;
}

/* 强度文字标签 */
.ilm-strength-label {
    font-size: 12px;
    color: #6b7a8d;
    background: #eef0f4;
    border: 1px solid #d0d5de;
    padding: 2px 10px;
    border-radius: 10px;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
}

.ilm-hint-badge {
    font-size: 13px;
    color: #1565C0;
    background: #e3f2fd;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #90CAF9;
    white-space: nowrap;
}

/* ===== 选区状态栏 ===== */
.ilm-selection-bar {
    text-align: center;
    padding: 4px 0;
}

.ilm-sel-info {
    font-size: 13px;
    color: #888;
    padding: 5px 16px;
    background: #f5f5f5;
    border-radius: 20px;
    transition: all 0.3s;
}

.ilm-sel-info.active {
    color: #1565C0;
    background: #e3f2fd;
    font-weight: 500;
}

/* ===== Canvas 画布区域 ===== */
.ilm-canvas-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border: 2px solid #cdd5e0;
    border-radius: 10px;
    overflow: hidden;
    /* 棋盘格背景，直观显示透明区域 */
    background-color: #f0f0f0;
    background-image:
            linear-gradient(45deg, #c8c8c8 25%, transparent 25%),
            linear-gradient(-45deg, #c8c8c8 25%, transparent 25%),
            linear-gradient(45deg, transparent 75%, #c8c8c8 75%),
            linear-gradient(-45deg, transparent 75%, #c8c8c8 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    line-height: 0;
    align-self: center;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    transition: box-shadow 0.2s;
}

.ilm-canvas-wrap:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

#imageCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

#overlayCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 2;
}

/* ===== AI 区域 ===== */
.ilm-ai-intro {
    padding: 14px 18px;
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    border-radius: 10px;
    border-left: 4px solid #43A047;
    margin-bottom: 18px;
    font-size: 14px;
    color: #2e4a2e;
    line-height: 1.6;
}

.ilm-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 4px;
}

.ilm-form-row {
    display: flex;
    flex-direction: column;
    gap: 7px;
    position: relative;
}

.ilm-form-row label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.ilm-required {
    color: #e53935;
}

.ilm-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    color: #333;
    line-height: 1.6;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 100px;
}

.ilm-textarea:focus {
    outline: none;
    border-color: #1976D2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.ilm-char-count {
    font-size: 12px;
    color: #aaa;
    align-self: flex-end;
}

.ilm-form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== 快捷建议按鈕 ===== */
.ilm-quick-btn {
    padding: 5px 14px;
    border: 1px solid #90CAF9;
    background: #e3f2fd;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    color: #1565C0;
    transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.ilm-quick-btn:hover {
    background: #1976D2;
    color: #fff;
    border-color: #1976D2;
    transform: translateY(-2px);
}

/* ===== 快捷选区按鈕容器 ===== */
.ilm-quick-tips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 14px 0;
    border-top: 1px solid #eee;
    margin-bottom: 16px;
}

.ilm-quick-label {
    font-size: 13px;
    color: #777;
    font-weight: 500;
}

/* ===== 图片信息栏 ===== */
.ilm-image-info {
    font-size: 12px;
    color: #5c7080;
    background: linear-gradient(135deg, #f0f4f8 0%, #eaf0f6 100%);
    border: 1px solid #d0dce8;
    border-radius: 8px;
    padding: 7px 16px;
    text-align: center;
    letter-spacing: 0.4px;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 工具栏提示分组 ===== */
.ilm-toolbar-hints {
    display: flex;
    align-items: center;
    flex: 1;
    flex-wrap: wrap;
    gap: 8px;
}

/* ===== 键盘快捷键提示 ===== */
.ilm-shortcut-hint {
    font-size: 11px;
    color: #aab5c4;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

/* 应用按鈕禁用状态 */
#applyBtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    animation: none !important;
}

/* AI按鈕处理中状态（保留点击能力以便显示 Toast） */
#aiSuggestBtn.ilm-btn-busy {
    opacity: 0.7;
    cursor: wait;
}

/* ===== 应用按钮高亮动画（有选区时） ===== */
#applyBtn.ilm-btn-highlight {
    animation: ilmBtnPulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes ilmBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(25, 118, 210, 0.45); }
    50%       { box-shadow: 0 0 0 7px rgba(25, 118, 210, 0); }
}

/* ===== 加载动画 ===== */
.ilm-ai-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    background: #f5f5f5;
    border-radius: 10px;
    color: #555;
    font-size: 14px;
    margin-top: 10px;
}

.ilm-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e0e0e0;
    border-top-color: #1976D2;
    border-radius: 50%;
    animation: ilmSpin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes ilmSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== AI 结果卡片 ===== */
.ilm-ai-result {
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    margin-top: 10px;
}

.ilm-ai-result-title {
    padding: 13px 18px;
    background: linear-gradient(135deg, #1565C0 0%, #1976D2 100%);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
}

.ilm-ai-result-content {
    padding: 16px;
}

.ilm-ai-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ilm-ai-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: box-shadow 0.2s;
}

.ilm-ai-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ilm-ai-icon {
    font-size: 24px;
    flex-shrink: 0;
    line-height: 1;
}

.ilm-ai-info {
    flex: 1;
    min-width: 0;
}

.ilm-ai-key {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ilm-ai-val {
    font-size: 14px;
    color: #333;
    line-height: 1.6;
    word-break: break-word;
}

/* ===== AI原始回复折叠 ===== */
.ilm-ai-raw-wrap {
    padding: 10px 16px;
    border-top: 1px solid #e0e0e0;
}

.ilm-raw-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    font-size: 12px;
    padding: 4px 0;
    transition: color 0.2s;
}

.ilm-raw-toggle-btn:hover {
    color: #1976D2;
}

.ilm-ai-raw {
    margin-top: 10px;
    padding: 12px;
    background: #2d2d2d;
    color: #e0e0e0;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* ===== Toast 通知 ===== */
.ilm-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 11px 28px;
    border-radius: 24px;
    font-size: 14px;
    color: #fff;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    white-space: nowrap;
    max-width: 88vw;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.ilm-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    cursor: pointer;
}

.ilm-toast.success {
    background: #43A047;
}

.ilm-toast.error {
    background: #E53935;
}

.ilm-toast.warning {
    background: #FB8C00;
}

.ilm-toast.info {
    background: #1976D2;
}

/* ===== 响应式适配 ===== */
@media (max-width: 768px) {
    .ilm-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .ilm-ai-grid {
        grid-template-columns: 1fr;
    }

    .ilm-tab-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .ilm-upload-area {
        padding: 44px 16px;
    }

    .ilm-upload-icon {
        font-size: 48px;
    }

    .ilm-upload-text {
        font-size: 16px;
    }

    .ilm-shortcut-hint {
        display: none;
    }

    .ilm-toolbar-sep {
        display: none;
    }
}

@media (max-width: 640px) {
    .ilm-tab-content {
        padding: 12px 10px;
    }

    .ilm-toolbar {
        padding: 10px 12px;
        gap: 8px;
    }

    .ilm-toolbar-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .ilm-toolbar-group .button,
    .ilm-toolbar-group .secondary,
    .ilm-toolbar-group .third {
        flex: 1;
        text-align: center;
        min-width: 0;
        font-size: 12px;
        padding: 7px 8px;
    }

    .ilm-upload-area {
        padding: 36px 14px;
    }

    .ilm-upload-icon {
        font-size: 40px;
    }

    .ilm-upload-text {
        font-size: 15px;
    }

    .ilm-upload-hint {
        font-size: 12px;
    }

    .ilm-image-info {
        font-size: 11px;
        padding: 6px 10px;
    }

    .ilm-toast {
        padding: 10px 16px;
        font-size: 13px;
        bottom: 20px;
    }

    .ilm-quick-tips {
        gap: 6px;
    }

    .ilm-quick-btn {
        font-size: 11px;
        padding: 4px 10px;
    }
}

@media (max-width: 480px) {
    .ilm-tab-btn {
        padding: 9px 12px;
        font-size: 12px;
    }
}
