:root {
    --primary-color: #3a86ff;
    --primary-hover: #2667cc;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #ff4d6d;
    --light-color: #f8f9fa;
    --dark-color: #1a1a2e;
    --text-color: #e2e2e2;
    --text-dark: #333;
    --bg-color: #16213e;
    --bg-secondary: #0f3460;
    --border-color: #2a3a5e;
    --highlight-color: rgba(58, 134, 255, 0.2);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius: 10px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --tech-gradient: linear-gradient(135deg, #3a86ff 0%, #8338ec 100%);
}

[data-theme="light"] {
    --primary-color: #3a86ff;
    --primary-hover: #2667cc;
    --text-color: #333;
    --text-dark: #111;
    --bg-color: #f8f9fa;
    --bg-secondary: #e9ecef;
    --border-color: #dee2e6;
    --highlight-color: rgba(58, 134, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

body {
    background-color: var(--bg-secondary);
    color: var(--text-color);
    transition: var(--transition);
    line-height: 1.6;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 科技感语言切换器 */
#language-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    display: flex;
    gap: 10px;
    background: rgba(15, 52, 96, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 5px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.lang-btn {
    padding: 8px 15px;
    border: none;
    background: transparent;
    color: var(--text-color);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    font-weight: 500;
}

.lang-btn.active {
    background: rgba(58, 134, 255, 0.2);
    color: white;
}

.lang-btn.active .lang-globe {
    color: var(--primary-color);
}

.lang-globe {
    transition: var(--transition);
    font-size: 0.9rem;
}

/* 科技感模态框 */
.modal {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 25, 47, 0.9);
    backdrop-filter: blur(5px);
    z-index: 1000;
}

.card {
    background-color: var(--bg-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    border: 1px solid var(--border-color);
    max-width: 420px;
    width: 90%;
}

.modal-header {
    padding: 2rem 1.5rem 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.tech-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(90deg, var(--bg-color) 15px, transparent 1%) center,
        linear-gradient(var(--bg-color) 15px, transparent 1%) center,
        var(--primary-color);
    background-size: 16px 16px;
    opacity: 0.05;
}

.tech-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.tech-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-color);
    opacity: 0.6;
}

.modal-header h2 {
    color: white;
    margin: 15px 0 0;
    font-size: 1.5rem;
    font-weight: 600;
    position: relative;
    background: var(--tech-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 10px rgba(58, 134, 255, 0.3);
}

.modal-body {
    padding: 1.5rem;
    position: relative;
}

.modal-body p {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 0.95rem;
}

.input-container {
    position: relative;
    margin: 1rem 0;
}

.input-container input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: rgba(15, 52, 96, 0.3);
    color: var(--text-color);
    transition: var(--transition);
    font-size: 1rem;
    backdrop-filter: blur(5px);
}

.input-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(58, 134, 255, 0.3);
}

.input-highlight {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--tech-gradient);
    transition: var(--transition);
}

.input-container input:focus ~ .input-highlight {
    width: 100%;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.9rem;
    min-height: 1.2rem;
    margin: 0.5rem 0;
    text-align: center;
}

.modal-footer {
    padding: 0 1.5rem 2rem;
    display: flex;
    justify-content: center;
}

/* 科技感按钮 */
.btn-tech {
    position: relative;
    padding: 0.85rem 2rem;
    border: none;
    border-radius: var(--radius);
    background: var(--tech-gradient);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 15px rgba(58, 134, 255, 0.4);
    z-index: 1;
}

.btn-tech:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(58, 134, 255, 0.6);
}

.btn-tech:active {
    transform: translateY(0);
}

.btn-tech-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: var(--transition);
}

.btn-tech:hover .btn-tech-overlay {
    opacity: 1;
}

.btn-tech-shine {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(255, 255, 255, 0) 45%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0) 55%
    );
    transform: rotate(30deg);
    transition: var(--transition);
    z-index: 0;
}

.btn-tech:hover .btn-tech-shine {
    left: 100%;
}

.btn-icon {
    position: relative;
    z-index: 2;
    transition: var(--transition);
}

.btn-tech:hover .btn-icon {
    transform: translateX(3px);
}

