/* =============================================================
 * 音视频工具专属共享样式（media-tools.css）
 * -------------------------------------------------------------
 * 仅被 /tools/media/* 下的工具页面引用，绝不修改公共 common.css。
 * 复用图片工具共享类的语义变量与组件类（.status/.code-area/.stat-grid
 * /.tool-btn/.opts/.form-tip/.btn-ghost 等），并补充音视频专属类。
 * 旧工具不引用本文件，零风险。
 * ============================================================= */

/* ---- 语义变量（与 image-tools.css 保持一致） ---- */
:root {
    --radius: 8px;
    --code-bg: #f6f8fa;
    --code-border: #e3e8ef;
    --tip-bg: rgba(255, 107, 0, 0.10);
    --tip-tx: #b35000;
    --wait-bg: #fff7e6;
    --wait-tx: #8a6100;
    --wait-border: #f3d98a;
    --ok-bg: #e9f8ee;
    --ok-tx: #1d7a3e;
    --ok-border: #a8e0bd;
    --err-bg: #fdecec;
    --err-tx: #c0392b;
    --err-border: #f3b7b1;
    --out-bg: #f6f8fa;
    --out-border: #e3e8ef;
    --sv-hl: #ff6b00;
    --line: #e3e8ef;
    --canvas-bg: #ffffff;
}

[data-theme="dark"] {
    --code-bg: #1b1f24;
    --code-border: #2c333c;
    --tip-bg: rgba(255, 107, 0, 0.16);
    --tip-tx: #ffae6b;
    --wait-bg: #3a3320;
    --wait-tx: #f0c869;
    --wait-border: #5c4f2a;
    --ok-bg: #1c3326;
    --ok-tx: #6bd99a;
    --ok-border: #2e5a44;
    --err-bg: #3a2424;
    --err-tx: #f08a82;
    --err-border: #5c3633;
    --out-bg: #1b1f24;
    --out-border: #2c333c;
    --sv-hl: #ff8a3d;
    --line: #2c333c;
    --canvas-bg: #16191d;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --code-bg: #1b1f24;
        --code-border: #2c333c;
        --tip-bg: rgba(255, 107, 0, 0.16);
        --tip-tx: #ffae6b;
        --wait-bg: #3a3320;
        --wait-tx: #f0c869;
        --wait-border: #5c4f2a;
        --ok-bg: #1c3326;
        --ok-tx: #6bd99a;
        --ok-border: #2e5a44;
        --err-bg: #3a2424;
        --err-tx: #f08a82;
        --err-border: #5c3633;
        --out-bg: #1b1f24;
        --out-border: #2c333c;
        --sv-hl: #ff8a3d;
        --line: #2c333c;
        --canvas-bg: #16191d;
    }
}

/* ---- 复用：代码 / 文本域 ---- */
.code-area {
    width: 100%;
    box-sizing: border-box;
    min-height: 200px;
    resize: vertical;
    padding: 12px 14px;
    border: 1px solid var(--code-border);
    border-radius: var(--radius-sm);
    background: var(--code-bg);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
}
.code-area:focus { outline: none; border-color: var(--primary); }

/* ---- 复用：双栏 ---- */
.io-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 14px 0;
}
.io-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.io-label .cnt { color: var(--text-secondary); font-size: 12px; }

/* ---- 复用：表单元素 ---- */
.form-item { margin: 12px 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0; }
.form-input, .form-select {
    padding: 8px 11px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    box-sizing: border-box;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--primary); }
.check-item {
    display: flex; align-items: center; gap: 7px;
    font-size: 13px; color: var(--text-primary); cursor: pointer;
}
.check-item input { width: 15px; height: 15px; accent-color: var(--primary); }

