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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #000;
    color: #333;
}

#app {
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* 页面隐藏 */
.page.hidden {
    display: none !important;
}

/* ==================== 加载画面 ==================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

#loading-screen .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#loading-screen p {
    color: #fff;
    margin-top: 20px;
    font-size: 16px;
}

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

/* ==================== 配置页面 ==================== */
#setup-page {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    padding: 20px;
}

.setup-container {
    background: rgba(255,255,255,0.95);
    border-radius: 24px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.setup-title {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.setup-subtitle {
    font-size: 16px;
    color: #666;
    text-align: center;
    margin-bottom: 32px;
}

.setup-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-label {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.form-label .optional {
    font-weight: 400;
    color: #999;
    font-size: 13px;
}

/* 选项卡片 */
.option-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.option-cards.small {
    grid-template-columns: repeat(3, 1fr);
}

.option-card {
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.option-card:hover {
    background: #e9ecef;
}

.option-card.selected {
    background: #e7f5ff;
    border-color: #339af0;
}

.option-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.option-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.option-desc {
    font-size: 12px;
    color: #666;
}

.option-cards.small .option-card {
    padding: 12px;
}

.option-cards.small .option-name {
    font-size: 14px;
}

/* 表单输入 */
.form-input, .form-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.3s ease;
    background: #fff;
}

.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* 开始按钮 */
.start-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102,126,234,0.4);
}

.start-btn:active {
    transform: translateY(0);
}

.start-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ==================== 面试页面 ==================== */
#interview-page {
    width: 100%;
    height: 100vh;
    display: flex;
    background: #f0f2f5;
    overflow: hidden;
}

/* 数字人区域 */
#character-container {
    flex: 1.2;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(102,126,234,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(118,75,162,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(240,147,251,0.15) 0%, transparent 40%),
        linear-gradient(180deg, #e8eaff 0%, #f0e6ff 40%, #fff0f5 70%, #f0fff0 100%);
}

/* 思考过程面板 */
#thinking-panel {
    width: 320px;
    background: #fff;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e9ecef;
    border-right: 1px solid #e9ecef;
}

.thinking-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfc;
}

.thinking-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.toggle-btn {
    background: none;
    border: none;
    color: #667eea;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.toggle-btn:hover {
    background: #e7f5ff;
}

.thinking-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 13px;
    line-height: 1.8;
    color: #555;
    background: #fafbfc;
}

.thinking-placeholder {
    color: #999;
    font-style: italic;
    text-align: center;
    margin-top: 40px;
}

.thinking-text {
    white-space: pre-wrap;
    word-break: break-word;
}

#thinking-panel.collapsed {
    width: 50px;
}

#thinking-panel.collapsed .thinking-header {
    writing-mode: vertical-rl;
    padding: 16px 8px;
    height: 100%;
}

#thinking-panel.collapsed .thinking-content {
    display: none;
}

#character-canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    position: relative;
}

#speech-bubble {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.95);
    color: #222;
    padding: 16px 28px;
    border-radius: 20px;
    font-size: 16px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

#speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 14px solid rgba(255,255,255,0.95);
}

#speech-bubble.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
    pointer-events: none;
}

/* 聊天面板 */
#chat-panel {
    flex: 1;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 20px rgba(0,0,0,0.1);
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-type-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.chat-position {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.question-counter {
    font-size: 14px;
    color: #666;
}

.end-btn {
    background: #fff;
    color: #dc3545;
    border: 1px solid #dc3545;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.end-btn:hover {
    background: #dc3545;
    color: #fff;
}

/* 消息区域 */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant-message {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.message.assistant-message .message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.message.user-message .message-content {
    background: #e9ecef;
    color: #333;
    border-bottom-right-radius: 4px;
}

.message.assistant-message .message-content {
    background: #f8f9fa;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* AI流式显示 */
#ai-streaming {
    padding: 0 20px 20px;
}

#ai-streaming .message {
    max-width: 85%;
}

.streaming-text {
    display: inline;
}

.cursor-blink {
    animation: blink 1s infinite;
    color: #667eea;
    font-weight: bold;
}

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

/* 输入区域 */
#input-area {
    padding: 16px 20px;
    border-top: 1px solid #e9ecef;
    background: #fff;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.text-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 24px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    transition: border-color 0.3s ease;
}

.text-input:focus {
    outline: none;
    border-color: #667eea;
}

.send-btn, .mic-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102,126,234,0.4);
}

.mic-btn {
    background: #fff;
    color: #667eea;
    border: 2px solid #667eea;
}

.mic-btn:hover {
    background: #e7f5ff;
}

.mic-btn.listening {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.input-hint {
    font-size: 12px;
    color: #999;
    margin-top: 8px;
    text-align: center;
}

/* ==================== 报告页面 ==================== */
#report-page {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    padding: 20px;
    overflow-y: auto;
}

.report-container {
    background: rgba(255,255,255,0.98);
    border-radius: 24px;
    padding: 40px;
    max-width: 700px;
    width: 100%;
    max-height: 95vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.report-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    color: #1a1a2e;
    margin-bottom: 16px;
}

.report-meta {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.report-meta span:not(:last-child)::after {
    content: '|';
    margin-left: 8px;
    color: #ddd;
}

.report-score-section {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.score-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 10px 30px rgba(102,126,234,0.4);
}

.score-number {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}

.score-label {
    font-size: 14px;
    margin-top: 8px;
    opacity: 0.9;
}

.report-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.section-title.positive {
    color: #28a745;
    border-bottom-color: #28a745;
}

.section-title.negative {
    color: #dc3545;
    border-bottom-color: #dc3545;
}

.section-content {
    font-size: 15px;
    line-height: 1.8;
    color: #555;
}

.section-list {
    list-style: none;
    padding: 0;
}

.section-list li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 10px;
    font-size: 15px;
    line-height: 1.6;
    color: #555;
}

.section-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.report-actions {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

.restart-btn {
    padding: 14px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102,126,234,0.4);
}

/* ==================== 响应式布局 ==================== */
@media (max-width: 900px) {
    #interview-page {
        flex-direction: column;
    }

    #character-container {
        height: 40vh;
        flex: none;
    }

    #chat-panel {
        width: 100%;
        height: 60vh;
    }
}

@media (max-width: 600px) {
    .setup-container, .report-container {
        padding: 24px;
    }

    .setup-title, .report-title {
        font-size: 24px;
    }

    .option-cards {
        grid-template-columns: 1fr;
    }

    .option-card {
        display: flex;
        align-items: center;
        gap: 12px;
        text-align: left;
    }

    .option-icon {
        margin-bottom: 0;
    }

    .option-desc {
        display: none;
    }
}