/* ================================================================
   image_format_helper.css — 图片格式转换工具
   ================================================================ */

/* -------- 初始隐藏辅助类 -------- */
.ifh-hidden {
    display: none !important;
}

/* -------- 结果图片淡入动画 -------- */
.img-fade-in {
    animation: imgFadeIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 原始图片加载淡入 */
.orig-img-loaded {
    animation: imgFadeIn 0.42s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes imgFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* 结果卡片转换成功闪光 */
.result-card-success {
    animation: cardSuccessFlash 0.85s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes cardSuccessFlash {
    0%   { box-shadow: 0 2px 12px rgba(0,0,0,0.05); border-color: #e8edf5; }
    40%  { box-shadow: 0 4px 28px rgba(34,197,94,0.35); border-color: #86efac; }
    100% { box-shadow: 0 2px 12px rgba(0,0,0,0.05); border-color: #e8edf5; }
}

/* -------- Toast 提示 -------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
    cursor: pointer;
    max-width: 360px;
    word-break: break-word;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(40px);
}

.toast.toast-success { background: linear-gradient(135deg, #22c55e, #16a34a); }
.toast.toast-error   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.toast-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toast.toast-info    { background: linear-gradient(135deg, #3b82f6, #2563eb); }

/* -------- 上传区域 -------- */
.upload-zone {
    border: 2.5px dashed #bfcfe8;
    border-radius: 18px;
    padding: 64px 24px;
    text-align: center;
    cursor: pointer;
    background: linear-gradient(160deg, #f8faff 0%, #f0f4ff 100%);
    transition: border-color 0.22s ease, background 0.22s ease, transform 0.16s ease, box-shadow 0.22s ease;
    margin-bottom: 28px;
    position: relative;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.06);
}

.upload-zone:hover {
    border-color: #3b82f6;
    background: linear-gradient(160deg, #eff6ff 0%, #dbeafe 100%);
    transform: scale(1.005);
    box-shadow: 0 6px 24px rgba(59, 130, 246, 0.14);
}

.upload-zone.drag-over {
    border-color: #2563eb;
    background: linear-gradient(160deg, #dbeafe 0%, #bfdbfe 100%);
    transform: scale(1.01);
    box-shadow: 0 8px 28px rgba(59, 130, 246, 0.22);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-icon-wrap {
    font-size: 56px;
    margin-bottom: 14px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.2));
    animation: uploadIconFloat 3s ease-in-out infinite;
}

@keyframes uploadIconFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-6px); }
}

.upload-zone.drag-over .upload-icon-wrap {
    animation: none;
    transform: scale(1.15);
    transition: transform 0.2s ease;
}

.upload-primary-text {
    font-size: 17px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.upload-secondary-text {
    font-size: 13px;
    color: #94a3b8;
}

.upload-shortcut-row {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.upload-shortcut-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 11px;
    color: #3b82f6;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* -------- 工具主体（左右布局） -------- */
.tool-body {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    animation: ifhFadeIn 0.28s ease;
}

@keyframes ifhFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* -------- 左侧控制面板 -------- */
.ctrl-panel {
    flex: 0 0 290px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
}

.ctrl-section {
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 14px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.ctrl-section:hover {
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.07);
    border-color: #d4dff0;
}

.ctrl-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1.5px solid #f1f5f9;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* -------- 原始图片信息 -------- */
.orig-info-grid {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.orig-info-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
}

.orig-info-key {
    color: #94a3b8;
    font-weight: 600;
    min-width: 56px;
    flex-shrink: 0;
    padding-top: 1px;
}

.orig-info-val {
    color: #334155;
    font-weight: 500;
    word-break: break-all;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* -------- 目标格式网格 -------- */
.format-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.format-item {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 6px 10px;
    cursor: pointer;
    background: #fafbfd;
    text-align: center;
    transition: border-color 0.18s, background 0.18s, transform 0.15s, box-shadow 0.18s;
    user-select: none;
}

.format-item:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    transform: scale(1.02);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.13);
}

.format-item.active {
    border-color: #2563eb;
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
    box-shadow: 0 2px 14px rgba(37, 99, 235, 0.22);
}

/* 选中状态勾选标 */
.format-item.active::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 7px;
    font-size: 10px;
    font-weight: 900;
    color: #2563eb;
    line-height: 1;
}

.format-icon {
    font-size: 22px;
    margin-bottom: 4px;
    line-height: 1;
}

.format-name {
    font-size: 13px;
    font-weight: 800;
    color: #334155;
    margin-bottom: 2px;
    letter-spacing: 0.03em;
}

.format-item.active .format-name {
    color: #1d4ed8;
}

.format-desc {
    font-size: 10px;
    color: #94a3b8;
    line-height: 1.4;
}

.format-item.active .format-desc {
    color: #60a5fa;
}

/* -------- 质量滑块 -------- */
.quality-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.quality-label-side {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    flex-shrink: 0;
}

.quality-range {
    flex: 1;
    cursor: pointer;
    height: 6px;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #ef4444 0%, #f59e0b 45%, #22c55e 100%);
    transition: opacity 0.2s;
}

.quality-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2563eb;
    border: 2.5px solid #ffffff;
    box-shadow: 0 1px 8px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.quality-range::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.55);
}

.quality-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2563eb;
    border: 2.5px solid #ffffff;
    box-shadow: 0 1px 8px rgba(37, 99, 235, 0.4);
    cursor: pointer;
}

.quality-value {
    font-size: 14px;
    font-weight: 700;
    color: #2563eb;
    min-width: 38px;
    text-align: right;
    flex-shrink: 0;
}

.quality-hint {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
    border-top: 1px solid #f1f5f9;
    padding-top: 8px;
}

/* -------- 尺寸调整 -------- */
.resize-mode-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    font-weight: 500;
    padding: 4px 0;
    transition: color 0.15s;
}

