/* ============================================================
   TTS 平台 - 全局样式
   主色: #4F46E5  成功: #10B981  警告: #F59E0B  错误: #EF4444
   ============================================================ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    background-color: #F9FAFB;
    color: #111827;
    line-height: 1.6;
    min-width: 768px;
}

a { color: #4F46E5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   顶部导航栏
   ============================================================ */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    padding: 0 24px;
}

.navbar-logo {
    font-size: 18px; font-weight: 700; color: #111827;
    display: flex; align-items: center; gap: 8px;
    margin-right: 40px; white-space: nowrap;
}

.navbar-nav {
    display: flex; gap: 32px; list-style: none;
}

.navbar-nav a {
    font-size: 14px; color: #6B7280; padding: 16px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.navbar-nav a:hover { color: #4F46E5; text-decoration: none; }
.navbar-nav a.active { color: #4F46E5; border-bottom-color: #4F46E5; }

.navbar-right {
    margin-left: auto;
    display: flex; align-items: center; gap: 16px;
    font-size: 14px; color: #6B7280;
}

.navbar-right .username { font-weight: 500; color: #111827; }

.btn-logout {
    background: none; border: 1px solid #D1D5DB; border-radius: 6px;
    padding: 4px 12px; font-size: 13px; color: #6B7280; cursor: pointer;
    transition: all 0.2s;
}
.btn-logout:hover { border-color: #EF4444; color: #EF4444; }

/* ============================================================
   页面容器
   ============================================================ */
.page-container {
    max-width: 960px;
    margin: 56px auto 0;
    padding: 32px 16px;
}

/* 宽版容器（任务列表、创建页） */
.page-container.wide {
    max-width: 1200px;
}

/* ============================================================
   卡片
   ============================================================ */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 32px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 18px; font-weight: 600; color: #111827;
    margin-bottom: 24px;
}

/* ============================================================
   表单元素
   ============================================================ */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block; font-size: 14px; font-weight: 600;
    color: #374151; margin-bottom: 6px;
}

.form-hint {
    font-size: 12px; color: #9CA3AF; margin-top: 4px;
}

textarea, input[type="text"], input[type="password"], input[type="search"], select {
    width: 100%; padding: 10px 12px;
    border: 1px solid #D1D5DB; border-radius: 8px;
    font-size: 14px; color: #111827;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

textarea:focus, input[type="text"]:focus, input[type="password"]:focus,
input[type="search"]:focus, select:focus {
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

textarea {
    resize: vertical; min-height: 160px;
    font-family: inherit;
}

/* 字数统计 */
.char-counter {
    text-align: right; font-size: 13px; color: #9CA3AF; margin-top: 4px;
}
.char-counter.warning { color: #F59E0B; }
.char-counter.error { color: #EF4444; font-weight: 600; }

/* 三列并排 */
.form-row {
    display: flex; gap: 28px;
}
.form-row .form-group { flex: 1; margin-bottom: 0; }

@media (max-width: 800px) {
    .form-row { flex-direction: column; }
}

/* ============================================================
   步进器（语速）
   ============================================================ */
.stepper {
    display: flex; align-items: center; gap: 8px;
}

.stepper-btn {
    width: 32px; height: 32px;
    border: 1px solid #D1D5DB; border-radius: 6px;
    background: #F9FAFB; color: #374151;
    font-size: 18px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; line-height: 1;
}
.stepper-btn:hover { background: #4F46E5; color: #fff; border-color: #4F46E5; }

.stepper-value {
    font-size: 16px; font-weight: 700; color: #111827;
    min-width: 50px; text-align: center;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: 8px;
    font-size: 14px; font-weight: 500;
    cursor: pointer; border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: #4F46E5; color: #fff;
}
.btn-primary:hover { background: #4338CA; }
.btn-primary:disabled { background: #A5B4FC; cursor: not-allowed; }

.btn-secondary {
    background: #fff; color: #374151;
    border: 1px solid #D1D5DB;
}
.btn-secondary:hover { background: #F9FAFB; }

.btn-danger {
    background: #fff; color: #EF4444;
    border: 1px solid #FCA5A5;
}
.btn-danger:hover { background: #FEF2F2; }

.btn-text {
    background: none; border: none; color: #4F46E5;
    padding: 4px 8px; font-size: 13px; cursor: pointer;
}
.btn-text:hover { text-decoration: underline; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-generate {
    width: 200px; height: 44px; font-size: 15px; font-weight: 600;
    margin: 24px auto 0; display: flex;
}

/* ============================================================
   音色试听按钮
   ============================================================ */
.voice-row {
    display: flex; align-items: center; gap: 8px;
}

.btn-play-sample {
    width: 32px; height: 32px; border-radius: 50%;
    background: #4F46E5; color: #fff; border: none;
    font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s; flex-shrink: 0;
}
.btn-play-sample:hover { background: #4338CA; }
.btn-play-sample.playing { background: #F59E0B; }

.btn-fav {
    background: none; border: none; font-size: 18px;
    cursor: pointer; padding: 2px; color: #D1D5DB;
    transition: color 0.2s;
}
.btn-fav.active { color: #F59E0B; }
.btn-fav:hover { color: #F59E0B; }

/* ============================================================
   状态标签
   ============================================================ */
.status { font-size: 13px; font-weight: 500; padding: 2px 8px; border-radius: 4px; }
.status-queued { background: #F3F4F6; color: #6B7280; }
.status-processing { background: #FEF3C7; color: #D97706; }
.status-completed { background: #D1FAE5; color: #059669; }
.status-failed { background: #FEE2E2; color: #DC2626; }
.status-cancelled { background: #F3F4F6; color: #9CA3AF; }

/* 旋转动画 */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; animation: spin 1s linear infinite; }

/* ============================================================
   播放区域（生成完成后）
   ============================================================ */
.result-area {
    margin-top: 20px; padding: 20px;
    background: #ECFDF5; border-radius: 8px;
    display: none;
}
.result-area.show { display: block; }
.result-area.error { background: #FEF2F2; }

.result-header {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 600; margin-bottom: 12px;
}

.audio-player {
    width: 100%; margin-bottom: 12px;
}
.audio-player audio { width: 100%; height: 40px; }

.result-actions {
    display: flex; gap: 16px;
}

/* 等待状态 */
.wait-area {
    margin-top: 20px; padding: 16px 20px;
    background: #F3F4F6; border-radius: 8px;
    text-align: center; color: #6B7280; font-size: 14px;
    display: none;
}
.wait-area.show { display: block; }

/* ============================================================
   任务列表表格
   ============================================================ */
.filters {
    display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
    align-items: center;
}

.filters input, .filters select {
    width: auto; min-width: 120px;
}

.filters .search-input { min-width: 200px; }

.batch-actions {
    display: flex; gap: 8px; margin-bottom: 12px;
}

.task-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
    table-layout: auto;
}

.task-table th {
    text-align: left; padding: 10px 8px;
    background: #F9FAFB; color: #6B7280; font-weight: 600;
    border-bottom: 1px solid #E5E7EB;
    white-space: nowrap;
}

.task-table td {
    padding: 10px 8px; border-bottom: 1px solid #F3F4F6;
    vertical-align: middle;
}

.task-table tr:hover { background: #F9FAFB; }
.task-table .task-row { cursor: pointer; }
.task-table .task-expand td { border-bottom: 1px solid #E5E7EB; }

.task-table .text-preview {
    max-width: 150px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; cursor: help;
}

.task-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.countdown { font-size: 12px; color: #9CA3AF; }

/* ============================================================
   分页
   ============================================================ */
.pagination {
    display: flex; justify-content: center; gap: 4px; margin-top: 20px;
}

.pagination button {
    padding: 6px 12px; border: 1px solid #D1D5DB; border-radius: 6px;
    background: #fff; color: #374151; font-size: 13px; cursor: pointer;
}
.pagination button:hover { background: #F9FAFB; }
.pagination button.active { background: #4F46E5; color: #fff; border-color: #4F46E5; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   设置页
   ============================================================ */
.settings-section {
    border-top: 1px solid #E5E7EB;
    padding-top: 24px; margin-top: 24px;
}
.settings-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.section-title {
    font-size: 15px; font-weight: 600; color: #374151; margin-bottom: 16px;
}

.actor-list { list-style: none; }
.actor-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border: 1px solid #E5E7EB; border-radius: 6px;
    margin-bottom: 8px;
}

.add-row {
    display: flex; gap: 8px; margin-top: 8px;
}
.add-row input { flex: 1; }

.voice-sample-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid #F3F4F6;
}
.voice-sample-item:last-child { border-bottom: none; }
.voice-sample-name { font-weight: 500; min-width: 120px; }
.voice-sample-status { font-size: 12px; color: #9CA3AF; }
.voice-sample-status.uploaded { color: #10B981; }

.password-toggle {
    position: relative;
}
.password-toggle input { padding-right: 40px; }
.password-toggle .toggle-btn {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; font-size: 16px; color: #9CA3AF;
}

/* ============================================================
   统计页
   ============================================================ */
.stats-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #F9FAFB; border-radius: 8px; padding: 20px; text-align: center;
}
.stat-number { font-size: 32px; font-weight: 700; color: #4F46E5; }
.stat-label { font-size: 13px; color: #6B7280; margin-top: 4px; }

.chart-bar-container {
    display: flex; align-items: flex-end; gap: 8px;
    height: 150px; padding: 0 20px;
}

.chart-bar-wrapper {
    flex: 1; display: flex; flex-direction: column; align-items: center;
}

.chart-bar {
    width: 100%; max-width: 40px;
    background: #4F46E5; border-radius: 4px 4px 0 0;
    min-height: 4px; transition: height 0.3s;
}

.chart-bar-label {
    font-size: 11px; color: #9CA3AF; margin-top: 6px;
}
.chart-bar-value {
    font-size: 11px; color: #4F46E5; font-weight: 600; margin-bottom: 4px;
}

.ranking-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.ranking-table th {
    text-align: left; padding: 8px; background: #F9FAFB;
    color: #6B7280; font-weight: 600; border-bottom: 1px solid #E5E7EB;
}
.ranking-table td { padding: 8px; border-bottom: 1px solid #F3F4F6; }

/* ============================================================
   登录页
   ============================================================ */
.login-page {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; background: #F9FAFB;
}

.login-box {
    background: #fff; padding: 40px; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    width: 100%; max-width: 400px; text-align: center;
}

.login-box h1 {
    font-size: 22px; font-weight: 700; margin-bottom: 8px;
}

.login-box .subtitle {
    font-size: 14px; color: #6B7280; margin-bottom: 32px;
}

.login-box .form-group { text-align: left; }

.login-box .btn-primary {
    width: 200px; height: 44px; margin: 24px auto 0;
}

/* ============================================================
   消息提示
   ============================================================ */
.toast {
    position: fixed; top: 72px; right: 24px; z-index: 200;
    padding: 12px 20px; border-radius: 8px;
    font-size: 14px; color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(120%);
    transition: transform 0.3s ease;
}
.toast.show { transform: translateX(0); }
.toast-success { background: #10B981; }
.toast-error { background: #EF4444; }
.toast-info { background: #4F46E5; }

/* ============================================================
   错误消息
   ============================================================ */
.error-msg {
    color: #EF4444; background: #FEF2F2;
    padding: 10px 14px; border-radius: 6px;
    font-size: 13px; margin-bottom: 16px;
    display: none;
}
.error-msg.show { display: block; }

/* ============================================================
   工具类
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: #9CA3AF; }
.text-sm { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