/* ---- 复用：统计卡片 ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.stat-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}
.stat-card .num { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.stat-card .lab { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.st-title { font-size: 13px; color: var(--text-secondary); margin: 14px 0 6px; }
.sv { font-weight: 600; }
.sv.hl { color: var(--sv-hl); }
.sl { font-size: 12px; color: var(--text-secondary); }
.row-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.cnt { color: var(--text-secondary); font-size: 12px; }
.blue { color: var(--primary); }

/* 面包屑分隔符与当前页（common.css 未定义，分类内补充） */
.tool-breadcrumb .sep { color: var(--text-muted, #9aa4b2); margin: 0 8px; }
.tool-breadcrumb .cur { color: var(--text-primary); font-weight: 600; }

/* ---- 复用：状态提示（三色） ---- */
.status, .status-box {
    display: none;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin: 12px 0;
    border: 1px solid transparent;
    line-height: 1.6;
}
.status.show, .status-box.show { display: block; }
.status.wait, .status-box.wait { background: var(--wait-bg); color: var(--wait-tx); border-color: var(--wait-border); }
.status.ok, .status-box.ok { background: var(--ok-bg); color: var(--ok-tx); border-color: var(--ok-border); }
.status.err, .status-box.err { background: var(--err-bg); color: var(--err-tx); border-color: var(--err-border); }

/* ---- 复用：说明提示框 ---- */
.form-tip {
    background: var(--tip-bg);
    color: var(--tip-tx);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.6;
    margin: 12px 0;
}
.form-tip code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.form-tip b { color: var(--tip-tx); }

/* ---- 复用：按钮组 / 工具按钮 ---- */
.btn-row, .btn-group {
    display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0;
}
.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
    cursor: pointer; border: 1px solid var(--border-color);
    background: transparent; color: var(--text-secondary); transition: all 0.2s;
}
.btn-ghost:hover { background: var(--tip-bg); color: var(--primary); border-color: var(--primary); }
.tool-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
    cursor: pointer; border: 1px solid var(--border-color);
    background: var(--bg-body); color: var(--text-primary); transition: all 0.2s;
}
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.tool-btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.tool-btn.ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-color); }
.tool-btn.ghost:hover { background: var(--tip-bg); color: var(--primary); border-color: var(--primary); }
.tool-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- 复用：选项 / 模式 ---- */
.opts {
    display: flex; gap: 18px; margin: 14px 0 18px; padding: 12px 16px;
    background: var(--bg-body); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); flex-wrap: wrap;
}
.opt { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-primary); }
.opt input { width: 15px; height: 15px; accent-color: var(--primary); }
.modes { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.mode-item {
    display: flex; align-items: center; gap: 8px; padding: 10px 16px;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    cursor: pointer; font-size: 14px; color: var(--text-primary);
    background: var(--bg-body); transition: 0.15s;
}
.mode-item:hover { border-color: var(--primary); }
.mode-item input { width: 15px; height: 15px; accent-color: var(--primary); }
.mode-item.checked { border-color: var(--primary); background: var(--tip-bg); color: var(--tip-tx); font-weight: 600; }

/* ---- 复用：结果 / 输出区 ---- */
.result-box {
    background: var(--out-bg); border: 1px solid var(--out-border);
    border-radius: var(--radius-sm); padding: 12px 14px; margin: 12px 0;
    font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
.badge {
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
    background: var(--tip-bg); color: var(--tip-tx);
}

/* ---- 复用：选项卡 ---- */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin: 14px 0 12px; }
.tab-btn {
    padding: 8px 14px; border: none; background: transparent; color: var(--text-secondary);
    cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
@media (max-width: 768px) {
    .tab-bar { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .tab-bar::-webkit-scrollbar { display: none; }
    .tab-btn { white-space: nowrap; flex-shrink: 0; font-size: 13px; padding: 8px 12px; }
}

/* ---- 复用：进度条 ---- */
.progress {
    height: 10px; background: var(--code-border); border-radius: 20px;
    overflow: hidden; margin: 14px 0 6px;
}
.progress-bar {
    height: 100%; width: 0%; background: var(--primary);
    border-radius: 20px; transition: width 0.2s;
}
.progress-text { font-size: 12px; color: var(--text-secondary); }

/* ---- 复用：拖拽上传区 ---- */
.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-body);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: 0.15s;
    margin: 14px 0;
}
.dropzone:hover, .dropzone.drag {
    border-color: var(--primary);
    background: var(--tip-bg);
}
.dz-icon { font-size: 38px; line-height: 1; margin-bottom: 8px; }
.dz-text { font-size: 15px; color: var(--text-primary); font-weight: 500; }
.dz-text .blue { color: var(--primary); }
.dz-hint { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* =========================================================
 * 音视频工具专属组件
 * ========================================================= */

/* 视频 / 音频播放器容器 */
.video-box {
    width: 100%;
    margin: 14px 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #000;
    overflow: hidden;
    line-height: 0;
}
.video-box video, .video-box audio {
    display: block;
    width: 100%;
    max-height: 420px;
    background: #000;
}
.video-box audio { max-height: none; }

/* 媒体信息行 */
.media-info {
    display: flex; flex-wrap: wrap; gap: 14px;
    font-size: 12px; color: var(--text-secondary);
    margin: 8px 0 4px;
}
.media-info b { color: var(--text-primary); font-weight: 600; }

/* 录制控制区 */
.rec-controls {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    margin: 14px 0;
}
.rec-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: #c0392b; display: inline-block; margin-right: 6px;
    vertical-align: middle;
}
.rec-dot.live { animation: recpulse 1s infinite; }
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.rec-time {
    font-variant-numeric: tabular-nums;
    font-size: 18px; font-weight: 700; color: var(--text-primary);
    background: var(--code-bg); border: 1px solid var(--code-border);
    padding: 4px 12px; border-radius: var(--radius-sm);
}

/* 波形图 */
.waveform {
    width: 100%;
    height: 110px;
    margin: 14px 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--canvas-bg);
    display: block;
    cursor: crosshair;
    touch-action: none;
}
.waveform-selection {
    position: relative;
    margin: 0 0 14px;
}