.radio-item:hover {
    color: #2563eb;
}

.radio-item input[type="radio"] {
    accent-color: #3b82f6;
    cursor: pointer;
}

.resize-options {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
    animation: ifhFadeIn 0.2s ease;
}

.scale-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scale-unit {
    font-size: 14px;
    color: #64748b;
    font-weight: 600;
    flex-shrink: 0;
}

.scale-preview-text {
    font-size: 11px;
    color: #3b82f6;
    margin-top: 6px;
    font-weight: 600;
}

.custom-size-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.size-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 70px;
}

.size-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.size-num-input {
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 14px;
    color: #334155;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    outline: none;
}

.size-num-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
    transform: scale(1.01);
}

.size-sep {
    font-size: 18px;
    color: #94a3b8;
    padding-bottom: 6px;
    flex-shrink: 0;
    font-weight: 300;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 12px;
    color: #475569;
    font-weight: 500;
}

.checkbox-item input[type="checkbox"] {
    accent-color: #3b82f6;
    cursor: pointer;
}

/* -------- 操作按钮区 -------- */
.ctrl-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.convert-btn,
.reset-btn {
    width: 100%;
    padding: 13px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    border-radius: 11px !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    letter-spacing: 0.02em !important;
}

.convert-btn:not(:disabled):hover,
.reset-btn:hover {
    transform: scale(1.02) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.13) !important;
}

.convert-btn.btn-processing {
    opacity: 0.7;
    cursor: not-allowed !important;
}

/* -------- 右侧预览区 -------- */
.preview-area {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    min-width: 0;
}

.preview-card {
    flex: 1;
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s;
}

.preview-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.09);
}

.preview-card-title {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 12px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.preview-img-box {
    width: 100%;
    min-height: 220px;
    max-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 0 0 / 16px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.preview-img-box img {
    max-width: 100%;
    max-height: 380px;
    object-fit: contain;
    display: block;
}

/* -------- 结果占位符 -------- */
.result-placeholder {
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.placeholder-icon {
    font-size: 40px;
    opacity: 0.5;
}

.placeholder-text {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

.placeholder-hint {
    font-size: 11px;
    color: #b0bec5;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 8px;
}

/* -------- 处理中覆盖层 -------- */
.processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 10;
    border-radius: 10px;
    backdrop-filter: blur(2px);
}

.spinner {
    width: 38px;
    height: 38px;
    border: 3.5px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.72s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing-text {
    font-size: 13px;
    font-weight: 600;
    color: #3b82f6;
    letter-spacing: 0.04em;
}

/* -------- 预览卡片信息 -------- */
.preview-card-info {
    margin-top: 12px;
    font-size: 12px;
    color: #64748b;
    text-align: center;
    line-height: 2;
    width: 100%;
    min-height: 28px;
}

.info-badge {
    display: inline-block;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 10px;
    font-weight: 700;
    border-radius: 5px;
    padding: 2px 8px;
    margin: 2px;
    vertical-align: middle;
    letter-spacing: 0.02em;
    transition: transform 0.15s, box-shadow 0.15s;
}

.info-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.info-badge-green {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #16a34a;
}

.info-badge-blue {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

.info-badge-orange {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #c2410c;
}

/* -------- 预览箭头 -------- */
.preview-arrow {
    font-size: 26px;
    color: #3b82f6;
    flex-shrink: 0;
    padding-top: 120px;
    font-weight: bold;
    opacity: 0.7;
    transition: opacity 0.2s;
    user-select: none;
}

/* -------- 下载区 -------- */
.download-area {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 22px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #f0f9ff 0%, #eff6ff 50%, #f8fafc 100%);
    border: 1px solid #bae6fd;
    border-radius: 16px;
    padding: 18px 22px;
    animation: ifhFadeIn 0.28s ease;
    box-shadow: 0 2px 16px rgba(59, 130, 246, 0.08);
}

.download-actions {
    flex-shrink: 0;
}

.download-btn {
    padding: 12px 28px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    letter-spacing: 0.02em !important;
}

.download-btn:hover {
    transform: scale(1.02) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14) !important;
}

.size-compare {
    font-size: 13px;
    color: #475569;
    line-height: 1.7;
    flex: 1;
}

.size-compare strong {
    color: #1e3a5f;
    font-weight: 700;
}

.savings-tag {
    margin-left: 8px;
    font-weight: 700;
}

.savings-decrease {
    color: #16a34a;
}

.savings-increase {
    color: #c2410c;
}

/* -------- 响应式布局 -------- */
@media (max-width: 800px) {
    .tool-body {
        flex-direction: column;
    }

    .ctrl-panel {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .preview-area {
        flex-direction: column;
        width: 100%;
    }

    .preview-arrow {
        padding-top: 0;
        text-align: center;
        width: 100%;
        font-size: 20px;
    }

    .format-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .download-area {
        flex-direction: column;
        align-items: flex-start;
    }

    .upload-shortcut-row {
        display: none;
    }
}

/* -------- 快捷键提示 -------- */
.shortcut-hint-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 6px;
}

.shortcut-hint {
    font-size: 11px;
    color: #94a3b8;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 8px;
    letter-spacing: 0.02em;
    user-select: none;
}
