/* ============================================
   AI 教育游戏工坊 - 公共样式
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   对话大厅页面
   ============================================ */

.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

.chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(102,126,234,0.3);
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.new-game-btn {
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f7fa;
}

.message {
    margin-bottom: 16px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.assistant .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

/* Markdown 样式 */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    margin: 10px 0 8px;
    font-weight: 600;
}

.message-bubble h1 { font-size: 18px; }
.message-bubble h2 { font-size: 16px; }
.message-bubble h3 { font-size: 15px; }

.message-bubble p {
    margin-bottom: 8px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

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

.message-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 13px;
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble a {
    color: #667eea;
    text-decoration: underline;
}

.message.user .message-bubble a {
    color: white;
}

/* 游戏链接卡片 */
.game-link-card {
    margin-top: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
    border-radius: 12px;
    border: 1px solid #c7d2fe;
}

.game-link-card .game-title {
    font-size: 16px;
    font-weight: 600;
    color: #4338ca;
    margin-bottom: 6px;
}

.game-link-card .game-desc {
    font-size: 13px;
    color: #6366f1;
    margin-bottom: 12px;
}

.game-link-card .open-game-btn {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* 输入区域 */
.chat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 15px;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #667eea;
}

.send-btn {
    padding: 0 20px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 22px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

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

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 加载中动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

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

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.welcome-title {
    font-size: 18px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
}

.welcome-desc {
    font-size: 14px;
    color: #999;
    line-height: 1.6;
}

/* ============================================
   游戏页面 - 顶部工具栏
   ============================================ */

.game-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.game-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.back-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.game-title-bar {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.game-toolbar-right {
    display: flex;
    gap: 8px;
}

.tool-btn {
    padding: 6px 12px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tool-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

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

.game-iframe-container {
    position: fixed;
    top: 53px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

.game-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* 底部版本信息条 */
.version-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    z-index: 99;
}

/* ============================================
   弹窗 (Modal)
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

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

.modal-title {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* 版本列表项 */
.version-item {
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.version-item:last-child {
    border-bottom: none;
}

.version-info {
    flex: 1;
    min-width: 0;
}

.version-number {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.version-number .current-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: #e0e7ff;
    color: #4338ca;
    font-size: 11px;
    border-radius: 10px;
    font-weight: 500;
}

.version-desc {
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
    line-height: 1.5;
}

.version-meta {
    font-size: 12px;
    color: #999;
}

.switch-version-btn {
    padding: 6px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.switch-version-btn:hover {
    opacity: 0.9;
}

.switch-version-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   侧边 AI 助手面板
   ============================================ */

.ai-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    background: white;
    z-index: 300;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}

.ai-panel.open {
    right: 0;
}

.ai-panel-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-panel-title {
    font-size: 16px;
    font-weight: 600;
}

.ai-panel-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 16px;
}

.ai-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f7fa;
}

.ai-panel-input {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

/* ============================================
   对话历史页面
   ============================================ */

.chat-history-page {
    max-width: 800px;
    margin: 0 auto;
    background: #f5f7fa;
    min-height: 100vh;
}

.history-header {
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-title {
    font-size: 17px;
    font-weight: 600;
}

.history-messages {
    padding: 20px;
}

/* ============================================
   响应式
   ============================================ */

@media (max-width: 480px) {
    .chat-header h1 {
        font-size: 16px;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 14px;
    }
    
    .modal {
        max-height: 85vh;
    }
}
