/* =========================================================
   纯前端图片格式转换 — 样式表
   ========================================================= */

.bic-wrap {
    --bic-bg: #ffffff;
    --bic-surface: #f8fafc;
    --bic-surface-2: #f1f5f9;
    --bic-border: #e6eaf0;
    --bic-border-strong: #cfd8e3;
    --bic-text: #0f172a;
    --bic-muted: #64748b;
    --bic-accent: #2563eb;
    --bic-green: #16a34a;
    --bic-green-hover: #15803d;
    --bic-green-soft: #f0fdf4;
    --bic-green-border: #bbf7d0;
    --bic-danger: #dc2626;
    --bic-radius: 18px;
    --bic-shadow: 0 1px 2px rgba(15, 23, 42, .04),
                  0 20px 44px -22px rgba(15, 23, 42, .3);

    width: 100%;
    margin: 2em auto;
    font-family: inherit;
    color: var(--bic-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.bic-wrap *,
.bic-wrap *::before,
.bic-wrap *::after { box-sizing: border-box; }

/* 必须强制隐藏，防止被 display:flex 等规则覆盖 */
.bic-wrap [hidden] { display: none !important; }

.bic-card {
    background: var(--bic-bg);
    border: 1px solid var(--bic-border);
    border-radius: var(--bic-radius);
    box-shadow: var(--bic-shadow);
    padding: 28px;
}

/* ---------- 头部 ---------- */

.bic-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.bic-head-text { min-width: 0; }

.bic-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
}

.bic-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .18);
}

.bic-title {
    margin: 10px 0 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.01em;
}

/* ---------- 清除按钮 ---------- */

.bic-ghost-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border: 1px solid var(--bic-border-strong);
    border-radius: 9px;
    background: transparent;
    color: var(--bic-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}

.bic-ghost-btn svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}

.bic-ghost-btn:hover {
    border-color: var(--bic-danger);
    color: var(--bic-danger);
    background: rgba(220, 38, 38, .06);
}

.bic-ghost-btn:focus-visible {
    outline: 2px solid var(--bic-accent);
    outline-offset: 2px;
}

/* ---------- 拖拽区 ---------- */

.bic-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 44px 24px;
    border: 2px dashed var(--bic-border-strong);
    border-radius: 16px;
    background: var(--bic-surface);
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s, transform .12s;
}

.bic-drop:hover,
.bic-drop:focus-visible {
    border-color: var(--bic-accent);
    background: #eff6ff;
    outline: none;
}

.bic-drop.is-drag {
    border-color: var(--bic-accent);
    background: #dbeafe;
    transform: scale(1.01);
}

.bic-drop-icon {
    width: 56px;
    height: 56px;
    padding: 14px;
    margin-bottom: 8px;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #7c3aed);
    box-shadow: 0 10px 22px -10px rgba(59, 130, 246, .9);
}

.bic-drop-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.bic-drop-title span { color: var(--bic-accent); }

.bic-drop-hint {
    margin: 0;
    font-size: 12.5px;
    color: var(--bic-muted);
}

/* ---------- 预览区（棋盘格背景，便于观察透明） ---------- */

.bic-preview-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    padding: 12px;
    border: 1px solid var(--bic-border);
    border-radius: 14px;
    background-color: #fff;
    background-image:
        linear-gradient(45deg, var(--bic-surface-2) 25%, transparent 25%),
        linear-gradient(-45deg, var(--bic-surface-2) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--bic-surface-2) 75%),
        linear-gradient(-45deg, transparent 75%, var(--bic-surface-2) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.bic-preview {
    display: block;
    max-width: 100%;
    max-height: 340px;
    width: auto;
    height: auto;
    border-radius: 8px;
}

/* ---------- 文件信息栏 ---------- */

.bic-filebar {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin: 14px 2px 0;
    font-size: 13px;
    color: var(--bic-muted);
}

.bic-file-name {
    max-width: 100%;
    font-weight: 600;
    color: var(--bic-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bic-file-info {
    font-variant-numeric: tabular-nums;
}

/* ---------- 格式选择行 ---------- */

.bic-convert-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
}

.bic-convert-label {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--bic-muted);
    white-space: nowrap;
}

/* ---------- 分段控件 ---------- */

.bic-segment {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    padding: 4px;
    border-radius: 12px;
    background: var(--bic-surface-2);
    border: 1px solid var(--bic-border);
}

.bic-segment button {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    padding: 10px 0;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--bic-muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: color .2s, opacity .2s;
}

.bic-segment button:hover { color: var(--bic-text); }
.bic-segment button.is-active { color: var(--bic-text); }

.bic-segment button:focus-visible {
    outline: 2px solid var(--bic-accent);
    outline-offset: 2px;
}

/* 滑块 */
.bic-segment-thumb {
    position: absolute;
    top: 4px;
    left: 0;
    height: calc(100% - 8px);
    background: var(--bic-bg);
    border-radius: 9px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .14);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1),
                width .25s cubic-bezier(.4, 0, .2, 1);
    pointer-events: none;
}

/* 禁用态：同格式 / Safari 不支持 WebP */
.bic-segment button:disabled,
.bic-segment button.is-disabled {
    color: var(--bic-muted);
    opacity: .38;
    cursor: not-allowed;
    text-decoration: line-through;
    text-decoration-color: rgba(100, 116, 139, .5);
}

