/* ===== 图片加文字工具样式  prefix: ito- ===== */

/* ─── 通用隐藏 ─── */
.ito-hidden {
    display: none !important;
}

/* ─── 上传区域 ─── */
#ito-upload-section {
    padding: 8px 0 16px;
}

.ito-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);
}

.ito-upload-zone:hover {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.ito-upload-zone.ito-drag-over {
    border-color: #667eea;
    background: #eef2ff;
    box-shadow: 0 0 0 6px rgba(102, 126, 234, 0.18);
    transform: scale(1.01);
}

.ito-upload-placeholder {
    text-align: center;
    pointer-events: none;
    padding: 40px 24px;
}

.ito-upload-icon {
    font-size: 52px;
    margin-bottom: 12px;
    line-height: 1;
}

.ito-upload-title {
    font-size: 16px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.ito-upload-hint {
    font-size: 13px;
    color: #a0aec0;
}

.ito-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.ito-upload-tips {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.ito-tip {
    font-size: 13px;
    color: #718096;
}

/* ─── 工具栏 ─── */
.ito-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);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.ito-toolbar-row {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.ito-toolbar-row-inline {
    align-items: center;
    gap: 14px;
}

.ito-toolbar-row + .ito-toolbar-row {
    border-top: 1px solid #e8edf5;
    padding-top: 10px;
}

.ito-tool-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.ito-actions-group {
    margin-left: auto;
}

.ito-settings-group {
    margin-left: auto;
}

.ito-group-label {
    font-size: 11px;
    font-weight: 700;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    user-select: none;
}

/* ─── 字体行 ─── */
.ito-font-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ito-select {
    height: 34px;
    padding: 0 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    font-size: 13px;
    color: #2d3748;
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
    min-width: 110px;
}

.ito-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.ito-setting-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #4a5568;
    user-select: none;
}

.ito-setting-name {
    color: #718096;
    font-size: 12px;
    white-space: nowrap;
}

.ito-setting-item input[type="range"] {
    width: 80px;
    cursor: pointer;
    accent-color: #667eea;
}

.ito-setting-val {
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
    min-width: 34px;
}

/* ─── 粗体/斜体按钮 ─── */
.ito-style-btns {
    display: flex;
    gap: 5px;
}

.ito-style-btn {
    width: 34px;
    height: 34px;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: #4a5568;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ito-style-btn:hover {
    transform: scale(1.02);
    border-color: #667eea;
    color: #667eea;
    background: #f0f4ff;
}

.ito-style-btn.ito-style-active {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

.ito-italic-btn {
    font-style: italic;
}

.ito-toolbar-row-inline .ito-action-btns {
    margin-left: auto;
}

.ito-toolbar-row-inline .ito-effects-row {
    margin-left: auto;
}

/* ─── 操作按鈕行 ─── */
.ito-action-btns {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ito-action-divider {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
}

.ito-action-btns .button:hover,
.ito-action-btns .third:hover {
    transform: scale(1.02);
}

.ito-popup-actions .button:hover,
.ito-popup-actions .third:hover {
    transform: scale(1.02);
}

.ito-shortcut-hint {
    font-size: 0.8em;
    color: #a0aec0;
    opacity: 0.7;
    user-select: none;
}

/* ─── 颜色面板 ─── */
.ito-color-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ito-color-swatches {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    max-width: 200px;
}

.ito-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;
}

.ito-color-swatch:hover {
    transform: scale(1.18);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.ito-color-swatch.ito-color-active {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #667eea;
}

.ito-color-swatch.ito-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);
}

.ito-custom-color-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ito-custom-color-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #718096;
}

.ito-custom-color-label input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

.ito-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(--ito-selected-color, #ffffff);
}

/* ─── 效果行 ─── */
.ito-effects-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.ito-effect-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 13px;
    color: #4a5568;
    user-select: none;
}

.ito-effect-toggle input[type="checkbox"] {
    accent-color: #667eea;
    cursor: pointer;
}

.ito-toggle-label {
    white-space: nowrap;
}

#ito-bg-options {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-left: 6px;
    border-left: 2px solid #e2e8f0;
}

.ito-bg-color-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #718096;
}

.ito-bg-color-wrap input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

/* ─── 信息栏 ─── */
.ito-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);
}

.ito-info-icon { font-size: 15px; }

