:root {
    --primary-gradient: linear-gradient(135deg, #6e8efb 0%, #4a6cf7 100%);
    --secondary-gradient: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    --ai-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --user-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --dark-color: #1a1a2e;
    --light-color: #f8f9fa;
    --card-bg: rgba(255, 255, 255, 0.9);
    --glass-effect: rgba(255, 255, 255, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@font-face {
    font-family: 'MapleMono';
    src: url('MapleMono-NF-CN-Regular.ttf') format('truetype');
}

* {
    font-family: 'MapleMono', sans-serif;
    font-size: 900;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'MapleMono', sans-serif;
    font-size: 900;
    line-height: 1.6;
    color: #333;
    background: url('background.png') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    overflow-x: hidden; /* 隐藏水平滚动条 */
}

.chat-container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-effect);
}

.chat-header {
    background: var(--ai-gradient);
    color: white;
    padding: 18px 30px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-content {
    display: flex;
    align-items: center;
}

.chat-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4cc9f0 0%, #f72585 50%, #4895ef 100%);
}

.chat-header .logo {
    display: flex;
    align-items: center;
}

.chat-header .logo i {
    margin-right: 12px;
    font-size: 1.8rem;
    color: rgba(255, 255, 255, 0.9);
}

.chat-header .status {
    font-size: 0.9rem;
    font-weight: 400;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 1.5s infinite;
}

.chat-messages {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    background-color: rgba(248, 249, 250, 0.7);
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 20px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn 0.4s ease forwards;
    box-shadow: var(--shadow-sm);
    line-height: 1.6;
    font-size: 1.05rem;
}

pre {
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.5;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background: var(--user-gradient);
    color: white;
    margin-left: auto;
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.bot-message {
    background: white;
    margin-right: auto;
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.bot-message::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--ai-gradient);
}

.message-time {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 8px;
    text-align: right;
}

.bot-message .message-time {
    color: rgba(0, 0, 0, 0.5);
}

.chat-input-container {
    padding: 18px 25px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background-color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn 0.3s ease forwards;
    box-shadow: var(--shadow-sm);
    line-height: 1.5;
}

pre {
    white-space: pre-wrap;
}

#user-input {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-lg);
    outline: none;
    font-size: 1rem;
    transition: var(--transition);
    background: rgba(248, 249, 250, 0.8);
    box-shadow: var(--shadow-sm);
}

#user-input:focus {
    box-shadow: 0 0 0 3px rgba(110, 142, 251, 0.3);
}

#send-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

#send-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#send-btn:active {
    transform: translateY(0);
}

#send-btn i {
    margin-left: 8px;
    font-size: 1rem;
}

.typing-indicator {
    display: none;
    padding: 14px 20px;
    background: white;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    width: fit-content;
    border-top-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.typing-indicator::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--ai-gradient);
}

.typing-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #6e8efb;
    margin: 0 3px;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
    background-color: #a18cd1;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
    background-color: #fbc2eb;
}

@keyframes typingAnimation {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(110, 142, 251, 0.5);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(110, 142, 251, 0.7);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .chat-header {
        padding: 15px 20px;
        font-size: 1.2rem;
    }

    .chat-messages {
        padding: 15px;
    }

    .message {
        max-width: 90%;
        padding: 12px 16px;
        font-size: 1rem;
    }

    .chat-input-container {
        padding: 15px;
    }

    #user-input {
        padding: 12px 16px;
    }

    #send-btn {
        padding: 12px 18px;
    }
}

/* 加载动画 */
@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.loading {
    animation: pulse 1.5s infinite ease-in-out;
}

/* Markdown样式 */
.message strong {
    font-weight: 700;
}

.message em {
    font-style: italic;
}

.bot-message pre {
    border-left: 3px solid #6e8efb;
}

.message ul,
.message ol {
    padding-left: 22px;
    margin: 10px 0;
}

.message li {
    margin-bottom: 6px;
}

.message a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.message a:hover {
    opacity: 0.8;
}

/* 特殊消息样式 */
.welcome-message {
    background: var(--ai-gradient);
    color: white;
    text-align: center;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.suggestion {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.suggestion:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* 打字机效果 */
.typewriter {
    overflow: hidden;
    border-right: 2px solid #6e8efb;
    white-space: nowrap;
    margin: 0 auto;
    letter-spacing: 0.15em;
    animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0
    }

    to {
        width: 100%
    }
}

@keyframes blink-caret {

    from,
    to {
        border-color: transparent
    }

    50% {
        border-color: #6e8efb;
    }
}

/* 新增的闪烁光标样式 */
.typing-cursor {
    display: inline-block;
    width: 1em;
    height: 1em;
    border-radius: 100%;
    background-color: #000000;
    vertical-align: middle;
    margin-left: 2px;
    animation: blink 0.7s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* 汉堡菜单按钮 */
.menu-btn {
    cursor: pointer;
    font-size: 1.2rem;
    margin-left: 15px;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.menu-popup {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100%;
    background: white;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.menu-popup.show {
    transform: translateX(0);
}

.menu-header {
    padding: 20px;
    background: var(--ai-gradient);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.close-btn {
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
}

.questions-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.question-item {
    padding: 12px 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.question-item:hover {
    background: #e9ecef;
}


.knowledge-status {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
}

.status-title {
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
}

#knowledge-status-list {
    max-height: 150px;
    overflow-y: auto;
    padding: 5px;
}

.knowledge-item {
    padding: 6px 10px;
    background: white;
    border-radius: 6px;
    margin-bottom: 5px;
    border-left: 3px solid #6e8efb;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}

.knowledge-name {
    font-weight: 500;
}

.knowledge-count {
    background: rgba(110, 142, 251, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
}

.knowledge-error {
    border-left: 3px solid #f87171;
}

.error-message {
    color: #f87171;
    font-size: 0.8rem;
    margin-top: 2px;
}