/* 双滑块选区（起止时间） */
.range-double {
    position: relative;
    height: 38px;
    margin: 14px 0;
}
.range-double .track {
    position: absolute; top: 17px; left: 0; right: 0; height: 4px;
    background: var(--code-border); border-radius: 4px;
}
.range-double .fill {
    position: absolute; top: 17px; height: 4px;
    background: var(--primary); border-radius: 4px;
}
.range-double input[type=range] {
    position: absolute; top: 0; left: 0; width: 100%;
    margin: 0; background: none; pointer-events: none;
    -webkit-appearance: none; appearance: none;
    height: 38px;
}
.range-double input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    pointer-events: auto;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 2px solid var(--primary); cursor: pointer;
}
.range-double input[type=range]::-moz-range-thumb {
    pointer-events: auto;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 2px solid var(--primary); cursor: pointer;
}
.range-double .labels {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--text-secondary); margin-top: 4px;
}

/* 滑块行 */
.range-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.range-row label { font-size: 13px; color: var(--text-secondary); min-width: 72px; }
.range-row input[type=range] { flex: 1; min-width: 160px; accent-color: var(--primary); }
.range-row .val { font-size: 13px; color: var(--text-primary); font-weight: 600; min-width: 56px; text-align: right; }

/* GIF 预览 */
.gif-preview {
    margin: 14px 0;
    text-align: center;
}
.gif-preview img {
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background:
        linear-gradient(45deg, #e9edf2 25%, transparent 25%),
        linear-gradient(-45deg, #e9edf2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e9edf2 75%),
        linear-gradient(-45deg, transparent 75%, #e9edf2 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: var(--canvas-bg);
}
[data-theme="dark"] .gif-preview img,
:root:not([data-theme="light"]) .gif-preview img {
    background:
        linear-gradient(45deg, #2a2f37 25%, transparent 25%),
        linear-gradient(-45deg, #2a2f37 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2f37 75%),
        linear-gradient(-45deg, transparent 75%, #2a2f37 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* 文字转语音：语音选择 + 文本域 */
.tts-voices {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    box-sizing: border-box;
    margin: 4px 0 12px;
}
.text-area {
    width: 100%;
    min-height: 160px;
    resize: vertical;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.7;
    box-sizing: border-box;
    font-family: inherit;
}
.text-area:focus { outline: none; border-color: var(--primary); }

/* 语音转文字：识别结果 + 实时字幕 */
.live-caption {
    min-height: 80px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--canvas-bg);
    padding: 12px 14px;
    font-size: 15px; line-height: 1.7;
    margin: 12px 0;
    color: var(--text-primary);
}
.live-caption .interim { color: var(--text-secondary); }

/* 下载链接 */
.dl-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--primary); font-size: 13px; text-decoration: none; cursor: pointer;
}
.dl-link:hover { text-decoration: underline; }

.hidden { display: none !important; }
.full-width { width: 100%; }
.center { text-align: center; }

@media (max-width: 768px) {
    .io-grid { grid-template-columns: 1fr; }
}
