/* ===== 图片标记工具样式 ===== */

/* ─── 通用隐藏类 ─── */
.ia-hidden {
    display: none !important;
}

/* ─── 上传区域 ─── */
#ia-upload-section {
    padding: 8px 0 16px;
}

.ia-upload-zone {
    position: relative;
    border: 2px dashed #c7d2fe;
    border-radius: 14px;
    background: linear-gradient(135deg, #fafbff 0%, #f0f4ff 100%);
    min-height: 220px;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 14px;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.06);
}

.ia-upload-zone:hover {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.ia-upload-zone.ia-drag-over {
    border-color: #667eea;
    background: #eef2ff;
    box-shadow: 0 0 0 6px rgba(102, 126, 234, 0.18);
    transform: scale(1.01);
}

.ia-upload-placeholder {
    text-align: center;
    pointer-events: none;
    padding: 40px 24px;
}

.ia-upload-icon {
    font-size: 52px;
    margin-bottom: 12px;
    line-height: 1;
}

.ia-upload-title {
    font-size: 16px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.ia-upload-hint {
    font-size: 13px;
    color: #a0aec0;
}

.ia-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* 上传提示 */
.ia-upload-tips {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.ia-tip {
    font-size: 13px;
    color: #718096;
}

/* ─── 工具栏 ─── */
.ia-toolbar {
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.06);
}

.ia-toolbar-row {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.ia-toolbar-row + .ia-toolbar-row {
    border-top: 1px solid #e8edf5;
    padding-top: 10px;
}

.ia-tool-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.ia-actions-group {
    margin-left: auto;
}

.ia-group-label {
    font-size: 11px;
    font-weight: 700;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    user-select: none;
}

/* ─── 工具按钮 ─── */
.ia-tool-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ia-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 7px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 54px;
    color: #4a5568;
}

.ia-tool-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f0f4ff;
    transform: scale(1.02);
}

.ia-tool-btn.ia-tool-active {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

.ia-btn-icon {
    font-size: 16px;
    line-height: 1;
    font-style: normal;
}

.ia-btn-label {
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
}

/* ─── 操作按钮 ─── */
.ia-action-btns {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ia-action-divider {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
    margin: 0 4px;
    align-self: center;
}

/* ─── 颜色面板 ─── */
.ia-color-panel {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ia-color-swatches {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    max-width: 220px;
}

.ia-color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    flex-shrink: 0;
}

.ia-color-swatch:hover {
    transform: scale(1.18);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.ia-color-swatch.ia-color-active {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #667eea;
}

.ia-color-swatch.ia-color-active::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.ia-custom-color-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ia-custom-color-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #718096;
}

.ia-custom-color-label input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

.ia-current-color-preview {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1.5px solid rgba(0, 0, 0, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    background: var(--ia-selected-color, #f03e3e); /* JS 通过 CSS 自定义属性动态更新 */
}

/* ─── 参数设置 ─── */
.ia-settings-group {
    flex: 1;
}

.ia-settings {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.ia-setting-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #4a5568;
    cursor: pointer;
    user-select: none;
}

.ia-setting-name {
    color: #718096;
    white-space: nowrap;
    font-size: 12px;
}

.ia-setting-item input[type="range"] {
    width: 80px;
    cursor: pointer;
    accent-color: #667eea;
}

.ia-setting-val {
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
    min-width: 32px;
}

.ia-text-input {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 13px;
    color: #2d3748;
    background: #fff;
    outline: none;
    width: 160px;
    transition: border-color 0.2s ease;
}

.ia-text-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.ia-counter-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    background: #667eea;
    color: #fff;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
}

.ia-counter-reset {
    font-size: 12px;
    padding: 4px 8px;
}

/* ─── 信息栏 ─── */
.ia-info-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #fff 0%, #f8faff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ia-info-icon {
    font-size: 15px;
}

.ia-info-name {
    font-weight: 600;
    color: #2d3748;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ia-info-sep {
    color: #cbd5e0;
    user-select: none;
}

.ia-info-dim {
    color: #718096;
}

.ia-info-size {
    color: #a0aec0;
    font-size: 12px;
}

.ia-info-count {
    color: #667eea;
    font-weight: 600;
    margin-left: auto;
}

/* ─── 画布区域 ─── */
.ia-canvas-wrap {
    width: 100%;
    max-height: 72vh;
    overflow: auto;
    user-select: none;
    background-color: #2d3748;
    background-image:
        linear-gradient(45deg, #374151 25%, transparent 25%),
        linear-gradient(-45deg, #374151 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #374151 75%),
        linear-gradient(-45deg, transparent 75%, #374151 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    border-radius: 12px;
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 10px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.ia-canvas-wrap.ia-cursor-crosshair {
    cursor: crosshair;
}

.ia-canvas-wrap.ia-cursor-text {
    cursor: text;
}

.ia-canvas-wrap.ia-cursor-pen {
    cursor: cell;
}

#ia-canvas {
    max-width: 100%;
    display: block;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    touch-action: none;
    user-select: none;
}

#ia-canvas.ia-canvas-loaded {
    animation: iaCanvasIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes iaCanvasIn {
    from { opacity: 0; transform: scale(1.02); }
    to   { opacity: 1; transform: scale(1); }
}

/* ─── 快捷键提示 ─── */
.ia-shortcuts {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 4px 0 6px;
}

.ia-sc {
    font-size: 12px;
    color: #a0aec0;
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    background: #f7fafc;
    border: 1px solid #cbd5e0;
    border-bottom: 2px solid #a0aec0;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    color: #4a5568;
    line-height: 1.5;
    white-space: nowrap;
}

/* ─── Toast ─── */
.ia-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    min-width: 240px;
    max-width: 380px;
    padding: 12px 14px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(8px);
    animation: iaToastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ia-toast-success {
    background: #c6f6d5;
    color: #276749;
    border: 1px solid #9ae6b4;
}

.ia-toast-error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.ia-toast-info {
    background: #ebf8ff;
    color: #2c5282;
    border: 1px solid #bee3f8;
}

.ia-toast-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.ia-toast-msg {
    flex: 1;
    line-height: 1.4;
}

.ia-toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 18px;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.ia-toast-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

@keyframes iaToastIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes iaToastOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(8px); }
}

.ia-toast-fading {
    animation: iaToastOut 0.3s ease forwards;
}

/* ─── 按鈕 hover 微缩放 ─── */
.ia-action-btns .button:hover,
.ia-action-btns .third:hover {
    transform: scale(1.02);
}

#btn-export {
    transition: all 0.2s ease;
}

#btn-export:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* ─── 编辑区域淡入 ─── */
.ia-anim-show {
    animation: iaFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes iaFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── 响应式 ─── */
@media (max-width: 768px) {
    .ia-toolbar-row {
        flex-direction: column;
        gap: 10px;
    }

    .ia-actions-group {
        margin-left: 0;
    }

    .ia-tool-btns {
        gap: 4px;
    }

    .ia-tool-btn {
        min-width: 46px;
        padding: 6px 8px;
    }

    .ia-btn-icon {
        font-size: 14px;
    }

    .ia-btn-label {
        font-size: 10px;
    }

    .ia-color-swatches {
        max-width: 100%;
    }

    .ia-settings {
        gap: 10px;
    }

    .ia-setting-item input[type="range"] {
        width: 60px;
    }

    .ia-text-input {
        width: 120px;
    }

    .ia-shortcuts {
        display: none;
    }

    .ia-upload-tips {
        flex-direction: column;
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .ia-upload-zone {
        min-height: 140px;
    }

    .ia-upload-icon {
        font-size: 36px;
    }

    .ia-upload-title {
        font-size: 14px;
    }

    .ia-canvas-wrap {
        padding: 6px;
        max-height: 60vh;
    }

    .ia-info-bar {
        gap: 5px;
        font-size: 12px;
    }

    .ia-info-count {
        margin-left: 0;
        width: 100%;
    }
}

/* ─── 颜色色块背景色（替代内联 style） ─── */
.ia-color-swatch[data-color="#f03e3e"] { background: #f03e3e; }
.ia-color-swatch[data-color="#fd7e14"] { background: #fd7e14; }
.ia-color-swatch[data-color="#ffd43b"] { background: #ffd43b; }
.ia-color-swatch[data-color="#40c057"] { background: #40c057; }
.ia-color-swatch[data-color="#339af0"] { background: #339af0; }
.ia-color-swatch[data-color="#7950f2"] { background: #7950f2; }
.ia-color-swatch[data-color="#f06595"] { background: #f06595; }
.ia-color-swatch[data-color="#ffffff"] { background: #ffffff; border: 1px solid #ddd; }
.ia-color-swatch[data-color="#212529"] { background: #212529; }
