:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #4895ef;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --success-color: #4cc9f0;
    --warning-color: #f72585;
    --gray-color: #adb5bd;
    --white-color: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'SF Pro Display', -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    touch-action: none;
    background-color: #292a2d;
    background-image: url(/img/2025.webp);
    /*background-image: url(https://www.cangbaolou.com/wp-custom/api/img/api.php);*/
}

body {
    /*background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);*/
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 0;
}

.chat-container {
    width: 100%;
    height: 100vh;
    max-width: 100%;
    background-color: var(--white-color);
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.chat-header {
    padding: 12px 15px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    text-align: center;
    position: relative;
    flex-shrink: 0;
    min-height: 60px;
    -webkit-app-region: drag;
}

.chat-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.chat-header .status {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.9);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #4ade80;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 1.5s infinite;
}

.menu-container {
    padding: 8px 10px;
    background-color: var(--white-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.menu-item {
    padding: 8px 4px;
    background-color: var(--white-color);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    color: var(--dark-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    min-height: 45px;
    touch-action: manipulation;
}

.desktop-menu-item {
    padding: 10px 12px;
    background-color: var(--white-color);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    color: var(--dark-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.menu-item:hover, .desktop-menu-item:hover {
    background-color: rgba(67, 97, 238, 0.05);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(67, 97, 238, 0.1);
}

.menu-item span {
    font-size: 14px;
    margin-bottom: 2px;
}

.chat-box {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background-color: var(--light-color);
    display: flex;
    flex-direction: column;
    background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.05) 1px, transparent 0);
    background-size: 15px 15px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.message {
    margin-bottom: 12px;
    position: relative;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}

.message.visible {
    opacity: 1;
}

.user-message {
    align-self: flex-end;
    align-items: flex-end;
    max-width: 85%;
}

.bot-message {
    align-self: flex-start;
    align-items: flex-start;
    max-width: 85%;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.user-message .message-header {
    flex-direction: row-reverse;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.user-message .avatar {
    margin-right: 0;
    margin-left: 8px;
    box-shadow: 0 1px 3px rgba(67, 97, 238, 0.3);
}

.nickname {
    font-weight: 600;
    font-size: 13px;
    margin-right: 8px;
}

.user-message .nickname {
    color: var(--primary-color);
    margin-right: 0;
    margin-left: 8px;
}

.bot-message .nickname {
    color: var(--dark-color);
}

.time {
    font-size: 11px;
    color: var(--gray-color);
}

.user-message .time {
    margin-right: 8px;
}

.message-text {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    word-wrap: break-word;
    white-space: normal;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
    box-sizing: border-box;
    max-width: 100%;
    min-width: 60px; /* 设置最小宽度，避免太短的消息显得太空 */
}

.user-message .message-text {
    background-color: var(--white-color);
    color: var(--dark-color);
    /*border-bottom-right-radius: 4px;*/ /* 用户消息右下角稍微小圆角 */
}

.bot-message .message-text {
    background-color: var(--white-color);
    color: var(--dark-color);
    /*border-bottom-left-radius: 4px;*/ /* 机器人消息左下角稍微小圆角 */
}

.bot-message .message-text::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 10px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-right: 8px solid var(--white-color);
    border-bottom: 8px solid transparent;
}

.user-message .message-text::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 10px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-left: 8px solid var(--white-color);
    border-bottom: 8px solid transparent;
}

/* 消息加载指示器样式 - 集成到消息框中 */
.message-loading {
    display: inline-block;
    padding: 0 8px;
}

.loading-dots {
    display: flex;
    align-items: center;
}

.loading-dots span {
    height: 8px;
    width: 8px;
    background-color: var(--gray-color);
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    opacity: 0.6;
}

.loading-dots span:nth-child(1) {
    animation: loading 1.4s infinite;
}

.loading-dots span:nth-child(2) {
    animation: loading 1.4s infinite 0.2s;
}

.loading-dots span:nth-child(3) {
    animation: loading 1.4s infinite 0.4s;
}

.input-container {
    display: flex;
    padding: 10px;
    background-color: var(--white-color);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    flex-shrink: 0;
    will-change: transform;
    backface-visibility: hidden;
}

#user-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    margin-right: 10px;
    transition: all 0.3s;
    background-color: var(--light-color);
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    touch-action: manipulation;
}

#user-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

#send-btn {
    padding: 0 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(67, 97, 238, 0.2);
    white-space: nowrap;
    min-width: 60px;
    touch-action: manipulation;
}

#send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(67, 97, 238, 0.3);
}

#send-btn:active {
    transform: translateY(0);
}

/* 移除旧的独立输入指示器样式 */
.typing-indicator {
    display: none;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

@keyframes loading {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

/* 防止双击缩放 */
* {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* 手机端样式 */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .chat-header {
        padding: 10px 12px;
        min-height: 50px;
    }
    
    .chat-header h2 {
        font-size: 1.1rem;
    }
    
    .menu-container {
        padding: 6px 8px;
    }
    
    .menu-grid {
        gap: 4px;
    }
    
    .menu-item {
        padding: 6px 3px;
        font-size: 11px;
        border-radius: 6px;
        min-height: 40px;
    }
    
    .menu-item span {
        font-size: 12px;
    }
    
    .chat-box {
        padding: 8px;
        padding-bottom: 70px;
    }
    
    .message {
        margin-bottom: 10px;
        max-width: 90%;
    }
    
    .avatar {
        width: 30px;
        height: 30px;
    }
    
    .nickname {
        font-size: 12px;
    }
    
    .time {
        font-size: 10px;
    }
    
    .message-text {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 14px;
        min-width: 50px;
    }
    
    .input-container {
        padding: 8px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: var(--white-color);
        z-index: 100;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        padding-top: 8px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
    
    #user-input {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 18px;
        margin-bottom: 0;
    }
    
    #send-btn {
        padding: 0 16px;
        font-size: 13px;
        border-radius: 18px;
        min-width: 55px;
        margin-bottom: 0;
    }
    
    .desktop-menu {
        display: none;
    }
    
    .mobile-menu {
        display: block;
    }
}

/* 电脑端样式 */
@media (min-width: 769px) {
    body {
        padding: 15px;
    }
    
    .chat-container {
        height: 90vh;
        border-radius: 16px;
        position: relative;
        max-width: 1000px;
        padding-bottom: 0;
    }
    
    .desktop-menu {
        display: block;
    }
    
    .mobile-menu {
        display: none;
    }
    
    .input-container {
        box-shadow: none;
    }
    
    .user-message {
        max-width: 75%;
    }
    
    .bot-message {
        max-width: 75%;
    }
}

/* 防止弹性滚动 */
.chat-box::-webkit-scrollbar {
    display: none;
}

.chat-box {
    -ms-overflow-style: none;
    scrollbar-width: none;
}