/* ============================================================
   Rusminlab 口语检测 · 嵌入式样式
   路径: /var/www/rusminlab/frontend/oral_test.css
   设计原则:
   - 完全嵌入到 #testContentArea，不创建任何独立弹窗
   - 复用现有 .comp-config 等样式做配置态
   - 对话态聊天区居中，最大宽度 520px 模仿微信
   - 评分抽屉：桌面浮于聊天右侧，不压缩对话宽度；移动端底部抽屉
   ============================================================ */

/* ============== 对话主容器 ============== */
.oral-chat-host {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 480px;
    position: relative;
    background: #f8fafc;
    border-radius: 12px;
    overflow: hidden;
}

.oral-chat-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
}
.oral-chat-back, .oral-chat-icon-btn {
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #64748b;
}
.oral-chat-back:hover, .oral-chat-icon-btn:hover { background: #f1f5f9; color: #0f172a; }
.oral-chat-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}
.oral-chat-progress {
    background: #eef2ff;
    color: #4338ca;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

/* ============== 聊天滚动区 ============== */
.oral-chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* 气泡 */
.oral-bubble {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    max-width: 100%;
    animation: oralBubbleIn 0.25s ease;
}
.oral-bubble.user { flex-direction: row-reverse; }

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

.oral-bubble-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #e2e8f0;
}
.oral-avatar-fallback {
    background: linear-gradient(135deg, #818cf8, #6366f1);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.oral-bubble-content {
    max-width: 78%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.55;
    color: #0f172a;
    word-wrap: break-word;
    word-break: break-word;
    position: relative;
}
.oral-bubble.ai .oral-bubble-content {
    background: #fff;
    border: 1px solid #f1f5f9;
}
.oral-bubble.user .oral-bubble-content {
    background: #dbeafe;
    color: #1e3a8a;
}

.oral-bubble-ru { word-break: break-word; }
.oral-bubble-zh {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
    font-style: italic;
}
.oral-bubble.user .oral-bubble-zh { color: #6366f1; opacity: 0.7; }

.oral-bubble-tools {
    margin-top: 6px;
    display: flex;
    gap: 6px;
}
.oral-bubble-tool {
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f8fafc;
    color: #64748b;
    font-size: 11px;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.oral-bubble-tool:hover { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }

/* "换一句"按钮：与"朗读"风格一致，仅 hover 时偏紫色提示这是更换操作 */
.oral-bubble-tool-regen[data-loading="1"] {
    cursor: wait;
}
.oral-bubble-tool-regen:hover {
    background: #f5f3ff;
    color: #6d28d9;
    border-color: #ddd6fe;
}

/* ============== 评分胶囊（用户气泡下方） ============== */
.oral-bubble-pills {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.oral-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 9px;
    background: #fff;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    transition: all 0.15s;
    user-select: none;
}
.oral-pill:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.oral-pill-num {
    font-weight: 700;
    font-size: 12px;
    color: #94a3b8;
}
.oral-pill-label {
    color: #64748b;
}

.oral-pill.loading .oral-pill-num {
    animation: oralPulseDot 1s ease-in-out infinite;
}
@keyframes oralPulseDot {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.oral-pill.good .oral-pill-num { color: #10b981; }
.oral-pill.mid .oral-pill-num { color: #f59e0b; }
.oral-pill.bad .oral-pill-num { color: #ef4444; }
.oral-pill.error .oral-pill-num { color: #94a3b8; }

/* ============== 建议卡（自由版） ============== */
.oral-suggest-card {
    background: #fef3c7;
    border: 1px dashed #f59e0b;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 4px 0;
    align-self: center;
    max-width: 80%;
}
.oral-suggest-header {
    font-size: 11px;
    color: #92400e;
    font-weight: 600;
    margin-bottom: 4px;
}
.oral-suggest-ru {
    font-size: 14px;
    color: #78350f;
    margin-bottom: 2px;
}
.oral-suggest-zh {
    font-size: 12px;
    color: #a16207;
    font-style: italic;
}

/* ============== 当前目标提示条 ============== */
.oral-target-bar {
    flex: 0 0 auto;
    padding: 8px 16px;
    background: linear-gradient(180deg, transparent, rgba(254, 243, 199, 0.6));
    border-top: 1px dashed #fbbf24;
    font-size: 13px;
    color: #78350f;
    display: flex;
    align-items: center;
    gap: 8px;
}
.oral-target-emoji { font-size: 16px; }
.oral-target-text { flex: 1; }

/* ============== 录音底栏 ============== */
.oral-mic-row {
    flex: 0 0 auto;
    padding: 12px 16px 14px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.oral-mic-status {
    flex: 1 0 100%;
    text-align: center;
    font-size: 12px;
    color: #64748b;
    min-height: 14px;
    margin-bottom: 4px;
}
.oral-mic-button {
    flex: 1;
    padding: 12px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border: 0;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
}
.oral-mic-button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.oral-mic-button.recording {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    animation: oralMicPulse 1.4s ease-in-out infinite;
}
@keyframes oralMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.oral-suggest-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    color: #92400e;
}
.oral-suggest-btn:hover { background: #fde68a; }

/* ============== 评分抽屉（桌面：浮于右侧 / 移动：底部） ============== */
.oral-score-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    background: #fff;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    z-index: 10;
    border-left: 1px solid #e2e8f0;
}
.oral-score-panel[data-open="1"] { transform: translateX(0); }

.oral-score-panel-header {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
}
.oral-score-panel-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}
.oral-score-panel-close {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    color: #64748b;
}
.oral-score-panel-close:hover { background: #f1f5f9; color: #0f172a; }

.oral-score-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}

/* Tabs */
.oral-score-tabs {
    display: flex;
    border-bottom: 1px solid #f1f5f9;
    margin: -14px -16px 14px;
    padding: 0 16px;
}
.oral-score-tab {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #64748b;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.oral-score-tab.active {
    color: #4f46e5;
    border-color: #4f46e5;
    font-weight: 600;
}

/* 原句对照卡 */
.oral-diff-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
}
.oral-diff-row {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 4px;
    word-break: break-word;
}
.oral-diff-row:last-child { margin-bottom: 0; }
.oral-diff-label {
    color: #94a3b8;
    margin-right: 6px;
    font-size: 11px;
}
.oral-diff-text { color: #0f172a; }

/* 综合评分块 */
.oral-score-summary {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
}
.oral-score-num {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
}
.oral-score-num.good { background: linear-gradient(135deg, #34d399, #10b981); }
.oral-score-num.mid { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.oral-score-num.bad { background: linear-gradient(135deg, #f87171, #ef4444); }

.oral-score-bars-mini { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.oral-mini-bar { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #475569; }
.oral-mini-bar-label { width: 44px; flex-shrink: 0; }
.oral-mini-bar-track {
    flex: 1;
    height: 5px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}
.oral-mini-bar-fill {
    display: block;
    height: 100%;
    background: #10b981;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.oral-mini-bar-num { width: 24px; text-align: right; font-weight: 600; color: #0f172a; }

/* 录音对照按钮 */
.oral-playback-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.oral-playback-mini {
    padding: 8px;
    background: #f1f5f9;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    color: #475569;
}
.oral-playback-mini:hover { background: #e2e8f0; }

.oral-soft-feedback {
    background: #ecfdf5;
    color: #065f46;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 8px;
}

/* 语法块 */
.oral-grammar-block { padding: 4px 0; text-align: center; }
.oral-grammar-comment {
    font-size: 13px;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 14px;
    text-align: left;
}
.oral-error-title {
    font-size: 12px;
    color: #475569;
    font-weight: 600;
    margin: 10px 0 6px;
    text-align: left;
}
.oral-error-item {
    background: #fef2f2;
    border-left: 3px solid #ef4444;
    padding: 8px 10px;
    border-radius: 0 6px 6px 0;
    margin-bottom: 6px;
    text-align: left;
}
.oral-error-row { font-size: 13px; }
.oral-error-wrong { color: #dc2626; text-decoration: line-through; word-break: break-word; }
.oral-error-arrow { color: #94a3b8; margin: 0 6px; }
.oral-error-right { color: #059669; font-weight: 600; word-break: break-word; }
.oral-error-reason { font-size: 12px; color: #64748b; margin-top: 4px; line-height: 1.5; }

/* ============== 移动端：评分抽屉变底部抽屉 ============== */
@media (max-width: 768px) {
    .oral-score-panel {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70%;
        max-height: 480px;
        transform: translateY(100%);
        border-left: 0;
        border-top: 1px solid #e2e8f0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
    }
    .oral-score-panel[data-open="1"] { transform: translateY(0); }
    .oral-bubble-content { font-size: 14px; max-width: 82%; }
    .oral-bubble-avatar { width: 28px; height: 28px; }
    .oral-chat-scroll { padding: 12px; }
}

/* ============== 桌面：聊天最大宽度限制（微信感） ============== */
@media (min-width: 769px) {
    .oral-chat-scroll > .oral-bubble,
    .oral-chat-scroll > .oral-suggest-card {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
        width: 100%;
    }
    .oral-chat-scroll > .oral-bubble.ai { /* 保持左对齐 */ }
}

/* ============== 历史回看卡片 ============== */
.oral-history-card:hover {
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}
.oral-pill.history-pill {
    cursor: pointer;
}

/* ============== 历史导出按钮 ============== */
.oral-chat-icon-btn[title="导出对话"]:hover {
    background: #fef3c7;
    color: #92400e;
}

/* peeked 标记 */
.oral-bubble.user .oral-bubble-content > div[style*="color:#a16207"] {
    margin-top: 4px;
}
