/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 800px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 900px;
}

/* 头部 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* 语言选择区 */
.language-control {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.language-selector {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.language-selector label {
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

.lang-select {
    padding: 10px 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.lang-select:hover {
    border-color: #667eea;
}

.lang-select:focus {
    outline: none;
    border-color: #667eea;
}

.swap-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
}

.swap-btn:hover {
    background: #5568d3;
    transform: rotate(180deg);
}

.swap-btn:active {
    transform: scale(0.95);
}

/* 状态栏 */
.status-bar {
    padding: 12px 30px;
    background: #e7f3ff;
    border-bottom: 1px solid #b6d4fe;
    text-align: center;
}

#status-text {
    font-size: 14px;
    color: #084298;
}

.status-bar.connected #status-text {
    color: #0f5132;
}

.status-bar.connected {
    background: #d1e7dd;
    border-bottom: 1px solid #a3cfbb;
}

.status-bar.error {
    background: #f8d7da;
    border-bottom: 1px solid #f1aeb5;
}

.status-bar.error #status-text {
    color: #842029;
}

/* 字幕容器 */
.sentences-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    background: #ffffff;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
}

.empty-state p {
    font-size: 16px;
}

/* 句子卡片 */
.sentence-card {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    animation: slideIn 0.3s ease-out;
}

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

.sentence-card .source {
    font-size: 16px;
    color: #212529;
    margin-bottom: 10px;
    font-weight: 500;
}

.sentence-card .translation {
    font-size: 15px;
    color: #495057;
    padding-top: 10px;
    border-top: 1px solid #dee2e6;
}

/* 可点击的译文样式 */
.sentence-card .translation.clickable {
    cursor: pointer;
    position: relative;
    padding-left: 2rem; /* 为图标留更多空间 */
    transition: all 0.2s ease;
}

/* 添加播放图标 */
.sentence-card .translation.clickable::before {
    content: '🔊';
    position: absolute;
    left: 0;
    top: 10px; /* 与译文对齐 */
    opacity: 1; /* 默认显示喇叭 */
    transition: opacity 0.2s ease;
    font-size: 0.9rem;
    line-height: 1;
}

/* hover 效果 */
.sentence-card .translation.clickable:hover {
    background-color: #f0f9ff;
    color: #0284c7;
    padding: 0.5rem 0.5rem 0.5rem 2rem; /* 保持左侧padding给图标 */
    margin: -0.5rem 0 -0.5rem -0.5rem;
    border-radius: 6px;
}

.sentence-card .translation.clickable:hover::before {
    left: 0.5rem; /* hover时图标也跟着移动 */
}

/* 播放中状态 */
.sentence-card .translation.replaying {
    background-color: #dbeafe;
    color: #0369a1;
    padding: 0.5rem 0.5rem 0.5rem 2rem; /* 保持左侧padding给图标 */
    margin: -0.5rem 0 -0.5rem -0.5rem;
    border-radius: 6px;
    animation: translation-pulse 1.5s ease-in-out infinite;
}

.sentence-card .translation.replaying::before {
    content: '▶';
    opacity: 1;
    left: 0.5rem; /* 播放时图标位置 */
}

@keyframes translation-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.sentence-card .status {
    font-size: 12px;
    color: #6c757d;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sentence-card .status.playing {
    color: #0d6efd;
    font-weight: 500;
}

.sentence-card .status.done {
    color: #198754;
}

.sentence-card .status.error {
    color: #dc3545;
}

/* 控制区 */
.control-area {
    padding: 25px 30px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 15px;
    align-items: center;
}

.clear-btn {
    padding: 12px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.clear-btn:hover {
    background: #5a6268;
}

.talk-btn {
    flex: 1;
    padding: 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
}

.talk-btn:hover:not(:disabled) {
    background: #5568d3;
    transform: scale(1.02);
}

.talk-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.talk-btn.recording {
    background: #dc3545;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(220, 53, 69, 0);
    }
}

.talk-btn:disabled {
    background: #dee2e6;
    color: #6c757d;
    cursor: not-allowed;
}

/* 错误提示 Toast */
.error-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #dc3545;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease-out;
}

.error-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 滚动条样式 */
.sentences-container::-webkit-scrollbar {
    width: 8px;
}

.sentences-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sentences-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.sentences-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 响应式 */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .header h1 {
        font-size: 24px;
    }

    .language-control {
        flex-direction: column;
        gap: 10px;
    }

    .swap-btn {
        transform: rotate(90deg);
        margin-top: 0;
    }

    .swap-btn:hover {
        transform: rotate(270deg);
    }
}
