/* 基础变量 - 暖金现代风 */
:root {
    --bg-color: #FAFAFA;
    --card-color: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #6B7280;
    --accent: #F59E0B;
    --accent-hover: #D97706;
    --border-color: #E5E7EB;
    --success: #10B981;
    --error: #EF4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部 */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 主内容区 */
.main {
    background: var(--card-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    position: relative;
}

/* 语言和音色选择 */
.voice-section {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.select-group {
    flex: 1;
}

.select-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.select-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    background: var(--card-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.select-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.voice-select-wrapper {
    display: flex;
    gap: 8px;
}

.voice-select-wrapper select {
    flex: 1;
}

.icon-btn {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.icon-btn .icon {
    font-size: 1.25rem;
}

/* 文本输入 */
.text-section {
    margin-bottom: 20px;
}

.text-section label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.text-section textarea {
    width: 100%;
    height: 160px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.text-section textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* 参数调整 */
.params-section {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
}

.param-group {
    flex: 1;
}

.param-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-wrapper input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    appearance: none;
    cursor: pointer;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.param-value {
    min-width: 60px;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* 字幕选项 */
.srt-section {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-color);
    border-radius: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* 操作按钮 */
.action-section {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 播放器 */
.player-section {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 10px;
}

.player-section audio {
    width: 100%;
    height: 40px;
}

/* 加载动画 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 历史记录 */
.history-section {
    margin-top: 24px;
    background: var(--card-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.history-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.2s;
}

.text-btn:hover {
    color: var(--accent);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    padding: 20px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    background: var(--bg-color);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: var(--border-color);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-item-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-text {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.history-item-actions {
    display: flex;
    gap: 8px;
}

.history-item-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: var(--card-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.history-item-btn:hover {
    background: var(--accent);
    color: white;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* 响应式设计 - 平板 */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .voice-section {
        flex-direction: column;
        gap: 12px;
    }

    .params-section {
        flex-direction: column;
        gap: 16px;
    }

    .main {
        padding: 20px;
    }
}

/* 响应式设计 - 手机 */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .header {
        margin-bottom: 20px;
        padding: 12px 0;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .main {
        padding: 16px;
        border-radius: 12px;
    }

    .select-group select {
        padding: 10px 14px;
    }

    .icon-btn {
        width: 44px;
        height: 44px;
    }

    .text-section textarea {
        height: 120px;
        padding: 12px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .action-section {
        flex-direction: column;
    }

    .history-section {
        padding: 16px;
        border-radius: 12px;
    }

    .history-item {
        padding: 10px;
    }
}

/* 滚动条样式 */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 动画 */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* API 文档区域 */
.api-section {
    margin-top: 24px;
    background: var(--card-color);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.api-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.api-header:hover {
    background: var(--bg-color);
}

.api-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.toggle-icon {
    color: var(--text-secondary);
    font-size: 0.8rem;
    transition: transform 0.3s;
}

.api-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.api-content {
    padding: 0 20px 20px;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.api-section.collapsed .api-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.api-item {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.api-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.api-item h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.api-endpoint {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.api-endpoint .method {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.method.get {
    background: #DBEAFE;
    color: #1D4ED8;
}

.method.post {
    background: #D1FAE5;
    color: #047857;
}

.api-endpoint code {
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.code-block {
    position: relative;
    background: #1E293B;
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}

.code-block pre {
    padding: 16px;
    padding-right: 70px;
    margin: 0;
    overflow-x: auto;
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: #E2E8F0;
    white-space: pre;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: #94A3B8;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #E2E8F0;
}

.copy-btn.copied {
    background: var(--success);
    color: white;
}

.api-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.api-params {
    margin-top: 12px;
    overflow-x: auto;
}

.api-params table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.api-params th,
.api-params td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.api-params th {
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-secondary);
}

.api-params td {
    color: var(--text-primary);
}

.api-params td:first-child {
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    color: var(--accent);
}

.api-params td:nth-child(2) {
    color: var(--text-secondary);
}

/* 响应式 - API 文档 */
@media (max-width: 768px) {
    .api-section {
        border-radius: 12px;
    }

    .api-header {
        padding: 16px;
    }

    .api-content {
        padding: 0 16px 16px;
    }

    .code-block pre {
        font-size: 0.75rem;
        padding: 12px;
        padding-right: 60px;
    }

    .api-params th,
    .api-params td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .api-endpoint {
        flex-wrap: wrap;
    }

    .code-block pre {
        font-size: 0.7rem;
    }
}