/* 聊天容器 */
#chat-container {
    display: flex;
    height: 100vh;
    transition: var(--transition);
}

.hidden {
    display: none;
}

/* 侧边栏 */
#sidebar {
    width: 280px;
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: 600;
}

.tech-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--success-color);
    box-shadow: 0 0 10px var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

#user-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 0.75rem;
}

#user-list li {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 52, 96, 0.3);
    backdrop-filter: blur(5px);
    position: relative;
    overflow: hidden;
}

#user-list li:hover {
    background: rgba(58, 134, 255, 0.2);
}

#user-list li::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

/* 侧边栏底部版权信息 */
.sidebar-footer {
    padding: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    font-size: 0.7rem;
    color: var(--secondary-color);
    text-align: center;
    background: rgba(15, 52, 96, 0.3);
}

/* 聊天区域 */
#chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

#chat-area::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(90deg, var(--bg-secondary) 20px, transparent 1%) center,
        linear-gradient(var(--bg-secondary) 20px, transparent 1%) center,
        var(--primary-color);
    background-size: 22px 22px;
    opacity: 0.03;
    pointer-events: none;
}

/* 消息框优化部分 */
#messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* 改善移动端滚动 */
}

/* 基础消息样式 */
.message {
    max-width: 85%;
    min-width: 120px;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    background-color: var(--bg-color);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    position: relative;
    word-break: break-word;
    animation: fadeIn 0.3s ease-out;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
}

/* 消息左侧装饰线 */
.message::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--tech-gradient);
}

/* 元信息区域 - 确保用户名和时间始终可见 */
.message .meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.4rem;
    font-size: 0.82rem;
    gap: 0.8rem;
    flex-wrap: nowrap; /* 防止换行 */
    min-width: 100%; /* 确保占满容器 */
}

/* 用户名样式 */
.message .username {
    font-weight: 600;
    color: var(--primary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 60%; /* 限制最大宽度 */
}

/* 时间样式 */
.message .time {
    color: var(--secondary-color);
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-left: auto; /* 推到最右侧 */
}

/* 消息内容区域 - 确保内容自适应 */
.message .content {
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap; /* 保留换行和空格 */
    overflow-wrap: anywhere; /* 更智能的断词 */
    word-break: break-word; /* 确保长单词和URL换行 */
    width: 100%; /* 占满可用空间 */
}

/* 自己发送的消息 */
.message.self {
    align-self: flex-end;
    background-color: rgba(58, 134, 255, 0.15);
    border-color: rgba(58, 134, 255, 0.3);
}

/* 系统消息 */
.message.system {
    align-self: center;
    background-color: rgba(108, 117, 125, 0.15);
    border-color: rgba(108, 117, 125, 0.3);
    max-width: 90%;
    text-align: center;
}

/* 响应式调整 */
@media (max-width: 768px) {
    #messages {
        padding: 0.8rem;
    }
    
    .message {
        max-width: 92%;
        padding: 0.7rem 0.9rem;
    }
    
    .message .meta {
        font-size: 0.78rem;
        gap: 0.5rem;
    }
    
    .message .username {
        max-width: 55%;
    }
    
    .message .content {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 96%;
        padding: 0.6rem 0.8rem;
    }
    
    .message .meta {
        flex-direction: row; /* 保持水平排列 */
        align-items: center;
    }
    
    .message .username {
        max-width: 50%;
    }
    
    .message .time {
        font-size: 0.7rem;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    .message .meta {
        flex-wrap: wrap; /* 允许换行 */
    }
    
    .message .username,
    .message .time {
        max-width: 100%; /* 占满整行 */
    }
    
    .message .time {
        margin-left: 0;
        margin-top: 0.2rem;
    }
}

/* 长消息滚动提示 */
.long-message {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.long-message::-webkit-scrollbar {
    width: 4px;
}

.long-message::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 2px;
}

/* 打字指示器 */
.typing-indicator {
    display: inline-flex;
    padding: 0.5rem 1rem;
    background-color: rgba(15, 52, 96, 0.3);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    align-items: center;
    gap: 0.5rem;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}
/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    animation: fadeIn 0.3s ease-out;
}

@keyframes float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

.btn-tech:hover {
    animation: float 1.5s ease-in-out infinite;
}