/**
 * AI私教板书版 - 基础样式
 * 设计规格：375px 宽度，竖屏手机界面
 */

/* 全局样式重置 */
* {
    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;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* 移动端容器 */
.mobile-container {
    position: relative; /* 为浮层提供定位基准 */
    width: 100%;
    max-width: 375px;
    height: 90vh;
    max-height: 812px;
    background: #f5f7fa;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 顶部标题栏 */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header-title {
    flex: 1;
}

.header-title h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 2px;
}

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

/* 对话区域 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 15px;
}

/* 消息气泡 */
.message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: messageSlideIn 0.3s ease;
}

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

.message.ai {
    align-items: flex-start;
}

.message.user {
    align-items: flex-end;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.message-bubble {
    max-width: 92%; /* 增加最大宽度，更好利用屏幕空间 */
    min-width: 200px;
    width: fit-content;
    padding: 15px 18px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-line;
    overflow-wrap: break-word;
}

/* 气泡内的列表紧凑化 */
.message-bubble ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin: 4px 0;
}

.message.ai .message-bubble {
    background: white;
    border: 1px solid #e0e6ed;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message-time {
    font-size: 12px;
    color: #999;
    padding: 0 5px;
}

/* 题目图片消息 */
.question-image {
    max-width: 100%;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.question-image:hover {
    transform: scale(1.02);
}

/* 输入区域 */
.input-area {
    background: white;
    border-top: 1px solid #e0e6ed;
    padding: 15px 20px 20px;
    flex-shrink: 0;
}

.input-area.hidden {
    display: none;
}

/* 上传区域 */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upload-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.upload-btn span:first-child {
    font-size: 24px;
}

.upload-hint {
    text-align: center;
    font-size: 13px;
    color: #999;
    margin: 0;
}

.example-buttons {
    display: flex;
    gap: 8px;
}

.example-btn {
    flex: 1;
    background: white;
    color: #667eea;
    border: 2px solid #e0e6ed;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.example-btn:hover {
    border-color: #667eea;
    background: #f0f3ff;
}

/* Check按钮组 */
.check-buttons {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    padding: 0 5px;
    animation: slideInUp 0.3s ease;
}

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

/* 理解确认按钮容器 */
.check-understanding-container,
.check-buttons {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    padding: 0 5px;
    animation: slideInUp 0.3s ease;
}

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

.check-btn {
    flex: 1;
    background: white;
    color: #333;
    border: 2px solid #e0e6ed;
    padding: 12px 8px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.check-btn:hover {
    border-color: #667eea;
    background: #f0f3ff;
    transform: translateY(-2px);
}

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

/* 主操作按钮（开始学习、查看总结） */
.primary-action-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    width: 100%;
}

.primary-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

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

/* 主操作按钮容器 */
.primary-action-container {
    margin: 20px 5px;
    animation: slideInUp 0.3s ease;
}

/* 悬浮题目按钮（已被进度条题目节点替代，隐藏） */
.question-float-btn {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    display: none !important; /* 隐藏，功能已被进度条题目节点替代 */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    color: white;
}

.question-float-btn.show {
    display: none !important; /* 确保不显示 */
}

.question-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.question-float-btn span:first-child {
    font-size: 24px;
    line-height: 1;
}

.question-float-btn .float-text {
    font-size: 11px;
    margin-top: 2px;
}

/* 题目图片浮层 - 只在手机容器内显示 */
.question-overlay {
    position: absolute; /* 改为absolute，相对于mobile-container定位 */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65); /* 降低透明度，从0.9改为0.65 */
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
    border-radius: 20px; /* 与容器边角一致 */
}

.question-overlay.show {
    display: flex;
}

.overlay-content {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-content img {
    max-width: 90%;
    max-height: 80%;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* 文字内容浮层 */
.overlay-text {
    max-width: 90%;
    max-height: 80%;
    overflow-y: auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color: #1f2937;
    font-size: 15px;
    line-height: 1.8;
    white-space: pre-wrap;
}

.overlay-text::-webkit-scrollbar {
    width: 6px;
}

.overlay-text::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.overlay-text::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.overlay-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.overlay-close:hover {
    transform: scale(1.1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* AI思考中的气泡提示 */
.thinking-bubble {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: messageSlideIn 0.3s ease;
}

.thinking-bubble .message-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
}

.thinking-animation {
    display: flex;
    gap: 4px;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: thinkingBounce 1.4s infinite ease-in-out;
}

.thinking-dot:nth-child(1) {
    animation-delay: 0s;
}

.thinking-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinkingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 数学公式样式优化 */
.message-bubble mjx-container {
    margin: 8px 0;
}

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

.chat-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

/* 响应式调整 */
@media (max-width: 375px) {
    body {
        padding: 10px;
    }
    
    .mobile-container {
        border-radius: 15px;
    }
    
    .chat-container {
        padding: 15px;
    }
    
    .message-bubble {
        font-size: 14px;
    }
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 按钮禁用状态 */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* 小问选择按钮 */
.sub-question-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    margin: 10px 0;
}

.sub-question-btn {
    background: white;
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 12px 15px;
    font-size: 15px;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sub-question-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.sub-question-btn .sq-number {
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}

.sub-question-btn .sq-summary {
    flex: 1;
    line-height: 1.4;
}

/* 学完一问后的选择按钮 */
.after-question-choice {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    margin: 10px 0;
}

.after-question-choice .choice-btn {
    background: white;
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 15px;
    color: #667eea;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.after-question-choice .choice-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.after-question-choice .choice-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.after-question-choice .choice-btn.primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

