/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS变量定义 */
:root {
    --safe-area-bottom: 0px;
    --safe-area-top: 0px;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: #faeaf5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    padding-top: var(--safe-area-top);
    overflow: hidden;
}

.container {
    width: 100%;
    max-width: 800px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #ff9acc 0%, #ffcaf8 100%);
    color: white;
    text-align: center;
    padding: 10px;
}

header h1 {
    font-weight: 500;
    font-size: 1.8rem;
}

/* 聊天容器 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    width: 100%;
}

/* 聊天头部 */
.chat-header {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.avatar img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #ff9acc;
}

.info {
    margin-left: 15px;
    flex: 1;
}

.info h2 {
    color: #333;
    font-size: 1.3rem;
    font-weight: 500;
}

.info p {
    color: #666;
    font-size: 0.9rem;
    margin-top: 5px;
}

.header-actions {
    display: flex;
    align-items: center;
}

.clear-btn {
    padding: 8px 15px;
    background: linear-gradient(135deg, #ff9acc 0%, #ffcaf8 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.clear-btn:hover {
    transform: translateY(-2px);
}

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

/* 消息区域 */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fafafa;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.3s ease-in;
}

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

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

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

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, #ff9acc 0%, #ffcaf8 100%);
    color: white;
    border-bottom-right-radius: 5px;
}

.ai-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #eee;
    border-bottom-left-radius: 5px;
}

.message-time {
    font-size: 0.7rem;
    color: #999;
    margin-top: 5px;
}

.user-message .message-time {
    align-self: flex-end;
}

.ai-message .message-time {
    align-self: flex-start;
}

/* 输入区域 */
.chat-input {
    padding: 20px;
    padding-bottom: calc(20px + var(--safe-area-bottom));
    background: white;
    border-top: 1px solid #eee;
}

#chat-form {
    display: flex;
    gap: 10px;
}

#message-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #eee;
    border-radius: 25px;
    outline: none;
    font-size: 1rem;
    transition: border-color 0.3s;
}

#message-input:focus {
    border-color: #ff9acc;
}

button[type="submit"] {
    padding: 12px 20px;
    background: linear-gradient(135deg, #ff9acc 0%, #ffcaf8 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s;
}

button[type="submit"]:hover {
    transform: translateY(-2px);
}

button[type="submit"]:active {
    transform: translateY(0);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .container {
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        margin-top: var(--safe-area-top);
    }
    
    header {
        display: none;
    }
    
    main {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .chat-container {
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .chat-header {
        padding: 15px;
        padding-top: calc(15px + var(--safe-area-top));
    }
    
    .chat-messages {
        flex: 1;
        padding: 15px;
    }
    
    .chat-input {
        padding: 15px;
        padding-bottom: calc(15px + var(--safe-area-bottom));
    }
    
    .message {
        max-width: 90%;
    }
    
    .avatar img {
        width: 50px;
        height: 50px;
    }
    
    .info h2 {
        font-size: 1.2rem;
    }
}