/* DualTalk - 公共样式 */

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

:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #666666;
    --accent-a: #667eea;
    --accent-b: #f5576c;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* 顶部控制栏 */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    flex-wrap: wrap;
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* 开关样式 */
.toggle {
    position: relative;
    width: 60px;
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle.active {
    background: var(--accent-a);
}

.toggle-knob {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle.active .toggle-knob {
    left: 32px;
}

/* 语言切换特殊样式 */
.toggle.lang .toggle-knob::after {
    content: 'TH';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--bg-secondary);
    font-size: 8px;
    font-weight: bold;
}

.toggle.lang.active .toggle-knob::after {
    content: 'EN';
}

/* 主显示区域 */
.main-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    min-height: 200px;
}

.translation-container {
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.translation-item {
    padding: 1rem;
    margin: 0.5rem 0;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    opacity: 0;
    transform: translateY(20px);
    animation: slideIn 0.3s ease forwards;
}

.translation-item.latest {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-a);
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.translation-text {
    font-size: 2rem;
    line-height: 1.4;
    font-weight: 500;
}

.translation-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* 本机识别显示区域 */
.local-display {
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
    padding: 1.5rem;
    min-height: 120px;
}

.local-container {
    max-width: 600px;
    margin: 0 auto;
}

.local-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.local-text {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.local-text.interim {
    color: var(--text-muted);
    font-style: italic;
}

/* 状态栏 */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
    font-size: 0.85rem;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.connected {
    background: var(--success);
    animation: pulse 2s infinite;
}

.status-dot.listening {
    background: var(--warning);
    animation: pulse 1s infinite;
}

.status-dot.error {
    background: var(--error);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text {
    color: var(--text-secondary);
}

/* 录音指示器 */
.recording-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--error);
}

.recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--error);
    animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* 欢迎提示 */
.welcome-message {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.welcome-message h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.welcome-message p {
    font-size: 0.95rem;
    line-height: 1.6;
}

/* 权限请求提示 */
.permission-prompt {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.permission-content {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 400px;
}

.permission-content h3 {
    margin-bottom: 1rem;
}

.permission-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.permission-btn {
    padding: 0.75rem 2rem;
    background: var(--accent-a);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.permission-btn:hover {
    opacity: 0.9;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .controls {
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .toggle-group {
        gap: 0.25rem;
    }

    .toggle-label {
        font-size: 0.8rem;
    }

    .toggle {
        width: 50px;
        height: 28px;
    }

    .translation-text {
        font-size: 1.5rem;
    }

    .local-display {
        padding: 1rem;
    }

    .local-text {
        font-size: 0.9rem;
    }
}

/* 深色模式适配（默认就是深色） */
@media (prefers-color-scheme: light) {
    /* 强制保持深色模式 */
}

/* 横屏适配 */
@media (orientation: landscape) and (max-height: 500px) {
    .main-display {
        padding: 1rem;
    }

    .translation-text {
        font-size: 1.5rem;
    }

    .local-display {
        min-height: 80px;
    }
}
