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

:root {
    --primary-color: #4A6CF7;
    --primary-hover: #3B5BD9;
    --secondary-color: #6B7280;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --bg-color: #F3F4F6;
    --white: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #F3F3F3;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== 聊天界面样式 ==================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    max-width: 100%;
    margin: 0;
    background: transparent;
    box-shadow: none;
    overflow: hidden;
}

/* 左侧信息栏 */
.sidebar {
    width: 240px;
    background: #F3F3F3;
    border-right: none;
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.company-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.company-logo i {
    font-size: 1.8rem;
    color: var(--primary-color);
}

.company-logo h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 400;
    font-size: 0.95rem;
}

.sidebar-link:hover {
    background: rgba(74, 108, 247, 0.1);
    color: var(--primary-color);
    transform: none;
    box-shadow: none;
}

.sidebar-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.sidebar-detail {
    padding: 0 14px;
}

.sidebar-detail p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.qrcode-container {
    margin-top: 8px;
}

.qrcode-placeholder {
    width: 140px;
    height: 140px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 auto;
}

.qrcode-placeholder i {
    font-size: 1.8rem;
    color: var(--secondary-color);
}

.qrcode-placeholder p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
}

/* 二维码图片 */
.qrcode-image {
    width: 140px;
    margin: 0 auto;
    text-align: center;
}

.qrcode-image img {
    width: 140px;
    height: 140px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.qrcode-image p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 10px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-footer p {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 4px;
}

/* 右侧聊天区域 */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #F3F3F3;
    padding: 8px;
}

/* 聊天内容容器 */
.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-radius: 6px;
    padding: 0px;
    min-height: 0; /* 确保flex容器正确处理子元素高度 */
}

/* 聊天头部 */
.chat-header {
    margin-bottom: 24px;
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366F1 100%);
    color: var(--white);
    padding: 16px 24px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 600;
}

.logo i {
    font-size: 1.6rem;
}

.header-stats {
    display: flex;
    gap: 20px;
}

.online-users {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* 聊天区域 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--white);
    scroll-behavior: smooth;
    min-height: 0; /* 确保flex容器正确处理子元素高度 */
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 960px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 12px;
    padding: 32px;
    box-shadow: none;
    /* 移除min-height，让内容根据容器高度自适应 */
}

/* 消息样式 */
.message {
    display: flex;
    gap: 16px;
    animation: messageIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message-ai .message-avatar {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366F1 100%);
    box-shadow: 0 4px 12px rgba(74, 108, 247, 0.3);
}

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

.message-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.3rem;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.message:hover .message-avatar {
    transform: scale(1.05);
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.message-bubble {
    padding: 18px 22px;
    border-radius: 20px;
    background: var(--white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    line-height: 1.6;
    font-size: 1rem;
    font-weight: 400;
    position: relative;
}

.message-user .message-bubble {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8db8f0 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(74, 108, 247, 0.3);
}

.message-bubble p {
    margin-bottom: 10px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.message:hover .message-time {
    opacity: 1;
}

.message-user .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.7);
}

/* 欢迎消息特殊样式 */
.welcome-message {
    text-align: center;
    padding: 40px 24px;
}

.welcome-content {
    max-width: 600px;
    margin: 0 auto;
}

.welcome-content h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.welcome-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* 常见问题 */
.common-questions {
    margin-bottom: 32px;
}

.questions-title {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-align: left;
}

.question-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 16px 20px;
    margin-bottom: 12px;
    background: #F5F5F5;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.question-btn:hover {
    background: #E8E8E8;
    transform: translateX(4px);
}

/* 欢迎页底部 */
.welcome-footer {
    margin-top: 32px;
}

.welcome-footer p {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 500;
}