.bic-segment button:disabled:hover,
.bic-segment button.is-disabled:hover {
    color: var(--bic-muted);
}

/* ---------- 结果条 ---------- */

.bic-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid var(--bic-green-border);
    border-radius: 14px;
    background: linear-gradient(135deg, var(--bic-green-soft), #ecfdf5);
    animation: bic-fade .25s ease;
    transition: opacity .2s;
}

.bic-result.is-busy { opacity: .75; }

.bic-result-meta {
    flex: 1 1 auto;
    min-width: 0;
}

.bic-result-name {
    display: flex;
    align-items: center;
    margin: 0 0 3px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* busy 态：文件名后追加旋转指示器 */
.bic-result.is-busy .bic-result-name::after {
    content: "";
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid rgba(22, 163, 74, .25);
    border-top-color: var(--bic-green);
    border-radius: 50%;
    animation: bic-spin .7s linear infinite;
}

.bic-result-size {
    margin: 0;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--bic-green-hover);
    font-variant-numeric: tabular-nums;
}

/* ---------- 下载按钮 ---------- */

.bic-btn {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 11px;
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 8px 18px -8px rgba(22, 163, 74, .8);
    transition: transform .15s, box-shadow .15s, background .15s;
}

.bic-btn:hover {
    color: #fff;
    background: linear-gradient(135deg, #15803d, #166534);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px -8px rgba(22, 163, 74, .9);
}

.bic-btn:focus-visible {
    outline: 2px solid var(--bic-accent);
    outline-offset: 2px;
}

.bic-btn svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

/* ---------- 状态文本 ---------- */

.bic-status {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--bic-danger);
}

.bic-status:empty { display: none; }

/* ---------- 动画 ---------- */

@keyframes bic-spin { to { transform: rotate(360deg); } }

@keyframes bic-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .bic-wrap *,
    .bic-wrap *::before,
    .bic-wrap *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ---------- 深色模式 ---------- */

@media (prefers-color-scheme: dark) {
    .bic-wrap {
        --bic-bg: #0f172a;
        --bic-surface: #1e293b;
        --bic-surface-2: #1e293b;
        --bic-border: #334155;
        --bic-border-strong: #475569;
        --bic-text: #f1f5f9;
        --bic-muted: #94a3b8;
        --bic-accent: #3b82f6;
        --bic-green-soft: #0f1f17;
        --bic-green-border: rgba(22, 163, 74, .4);
        --bic-shadow: 0 1px 2px rgba(0, 0, 0, .3),
                      0 20px 44px -22px rgba(0, 0, 0, .7);
    }

    .bic-badge {
        background: rgba(16, 185, 129, .14);
        color: #34d399;
    }

    .bic-drop:hover,
    .bic-drop:focus-visible { background: rgba(59, 130, 246, .1); }

    .bic-drop.is-drag { background: rgba(59, 130, 246, .2); }

    .bic-preview-wrap { background-color: #0b1220; }

    .bic-segment-thumb { background: #334155; }

    .bic-segment button:disabled,
    .bic-segment button.is-disabled {
        opacity: .3;
        text-decoration-color: rgba(148, 163, 184, .4);
    }

    .bic-ghost-btn:hover {
        border-color: #f87171;
        color: #f87171;
        background: rgba(248, 113, 113, .1);
    }

    .bic-result {
        background: linear-gradient(135deg,
            rgba(22, 163, 74, .14),
            rgba(22, 163, 74, .08));
    }

    .bic-result-size { color: #4ade80; }

    .bic-result.is-busy .bic-result-name::after {
        border-color: rgba(74, 222, 128, .25);
        border-top-color: #4ade80;
    }
}

/* ---------- 小屏 ---------- */

@media (max-width: 560px) {
    .bic-card { padding: 20px; }

    .bic-title { font-size: 19px; }

    .bic-drop { padding: 32px 16px; }

    .bic-convert-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .bic-result {
        flex-direction: column;
        align-items: stretch;
    }

    .bic-btn { justify-content: center; }

    .bic-preview { max-height: 260px; }
}

@media (max-width: 380px) {
    .bic-card { padding: 16px; }

    .bic-head { flex-direction: column; align-items: stretch; }

    .bic-ghost-btn { align-self: flex-start; }
}

/* ---------- 进度条 ---------- */

.bic-progress {
    margin-top: 18px;
}

.bic-progress-track {
    position: relative;
    height: 6px;
    border-radius: 999px;
    background: var(--bic-surface-2);
    overflow: hidden;
}

.bic-progress-bar {
    position: relative;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #3b82f6, #7c3aed);
    transition: width .25s ease;
}

.bic-progress-bar.is-indeterminate {
    width: 40%;
    animation: bic-progress-flow 1.1s ease-in-out infinite;
    transition: none;
}

@keyframes bic-progress-flow {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.bic-progress-text {
    margin: 8px 0 0;
    font-size: 12.5px;
    color: var(--bic-muted);
    font-variant-numeric: tabular-nums;
}

.bic-progress-text:empty { display: none; }

@media (prefers-color-scheme: dark) {
    .bic-progress-track { background: #1e293b; }
}

@media (prefers-reduced-motion: reduce) {
    .bic-progress-bar.is-indeterminate { animation: none; }
}