/* 新设计 - 基于图1的移动优先设计 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* 主容器 */
.container {
    width: 100%;
    max-width: 400px;
    background: #e8f4fd;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* 页面标题 */
.page-header {
    text-align: center;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #1a73e8;
    margin: 0;
}

/* 智能体选择按钮区域 */
.agent-buttons {
    margin-bottom: 20px;
}

.agent-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.agent-item {
    background: white;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-align: center;
    min-width: 80px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-item:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.agent-item.active {
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
}

.agent-item.loading {
    background: #f0f0f0;
    border-color: #ccc;
    color: #999;
    cursor: not-allowed;
}

/* 聊天显示区域 */
.chat-messages {
    background: white;
    border: 2px solid #333;
    border-radius: 12px;
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
}

/* 自定义滚动条 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 消息样式 */
.message {
    margin-bottom: 15px;
    display: flex;
}

.message:last-child {
    margin-bottom: 0;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

/* 用户消息 */
.user-message {
    justify-content: flex-end;
}

.user-bubble {
    background: white;
    border: 1px solid #ddd;
    color: #333;
    border-bottom-right-radius: 5px;
}

.user-bubble::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-left-color: white;
    border-bottom-color: white;
}

/* AI助手消息 */
.assistant-message {
    justify-content: flex-start;
}

.assistant-bubble {
    background: #e8f5e8;
    border: 1px solid #c8e6c9;
    color: #333;
    border-bottom-left-radius: 5px;
}

.assistant-bubble::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-right-color: #e8f5e8;
    border-bottom-color: #e8f5e8;
}

/* 复制按钮 */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(26, 115, 232, 0.15);
    border: 1px solid rgba(26, 115, 232, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: #1a73e8;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    font-family: inherit;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

.assistant-bubble:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(26, 115, 232, 0.2);
    transform: translateY(-1px);
}

.copy-btn.copied {
    background: rgba(52, 168, 83, 0.15);
    border-color: rgba(52, 168, 83, 0.3);
    color: #34a853;
}

/* 清空对话按钮 */
.clear-button-container {
    text-align: center;
    margin-bottom: 15px;
}

.btn-clear {
    background: #ff6b35;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-clear:hover {
    background: #e55a2b;
    transform: translateY(-1px);
}

/* 输入区域 */
.input-section {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-section textarea {
    flex: 1;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 40px;
    max-height: 120px;
    background: white;
    color: #333;
}

.input-section textarea:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.1);
}

.input-section textarea:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.btn-send {
    background: #00d4aa;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.btn-send:hover:not(:disabled) {
    background: #00b894;
    transform: translateY(-1px);
}

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* 后台管理链接 */
.admin-link {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 16px;
    color: #666;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.admin-link:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    transform: scale(1.1);
}

/* 加载状态 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #666;
    font-size: 14px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #1a73e8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 欢迎消息样式 */
.welcome-message {
    text-align: center;
    padding: 20px 0;
    color: #666;
}

.welcome-message .message {
    justify-content: center;
    margin-bottom: 10px;
}

.welcome-message .message-bubble {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: #666;
    font-style: italic;
}

/* 响应式设计 - 桌面版 */
@media (min-width: 768px) {
    body {
        background: #f0f0f0;
        padding: 10px;
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .container {
        width: 95%;
        max-width: 700px;
        background: #e8f4fd;
        border-radius: 15px;
        padding: 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        gap: 15px;
        height: auto;
        max-height: 95vh;
    }
    
    .page-header h1 {
        font-size: 28px;
        margin-bottom: 0;
        text-align: center;
        color: #1a73e8;
    }
    
    .agent-list {
        gap: 10px;
        margin-bottom: 0;
        justify-content: center;
    }
    
    .agent-item {
        padding: 10px 18px;
        font-size: 14px;
        min-width: 100px;
        max-width: 180px;
        border-radius: 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .chat-messages {
        min-height: 300px;
        max-height: 350px;
        padding: 15px;
        margin-bottom: 0;
        border-radius: 12px;
        background: #f8f9ff;
    }
    
    .clear-button-container {
        margin-bottom: 0;
        text-align: center;
    }
    
    .btn-clear {
        padding: 8px 16px;
        font-size: 12px;
        border-radius: 8px;
    }
    
    .input-section {
        gap: 10px;
        align-items: flex-end;
    }
    
    .input-section textarea {
        padding: 12px;
        font-size: 14px;
        min-height: 45px;
        border-radius: 8px;
        flex: 1;
    }
    
    .btn-send {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 8px;
        white-space: nowrap;
    }
    
    .admin-link {
        top: 15px;
        right: 15px;
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
}

/* 大屏幕桌面版优化 */
@media (min-width: 1200px) {
    .container {
        max-width: 800px;
        padding: 25px;
        gap: 18px;
    }
    
    .page-header h1 {
        font-size: 32px;
        margin-bottom: 5px;
    }
    
    .agent-list {
        gap: 12px;
    }
    
    .agent-item {
        padding: 12px 22px;
        font-size: 15px;
        min-width: 110px;
    }
    
    .chat-messages {
        min-height: 350px;
        max-height: 400px;
        padding: 18px;
    }
    
    .input-section textarea {
        padding: 14px;
        font-size: 15px;
        min-height: 50px;
    }
    
    .btn-send {
        padding: 14px 24px;
        font-size: 15px;
    }
    
    .btn-clear {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
    
    .agent-list {
        gap: 6px;
    }
    
    .agent-item {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 70px;
    }
    
    .chat-messages {
        min-height: 250px;
        max-height: 300px;
        padding: 10px;
    }
    
    .input-section {
        gap: 8px;
    }
    
    .input-section textarea {
        padding: 8px;
        font-size: 14px;
    }
    
    .btn-send {
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* 横屏手机优化 */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
        max-width: 800px;
    }
    
    .page-header h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .agent-buttons {
        margin-bottom: 15px;
    }
    
    .chat-messages {
        min-height: 200px;
        max-height: 250px;
        margin-bottom: 10px;
    }
    
    .clear-button-container {
        margin-bottom: 10px;
    }
}