/* ==================== 手机端优化 - 少儿教育AI对话应用 ==================== */

/* 重置基础样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    overflow-x: hidden;
}

/* 容器布局 - 手机端单列 */
.container {
    max-width: 100%;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 主应用容器 - 模拟手机屏幕 */
.app-container {
    background-color: #fff;
    border-radius: 25px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    min-height: 600px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 头部区域 */
.app-header {
    background-color: #667eea;
    color: white;
    padding: 25px 15px 15px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 5;
}

.app-header h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 连接状态区域 */
.connection-status-bar {
    background-color: #f8f9fa;
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 5;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6c757d;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #dc3545;
    transition: all 0.3s ease;
    animation: pulse 1.5s infinite;
}

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

.status-dot.online {
    background-color: #28a745;
}

.status {
    font-weight: 500;
}

.status.offline {
    color: #dc3545;
}

.status.listening {
    color: #28a745;
}

.status.speaking {
    color: #007bff;
}

.connect-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background-color: #667eea;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.connect-btn:hover {
    background-color: #5a6fd8;
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
}

/* 对话区域 - 核心聊天界面 */
.conversation {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #f5f7fa;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23e0e0e0' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2V6h4V4h-4zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    min-height: 0;
}

/* 消息气泡样式 */
.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease-out;
}

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

.message.user {
    align-self: flex-end;
    background-color: #667eea;
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.message.assistant {
    align-self: flex-start;
    background-color: #fff;
    color: #333;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 标签页区域 */
.tabs {
    display: flex;
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
    position: relative;
    z-index: 5;
}

.tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

/* 消息输入区域 */
.message-input-section {
    padding: 12px 15px;
    background-color: #fff;
    border-top: 1px solid #e9ecef;
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-top: auto;
}

.tab.active {
    color: #667eea;
    border-bottom: 2px solid #667eea;
}

.tab:hover {
    color: #5a6fd8;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 日志区域 - 手机端完全隐藏 */
#logContainer {
    display: none !important;
    height: 0;
    overflow: hidden;
}

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

.message-input input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

.message-input input:focus {
    border-color: #667eea;
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.message-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.message-input button:hover:not(:disabled) {
    background-color: #5a6fd8;
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
}

.message-input button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* 语音输入区域 */
.audio-controls {
    text-align: center;
    padding: 20px 0;
}

.record-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #dc3545;
    color: white;
    border: none;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.record-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.record-button:active::before {
    width: 120px;
    height: 120px;
}

.record-button.recording {
    background-color: #28a745;
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
    animation: recordingPulse 1s infinite;
}

@keyframes recordingPulse {
    0%, 100% {
        box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
    }
    50% {
        box-shadow: 0 8px 25px rgba(40, 167, 69, 0.6);
    }
}

.record-button:active {
    transform: scale(0.95);
}

.audio-visualizer {
    width: 100%;
    height: 60px;
    margin-top: 15px;
    background-color: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

/* 日志区域 - 手机端可折叠 */
#logContainer {
    max-height: 100px;
    overflow-y: auto;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 10px;
    font-size: 12px;
    position: relative;
    z-index: 5;
    display: none;
}

.log-entry {
    margin-bottom: 5px;
    padding: 5px 8px;
    border-radius: 4px;
}

.log-info {
    background-color: #e7f3ff;
    color: #0066cc;
}

/* 隐藏电脑端元素 */
.two-column-layout,
.mcp {
    display: none;
}

/* 加载状态 */
#scriptStatus {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 10px;
    font-size: 16px;
    z-index: 1000;
}

/* 响应式设计 - 确保在各种手机尺寸上都良好显示 */
@media (max-width: 480px) {
    .container {
        padding: 0;
    }
    
    .app-container {
        border-radius: 0;
        min-height: 100vh;
        max-height: 100vh;
    }
    
    .message {
        max-width: 85%;
        font-size: 14px;
    }
    
    .app-header {
        padding: 15px;
    }
    
    .record-button {
        width: 70px;
        height: 70px;
        font-size: 14px;
    }
}

/* 滚动条美化 */
.conversation::-webkit-scrollbar {
    width: 4px;
}

.conversation::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.conversation::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.conversation::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* 文件协议警告框样式 */
#fileProtocolWarning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    padding: 20px;
    text-align: center;
    overflow-y: auto;
}

#fileProtocolWarning h2 {
    color: #dc3545;
    margin-bottom: 20px;
    font-size: 18px;
}

#fileProtocolWarning p {
    margin-bottom: 15px;
    line-height: 1.5;
    color: #555;
}

#fileProtocolWarning ol {
    text-align: left;
    margin-bottom: 15px;
    padding-left: 20px;
}

#fileProtocolWarning li {
    margin-bottom: 10px;
    color: #555;
}

#fileProtocolWarning pre {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-family: 'Courier New', monospace;
    color: #007bff;
    word-break: break-all;
}

#fileProtocolWarning strong {
    color: #333;
}

/* 配置按钮样式 */
.config-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background-color: #667eea;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-left: auto;
}

.config-btn:hover {
    background-color: #5a6fd8;
}

/* 头部区域调整 */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.app-header h1 {
    margin: 0;
    font-size: 18px;
}

.app-header .config-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}

/* 配置弹窗样式 */
#configModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-in-out;
}

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

#configModal > div {
    background-color: white;
    border-radius: 15px;
    padding: 25px;
    width: 95%;
    max-width: 600px;
    margin: 20px auto;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    animation: slideIn 0.3s ease-in-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

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

#configModal h2 {
    font-size: 20px;
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

#configModal .section {
    margin-bottom: 25px;
}

#configModal .config-row {
    flex-direction: column;
    gap: 15px;
}

#configModal .config-item {
    width: 100%;
}

#configModal .config-item label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

#configModal .config-item input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

#configModal .config-item input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

#configModal .toggle-button {
    background-color: #667eea;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}

#configModal .toggle-button:hover {
    background-color: #5a6fd8;
}

#configModal .connection-status {
    font-size: 12px;
    color: #666;
    margin-left: 10px;
}

#configModal .status {
    margin-right: 8px;
}

#configModal .status.connected {
    color: #4caf50;
}