.explore-btn {
    display: inline-block;
    padding: 12px 24px;
    background: transparent;
    border: none;
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.explore-btn:hover {
    text-decoration: underline;
    transform: translateY(-2px);
}

/* H5移动端隐藏常见问题 */
@media (max-width: 768px) {
    .common-questions {
        display: none;
    }
}

/* 媒体链接样式 */
.media-links {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* 媒体项样式 */
.media-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 120px;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.media-item:hover {
    transform: translateY(-4px);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

/* 媒体缩略图样式 */
.media-thumbnail {
    width: 120px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 视频缩略图 */
.video-thumbnail {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: var(--white);
}

.video-thumbnail i {
    font-size: 2rem;
    opacity: 0.8;
}

/* 图片缩略图 */
.image-thumbnail {
    background: #f8f9fa;
}

.image-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.media-item:hover .image-thumbnail img {
    transform: scale(1.05);
}

/* 媒体信息样式 */
.media-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.media-title {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-type {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--bg-color);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    align-self: flex-start;
}

/* 视频和图片特定样式 */
.media-item.video .media-type {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.media-item.image .media-type {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

/* 输入区域 */
.input-area {
    background: transparent;
    padding: 0 24px 24px;
    border-top: none;
    position: relative;
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: center;
    max-width: 960px;
    margin: 0 auto;
    background: var(--white);
    padding: 20px 24px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.input-tools {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tool-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: rgba(74, 108, 247, 0.1);
    color: var(--primary-color);
    transform: scale(1.1);
}

.input-container:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

#questionInput {
    flex: 1;
    padding: 12px 0;
    border: none;
    border-radius: 0;
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: none;
    font-family: inherit;
    background: transparent;
    color: var(--text-primary);
}

#questionInput:focus {
    border-color: transparent;
    box-shadow: none;
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366F1 100%);
    color: var(--white);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(74, 108, 247, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-hint {
    text-align: center;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.input-hint span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.input-hint i {
    font-size: 0.9rem;
}

/* ==================== 媒体查看器 ==================== */
.media-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.media-viewer.active {
    display: flex;
    opacity: 1;
}

.media-viewer-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.media-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 10px;
    transition: var(--transition);
}

.media-close:hover {
    transform: scale(1.2);
}

.media-container video,
.media-container img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-md);
}

/* ==================== 加载指示器样式 ==================== */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.loading-dots {
    display: flex;
    gap: 8px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: loadingBounce 1.4s ease-in-out infinite both;
}

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

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* ==================== 管理后台样式 =-body {
    background=================== */
.admin: var(--bg-color);
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.admin-sidebar {
    width: 260px;
    background: var(--white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.admin-logo {
    padding: 24px;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-nav {
    flex: 1;
    padding: 20px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: var(--transition);
}

.nav-item:hover,
.nav-item.active {
    background: linear-gradient(135deg, rgba(74, 108, 247, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    color: var(--primary-color);
}

.nav-item.active {
    font-weight: 600;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.admin-footer {
    padding: 20px 12px;
    border-top: 1px solid var(--border-color);
}

.back-to-chat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.back-to-chat:hover {
    background: var(--primary-color);
    color: var(--white);
}

/* 主内容区 */
.admin-main {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
}

.admin-page {
    display: none;
}

.admin-page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.page-header {
    margin-bottom: 32px;
}

.page-header h2 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-secondary);
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--white);
}

.stat-icon.blue {
    background: linear-gradient(135deg, #4A6CF7 0%, #6366F1 100%);
}

.stat-icon.green {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
}

.stat-icon.orange {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
}

.stat-info h3 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--text-secondary);
}

/* 最近问题 */
.recent-questions {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.recent-questions h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.questions-list {
    max-height: 400px;
    overflow-y: auto;
}

.question-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.question-item:last-child {
    border-bottom: none;
}

.question-item:hover {
    background: var(--bg-color);
}

.question-text {
    flex: 1;
    color: var(--text-primary);
    margin-right: 16px;
}

.question-time {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/* 过滤栏 */
.filter-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-input {
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.filter-input:focus {
    border-color: var(--primary-color);
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366F1 100%);
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--white);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* 历史记录列表 */
.history-list {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.history-item {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background: var(--bg-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.history-time {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.history-question {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 8px;
}

.history-answer {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 知识库列表 */
.knowledge-list {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.knowledge-item {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.knowledge-item:last-child {
    border-bottom: none;
}

.knowledge-item:hover {
    background: var(--bg-color);
}

.knowledge-title {
    font-weight: 500;
    color: var(--text-primary);
}

.knowledge-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 知识库内联编辑器 */
.knowledge-editor {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.editor-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
}

.editor-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.editor-title label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.editor-title span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.editor-actions {
    display: flex;
    gap: 12px;
}

.editor-content {
    padding: 24px;
}

.editor-content .form-textarea {
    width: 100%;
    min-height: 400px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
}

/* 弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--primary-color);
}

.form-textarea {
    resize: vertical;
    min-height: 300px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

/* ==================== H5/移动端响应式 ==================== */
@media (max-width: 768px) {
    .app-container {
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
        flex-direction: column;
    }

    /* 移动端隐藏左侧sidebar */
    .sidebar {
        display: none;
    }

    .chat-wrapper {
        flex: 1;
    }

    .header {
        padding: 12px 16px;
    }

    .logo span {
        font-size: 1.1rem;
    }

    .header-stats {
        display: none;
    }

    .chat-container {
        padding: 12px;
    }

    .message-content {
        max-width: 85%;
    }

    .message-bubble {
        padding: 12px 14px;
        font-size: 0.95rem;
    }

    .input-area {
        padding: 12px 16px 16px;
    }

    #questionInput {
        padding: 12px 14px;
    }

    .send-btn {
        width: 44px;
        height: 44px;
    }

    /* 管理后台移动端 */
    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
    }

    .admin-logo {
        border: none;
        padding: 0;
        font-size: 1.1rem;
    }

    .admin-nav {
        display: flex;
        flex-direction: row;
        padding: 8px 12px;
        gap: 8px;
    }

    .nav-item {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .nav-item span {
        display: none;
    }

    .nav-item i {
        font-size: 1.1rem;
        margin-right: 0;
    }

    .admin-footer {
        border: none;
        padding: 0;
    }

    .back-to-chat span {
        display: none;
    }

    .admin-main {
        margin-left: 0;
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 16px;
    }

    .filter-bar {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .logo i {
        display: none;
    }

    .message {
        gap: 8px;
    }

    .message-avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .media-links {
        flex-direction: column;
    }

    .media-link {
        justify-content: center;
    }
}

/* ==================== 滚动条美化 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==================== 加载遮罩 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 999;
    display: none;
    justify-content: center;
    align-items: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== 提示消息 ==================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    z-index: 2000;
    animation: toastIn 0.3s ease;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