.ito-info-name {
    font-weight: 600;
    color: #2d3748;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ito-info-sep { color: #cbd5e0; user-select: none; }

.ito-info-dim { color: #718096; }

.ito-info-hint {
    font-size: 12px;
    color: #a0aec0;
}

/* 选中文字层时工具栏高亮 */
.ito-toolbar.ito-has-selection {
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.08), 0 1px 4px rgba(102, 126, 234, 0.06);
}

/* 选中强调徽章 */
.ito-sel-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 9px;
    background: rgba(102, 126, 234, 0.12);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    animation: itoFadeIn 0.2s ease;
}

.ito-text-count {
    color: #667eea;
    font-weight: 600;
    margin-left: auto;
}

/* ─── 画布区域 ─── */
.ito-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;
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

#ito-canvas {
    max-width: 100%;
    display: block;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    cursor: text;
    touch-action: none;
    user-select: none;
}

#ito-canvas.ito-canvas-loaded {
    animation: itoCanvasIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#ito-canvas.ito-cursor-move {
    cursor: move;
}

@keyframes itoCanvasIn {
    from { opacity: 0; transform: scale(1.02); }
    to   { opacity: 1; transform: scale(1); }
}

/* ─── 浮动文字输入框 ─── */
#ito-text-input-wrap {
    position: fixed;
    z-index: 9990;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 14px;
    width: 270px;
    border: 1px solid #e2e8f0;
    left: var(--ito-popup-left, 16px);
    top: var(--ito-popup-top, 16px);
    animation: itoPopupIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes itoPopupIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ito-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.ito-popup-title {
    font-size: 13px;
    font-weight: 700;
    color: #4a5568;
}

.ito-popup-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #a0aec0;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

.ito-popup-close:hover {
    color: #f03e3e;
}

#ito-text-input {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #2d3748;
    background: #fff;
    outline: none;
    resize: vertical;
    min-height: 64px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

#ito-text-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.ito-popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.ito-popup-actions .button,
.ito-popup-actions .third {
    flex: 1;
}

/* ─── 快捷键 ─── */
.ito-shortcuts {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 4px 0 6px;
}

.ito-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 ─── */
.ito-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;
    animation: itoToastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ito-toast-success { background: #c6f6d5; color: #276749; border: 1px solid #9ae6b4; }
.ito-toast-error   { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; }
.ito-toast-info    { background: #ebf8ff; color: #2c5282; border: 1px solid #bee3f8; }
.ito-toast-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }

.ito-toast-msg { flex: 1; line-height: 1.4; }

.ito-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;
}

.ito-toast-close:hover { opacity: 1; transform: scale(1.1); }

@keyframes itoToastIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes itoToastOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(8px); }
}

.ito-toast-fading {
    animation: itoToastOut 0.3s ease forwards;
}

/* ─── 编辑区动效 ─── */
.ito-anim-show {
    animation: itoFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes itoFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── 颜色色块背景（替代内联 style） ─── */
.ito-color-swatch[data-color="#ffffff"] { background: #ffffff; border: 1px solid #ddd; }
.ito-color-swatch[data-color="#000000"] { background: #000000; }
.ito-color-swatch[data-color="#f03e3e"] { background: #f03e3e; }
.ito-color-swatch[data-color="#fd7e14"] { background: #fd7e14; }
.ito-color-swatch[data-color="#ffd43b"] { background: #ffd43b; }
.ito-color-swatch[data-color="#40c057"] { background: #40c057; }
.ito-color-swatch[data-color="#339af0"] { background: #339af0; }
.ito-color-swatch[data-color="#7950f2"] { background: #7950f2; }

/* ─── 响应式 ─── */
@media (max-width: 768px) {
    .ito-toolbar-row { flex-direction: column; gap: 10px; }
    .ito-actions-group { margin-left: 0; }
    .ito-font-row { gap: 7px; }
    .ito-setting-item input[type="range"] { width: 60px; }
    .ito-shortcuts { display: none; }
    .ito-upload-tips { flex-direction: column; gap: 6px; }
    #ito-text-input-wrap { width: calc(100vw - 32px); left: 16px !important; }
}

@media (max-width: 640px) {
    .ito-upload-zone { min-height: 140px; }
    .ito-upload-icon { font-size: 36px; }
    .ito-upload-title { font-size: 14px; }
    .ito-canvas-wrap { padding: 6px; max-height: 60vh; }
    .ito-info-bar { gap: 5px; font-size: 12px; }
    .ito-text-count { margin-left: 0; width: 100%; }
}
