/* public/assets/css/ai/tts.css */
.tts-tool-wrapper { --p-bg: #ffffff; --p-border: #e2e8f0; --p-primary: #10b981; --p-text: #0f172a; width: 100%; max-width: 1300px; margin: 0 auto; background: var(--p-bg); border-radius: 24px; padding: 32px; border: 1px solid var(--p-border); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05); box-sizing: border-box; transition: 0.3s; }
.tts-header-main { font-size: 1.6rem; font-weight: 700; color: var(--p-text); margin-bottom: 12px; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; text-align: center; }
.tts-badge { background: #dcfce7; color: #16a34a; padding: 4px 12px; border-radius: 30px; font-size: 0.85rem; font-weight: 600; border: 1px solid #bbf7d0; }
.tts-subtitle { color: #64748b; font-size: 1rem; padding-bottom: 20px; border-bottom: 1px solid var(--p-border); margin-bottom: 24px; text-align: center; max-width: 900px; margin-left: auto; margin-right: auto; line-height: 1.6; }

.tts-layout { display: grid; grid-template-columns: 1fr 450px; gap: 24px; align-items: stretch; margin-bottom: 40px; }

.tts-panel { background: #f8fafc; border: 1px solid var(--p-border); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; box-sizing: border-box; min-width: 0; }
.tts-panel-title { font-weight: 700; color: var(--p-text); font-size: 1.1rem; display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--p-border); }
.tts-btn-icon { background: none; border: none; color: #64748b; cursor: pointer; font-size: 1.1rem; transition: 0.2s; }
.tts-btn-icon:hover { color: var(--p-primary); transform: scale(1.1); }

/* Tabs 切换器：默认桌面端布局 */
.tts-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; background: #e2e8f0; padding: 6px; border-radius: 12px; }
.tts-tab-btn { flex: 1 1 calc(25% - 8px); min-width: 120px; border: none; background: transparent; padding: 10px 4px; font-size: 0.95rem; font-weight: 600; color: #475569; border-radius: 8px; cursor: pointer; transition: 0.2s; text-align: center; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 4px; }
.tts-tab-btn.active { background: #ffffff; color: var(--p-primary); box-shadow: 0 2px 6px rgba(0,0,0,0.05); }

.tts-info-alert { background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; padding: 12px 14px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; word-break: break-word; }

.tts-textarea { flex: 1; min-height: 280px; width: 100%; padding: 16px; background: #ffffff; border: 2px solid #cbd5e1; color: var(--p-text); border-radius: 12px; outline: none; font-size: 1.05rem; line-height: 1.6; resize: vertical; transition: 0.2s; margin-bottom: 16px; box-sizing: border-box; }
.tts-textarea:focus { border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1); }

.tts-status-bar { display: flex; justify-content: space-between; align-items: center; background: #0f172a; padding: 12px 20px; border-radius: 12px; color: #f8fafc; flex-wrap: wrap; gap: 10px; }
.tts-status-text { font-family: monospace; font-size: 0.95rem; font-weight: 600; color: #38bdf8; word-break: break-all; }
.tts-error-box { margin-top: 16px; padding: 16px; background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; border-radius: 12px; font-size: 0.95rem; line-height: 1.6; word-break: break-word; }

.tts-wave { display: flex; align-items: center; gap: 4px; height: 24px; }
.tts-bar { width: 4px; height: 4px; background: var(--p-primary); border-radius: 2px; transition: 0.2s; }
.tts-wave.is-speaking .tts-bar { animation: ttsSoundWave 1s infinite ease-in-out; }
.tts-wave.is-speaking .tts-bar:nth-child(1) { animation-delay: 0.0s; }
.tts-wave.is-speaking .tts-bar:nth-child(2) { animation-delay: 0.1s; }
.tts-wave.is-speaking .tts-bar:nth-child(3) { animation-delay: 0.2s; }
.tts-wave.is-speaking .tts-bar:nth-child(4) { animation-delay: 0.3s; }
.tts-wave.is-speaking .tts-bar:nth-child(5) { animation-delay: 0.4s; }
@keyframes ttsSoundWave { 0%, 100% { height: 4px; } 50% { height: 24px; background: #34d399; } }

.tts-api-row { display: flex; gap: 12px; align-items: center; background: #ffffff; padding: 12px; border-radius: 10px; border: 1px solid var(--p-border); flex-wrap: wrap; box-sizing: border-box; width: 100%; }
.tts-input-sm { flex: 1; min-width: 120px; padding: 10px 14px; font-size: 0.9rem; border-radius: 8px; background: #f1f5f9; border: 1px solid #cbd5e1; outline: none; transition: 0.2s; font-family: monospace; box-sizing: border-box; }
.tts-input-sm:focus { border-color: var(--p-primary); background: #ffffff;}
.tts-api-link { font-size: 0.9rem; color: var(--p-primary); text-decoration: none; font-weight: 600; white-space: nowrap; }

.tts-control-group { margin-bottom: 24px; width: 100%; }
.tts-label { display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; font-weight: 700; color: #475569; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.tts-val-badge { background: #f1f5f9; padding: 2px 8px; border-radius: 6px; font-family: monospace; color: var(--p-primary); font-size: 0.9rem; border: 1px solid #e2e8f0; }

.tts-select { width: 100%; padding: 12px; border: 2px solid #cbd5e1; border-radius: 10px; background: #ffffff; font-size: 0.95rem; color: var(--p-text); outline: none; cursor: pointer; transition: 0.2s; box-sizing: border-box; }
.tts-select:focus { border-color: var(--p-primary); }

.tts-radio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tts-radio-label { display: block; padding: 10px 14px; background: #ffffff; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 0.9rem; font-weight: 600; color: #475569; cursor: pointer; transition: 0.2s; text-align: center; }
.tts-radio-label:has(input:checked) { background: #ecfdf5; border-color: var(--p-primary); color: var(--p-primary); box-shadow: 0 2px 6px rgba(16, 185, 129, 0.15); }
.tts-radio-label input { display: none; }

.tts-slider { -webkit-appearance: none; width: 100%; height: 6px; background: #cbd5e1; border-radius: 3px; outline: none; margin-top: 10px; }
.tts-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--p-primary); cursor: pointer; box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4); }

.tts-actions { margin-top: auto; display: flex; flex-direction: column; gap: 12px; width: 100%; }
.tts-btn { width: 100%; border: none; padding: 14px; border-radius: 10px; font-weight: bold; font-size: 1.05rem; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px; white-space: nowrap; box-sizing: border-box; }
.tts-btn:disabled { opacity: 0.6; cursor: not-allowed; filter: grayscale(1); box-shadow: none !important; }

.tts-btn-primary { background: var(--p-primary); color: white; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.tts-btn-primary:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-2px); }

.tts-sub-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.tts-btn-secondary { background: #e2e8f0; color: #334155; font-size: 0.95rem; }
.tts-btn-secondary:hover:not(:disabled) { background: #cbd5e1; }
.tts-btn-danger { background: #fee2e2; color: #dc2626; font-size: 0.95rem; }
.tts-btn-danger:hover:not(:disabled) { background: #fca5a5; }

.tts-btn-success { background: #3b82f6; color: white; }
.tts-btn-success:hover:not(:disabled) { background: #2563eb; }
.tts-btn-outline { background: #ffffff; color: #3b82f6; border: 2px solid #3b82f6; }
.tts-btn-outline:hover:not(:disabled) { background: #eff6ff; }

.tts-scenarios-box { background: #f8fafc; border: 1px solid var(--p-border); border-radius: 16px; padding: 32px; box-sizing: border-box; }
.tts-scenarios-title { font-size: 1.3rem; font-weight: 800; color: var(--p-text); margin-top: 0; margin-bottom: 24px; text-align: center; }
.tts-scenarios-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 24px; }
.tts-scenario-card { background: #ffffff; padding: 20px; border-radius: 12px; border: 1px solid #e2e8f0; box-shadow: 0 2px 8px rgba(0,0,0,0.02); }
.tts-scenario-card h4 { margin-top: 0; margin-bottom: 12px; font-size: 1.05rem; color: #334155; border-bottom: 2px solid #f1f5f9; padding-bottom: 8px; }
.tts-scenario-card ul { list-style: none; padding: 0; margin: 0; }
.tts-scenario-card li { font-size: 0.9rem; color: #475569; margin-bottom: 8px; line-height: 1.6; position: relative; padding-left: 14px; }
.tts-scenario-card li::before { content: "•"; color: var(--p-primary); font-weight: bold; position: absolute; left: 0; top: 0; }
.tts-scenario-card li b { color: var(--p-text); }

/* ================= 移动端适配 (防溢出核心修复) ================= */
@media(max-width: 1000px) { 
    .tts-layout { grid-template-columns: 1fr; } 
}
@media(max-width: 640px) {
    .tts-tool-wrapper { padding: 16px; }
    
    /* 强制重构移动端的选项卡为 2列 网格，防止长文字挤压导致乱码 */
    .tts-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; }
    .tts-tab-btn { width: 100%; min-width: 0; flex: none; font-size: 0.85rem; padding: 8px 4px; line-height: 1.3; white-space: normal; flex-direction: column; }
    
    .tts-api-row { flex-direction: column; align-items: stretch; }
    .tts-input-sm { max-width: 100% !important; }
    .tts-api-link { align-self: flex-end; }
    .tts-radio-grid { grid-template-columns: 1fr; }
    .tts-sub-actions { grid-template-columns: 1fr; }
    .tts-panel { padding: 16px; min-width: 0; overflow: hidden; }
}

/* ================= 黑夜模式 ================= */
[data-theme="dark"] .tts-tool-wrapper { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .tts-panel, [data-theme="dark"] .tts-api-row, [data-theme="dark"] .tts-scenarios-box { background: #0f172a; border-color: #475569; }
[data-theme="dark"] .tts-panel-title, [data-theme="dark"] .tts-scenarios-title { border-bottom-color: #475569; color: #f8fafc; }
[data-theme="dark"] .tts-tabs { background: #1e293b; }
[data-theme="dark"] .tts-tab-btn { color: #94a3b8; }
[data-theme="dark"] .tts-tab-btn.active { background: #334155; color: var(--p-primary); }
[data-theme="dark"] .tts-info-alert { background: rgba(16, 185, 129, 0.1); border-color: #065f46; color: #34d399; }
[data-theme="dark"] .tts-textarea, [data-theme="dark"] .tts-input-sm, [data-theme="dark"] .tts-select { background: #1e293b; border-color: #475569; color: #f8fafc; }
[data-theme="dark"] .tts-textarea:focus, [data-theme="dark"] .tts-input-sm:focus, [data-theme="dark"] .tts-select:focus { border-color: var(--p-primary); }
[data-theme="dark"] .tts-status-bar { background: #020617; border: 1px solid #000; }
[data-theme="dark"] .tts-error-box { background: rgba(220, 38, 38, 0.1); border-color: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .tts-label { color: #cbd5e1; }
[data-theme="dark"] .tts-val-badge { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .tts-radio-label { background: #1e293b; border-color: #475569; color: #cbd5e1; }
[data-theme="dark"] .tts-radio-label:has(input:checked) { background: rgba(16, 185, 129, 0.1); border-color: var(--p-primary); }
[data-theme="dark"] .tts-slider { background: #475569; }
[data-theme="dark"] .tts-btn-secondary { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .tts-btn-secondary:hover:not(:disabled) { background: #475569; }
[data-theme="dark"] .tts-btn-danger { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }
[data-theme="dark"] .tts-btn-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.4); }
[data-theme="dark"] .tts-btn-outline { background: #0f172a; color: #60a5fa; border-color: #3b82f6; }
[data-theme="dark"] .tts-btn-outline:hover:not(:disabled) { background: #1e3a8a; }
[data-theme="dark"] .tts-scenario-card { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .tts-scenario-card h4 { color: #f8fafc; border-bottom-color: #334155; }
[data-theme="dark"] .tts-scenario-card li { color: #94a3b8; }
[data-theme="dark"] .tts-scenario-card li b { color: #cbd5e1; }