/* 基础样式 */
:root {
    --primary-color: #004098; /* 浙工大蓝 */
    --secondary-color: #c8102e; /* 点缀红色 */
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --gray-color: #6c757d;
    --light-gray: #e9ecef;
    --border-radius: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    color: var(--dark-color);
    background-color: #f5f7fa;
    line-height: 1.6;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶部导航栏 */
.header {
    background-color: white;
    box-shadow: var(--shadow);
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo {
    height: 48px;
    margin-right: 1rem;
}

.logo-container h1 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--primary-color);
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
}

.nav-menu a {
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 500;
    padding: 0.5rem 0;
    position: relative;
    transition: var(--transition);
}

.nav-menu a:hover {
    color: var(--primary-color);
}

.nav-menu a.active {
    color: var(--primary-color);
}

.nav-menu a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px 3px 0 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    font-size: 0.9rem;
    color: var(--gray-color);
}

.login-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.login-btn:hover {
    background-color: #003580;
    box-shadow: 0 2px 8px rgba(0, 64, 152, 0.3);
}

/* 主体内容区 */
.main-content {
    display: flex;
    flex: 1;
    padding: 1.5rem;
    gap: 1.5rem;
}

/* 左侧信息面板 */
.info-panel {
    width: 22%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.university-info {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.campus-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.university-info h2 {
    padding: 1rem 1rem 0.5rem;
    color: var(--primary-color);
    font-size: 1.3rem;
}

.university-brief {
    padding: 0 1rem 1rem;
    font-size: 0.9rem;
    color: var(--gray-color);
}

.quick-links {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
}

.quick-links h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 0.6rem;
}

.quick-links ul {
    list-style: none;
}

.quick-links li {
    margin-bottom: 0.8rem;
}

.quick-links a {
    text-decoration: none;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: var(--transition);
    padding: 0.5rem;
    border-radius: var(--border-radius);
}

.quick-links a:hover {
    background-color: #f0f4f8;
    color: var(--primary-color);
}

/* 终止按钮样式 */
.stop-mode {
    background-color: #ff4444 !important;
    color: white !important;
    transition: all 0.3s ease;
}

.stop-mode i {
    display: none;
}

.stop-mode::before {
    content: '\f04c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 2.2em;
}

.stop-mode:hover {
    background-color: #ff0000 !important;
    transform: scale(1.05);
}

.quick-links i {
    color: var(--primary-color);
}

/* 中央聊天区域 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    height: 905px;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.chat-header h2 {
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 600;
}

.chat-tools {
    display: flex;
    gap: 0.8rem;
}

.tool-btn {
    background: none;
    border: none;
    color: var(--gray-color);
    cursor: pointer;
    transition: var(--transition);
    padding: 0.5rem;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 30px;
}

.tool-btn:hover {
    background-color: var(--light-gray);
    color: var(--primary-color);
}

.messages-container {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 540px; 
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 80%;
}

.message.system {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    background-color: #f0f4f8;
    padding: 1rem 1rem 0.85rem 1.5rem;
    border-radius: 1rem;
    border-top-left-radius: 0;
    position: relative;
}

.message.user .message-content {
    background-color: #e6f2ff;
    border-radius: 1rem;
    border-top-right-radius: 0;
}

.time {
    font-size: 0.75rem;
    color: var(--gray-color);
    display: block;
    margin-top: 0.5rem;
    text-align: right;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.chip {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.chip:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.chat-input-area {
    padding: 1rem;
    border-top: 2px solid var(--light-gray);
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    height: 90px; /* 固定输入区域高度 */
}

textarea {
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    height: 40px; /* 固定文本区域高度 */
    width: 100%;
}

.input-tools {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    position: absolute; /* 改为绝对定位 */
    bottom: 36px; /* 距底部距离 */
    right: 5px; /* 距右侧距离 */
    height: 20px;
}

.input-container {
    flex: 1;
    background-color: #f8f9fa;
    border-radius: 1rem;
    padding: 0.2rem 1.2rem 0 1rem;
    display: flex;
    flex-direction: column;
    height: 60px;
    position: relative; /* 添加相对定位，作为input-tools的定位参考 */
}


.input-container:hover {
    box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1);
}

.send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0; /* 防止按钮被压缩 */
}

.send-btn:hover {
    background-color: #003580;
    transform: scale(1.05);
}

.send-btn i {
    font-size: 1.8rem;
}

/* 右侧信息栏 */
.additional-info {
    width: 22%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-box {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
}

.info-box h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 0.6rem;
}

.calendar-list, .faq-list {
    list-style: none;
}

.calendar-list li {
    display: flex;
    margin-bottom: 1rem;
    align-items: center;
}

.date {
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.7rem;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 0.8rem;
    min-width: 50px;
    text-align: center;
}

.event {
    flex: 1;
}

.faq-list li {
    margin-bottom: 0.8rem;
    padding-left: 1rem;
    position: relative;
}

.faq-list li::before {
    content: '•';
    color: var(--primary-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.faq-list a {
    text-decoration: none;
    color: var(--dark-color);
    transition: var(--transition);
}

.faq-list a:hover {
    color: var(--primary-color);
}

.contact p {
    margin-bottom: 0.8rem;
}

.social-media {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-media a {
    color: var(--gray-color);
    font-size: 1.5rem;
    transition: var(--transition);
}

.social-media a:hover {
    color: var(--primary-color);
}

/* 页脚样式 */
.footer {
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 2rem 0 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-section {
    flex: 1;
    min-width: 200px;
    margin-bottom: 2rem;
    padding: 0 15px;
}

.footer-logo {
    margin-bottom: 1rem;
}

.footer-info p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #bdc3c7;
}

.footer-section h4 {
    color: #fff;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.footer-section h4::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 40px;
    height: 2px;
    background-color: #3498db;
}

.footer-links-grid {
    display: block;
    color: #bdc3c7;
    text-decoration: none;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.footer-links a, 
.footer-links-grid a {
    display: block;
    color: #bdc3c7;
    text-decoration: none;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.footer-links a:hover, 
.footer-links-grid a:hover {
    color: #3498db;
}

.footer-links a i, 
.footer-links-grid a i {
    margin-right: 0.5rem;
    font-size: 1rem;
}

.footer-bottom {
    background-color: #1a252f;
    padding: 1rem 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.footer-bottom p {
    margin: 0;
    font-size: 0.8rem;
    color: #7f8c8d;
}

.accessibility {
    display: flex;
    gap: 0.5rem;
}

.accessibility button {
    background: none;
    border: 1px solid #7f8c8d;
    color: #7f8c8d;
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    transition: all 0.3s;
}

.accessibility button:hover {
    color: #3498db;
    border-color: #3498db;
}

.accessibility button i {
    font-size: 1rem;
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3rem;
    height: 3rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background-color: #2980b9;
}

.back-to-top i {
    font-size: 1.5rem;
}


/* 二维码样式 */
.qrcode-section {
    margin-top: -0.8rem;
    border-top: 5px solid rgba(255,255,255,0.1);
    text-align: center;
}

.qrcode-section h3 {
    border-bottom: none !important;
}

.qrcode-img {
    width: 200px;
    height: 200px;
    margin: -0.8rem auto;
    border: 0px solid white;
    border-radius: 8px;
}

/* 移动设备菜单按钮 */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
}

/* 响应式设计 - 优化手机端显示 */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .info-panel, .additional-info {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .university-info, .quick-links, .info-box {
        flex: 1;
        min-width: 300px;
    }
    
    .chat-container {
        height: auto;
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0.8rem 1rem;
        flex-wrap: wrap;
    }
    
    .logo-container {
        flex: 1;
    }
    
    .logo {
        height: 40px;
    }
    
    .logo-container h1 {
        font-size: 1.2rem;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .nav-menu {
        width: 100%;
        flex-direction: column;
        gap: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
    }
    
    .nav-menu.active {
        max-height: 500px;
    }
    
    .nav-menu a {
        padding: 0.8rem 0;
        border-bottom: 1px solid var(--light-gray);
    }
    
    .user-info {
        margin-left: auto;
    }
    
    .user-name {
        display: none;
    }
    
    .main-content {
        padding: 1rem;
        gap: 1rem;
    }
    
    /* 在手机上隐藏侧面板，优先显示聊天区域 */
    .info-panel, .additional-info {
        display: none;
    }
    
    /* 让聊天容器占满屏幕 */
    .chat-container {
        width: 100%;
        height: calc(100vh - 180px); /* 减去头部和底部高度 */
        min-height: 400px;
    }
    
    .messages-container {
        height: calc(100% - 160px); /* 减去输入区域和头部高度 */
    }
    
    .message {
        max-width: 95%;
    }
    
    .chat-input-area {
        height: auto;
        min-height: 70px;
        padding: 0.8rem;
    }
    
    .input-container {
        height: auto;
        min-height: 50px;
    }
    
    textarea {
        width: 100%;
        padding: 0.5rem 0;
    }
    
    .input-tools {
        right: 10px;
        bottom: 30px;
    }
    
    .send-btn {
        width: 45px;
        height: 45px;
    }
    
    .send-btn i {
        font-size: 1.5rem;
    }
    
    .suggestion-chips {
        overflow-x: auto;
        padding-bottom: 0.5rem;
        flex-wrap: nowrap;
        justify-content: flex-start;
        width: 100%;
    }
    
    .chip {
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* 页脚响应式调整 */
    .footer-content {
        flex-direction: column;
        padding: 0 1rem;
    }
    
    .footer-section {
        margin-bottom: 1.5rem;
    }
    
    .footer-bottom {
        flex-direction: column;
        align-items: center;
        gap: 0.8rem;
        padding: 1rem;
    }
    
    .accessibility {
        justify-content: center;
    }
    
    .qrcode-img {
        width: 150px;
        height: 150px;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    .header {
        padding: 0.6rem 0.8rem;
    }
    
    .logo {
        height: 32px;
    }
    
    .logo-container h1 {
        font-size: 1rem;
    }
    
    .login-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .chat-header {
        height: auto;
        padding: 0.8rem;
    }
    
    .chat-header h2 {
        font-size: 1rem;
    }
    
    .tool-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
    }
    
    .message-content {
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    .time {
        font-size: 0.7rem;
    }
    
    .send-btn {
        width: 40px;
        height: 40px;
    }
    
    .back-to-top {
        width: 2.5rem;
        height: 2.5rem;
        bottom: 1rem;
        right: 1rem;
    }
}
/* 综合优化 - 解决高度不足和开场白过宽的问题 */

/* 聊天框高度优化 */
@media (max-width: 768px) {
    /* 让聊天容器占据更多屏幕空间 */
    .chat-container {
        width: 100%;
        height: calc(90vh - 120px) !important;
        min-height: 70vh !important;
    }
    
    /* 相应调整消息容器的高度 */
    .messages-container {
        height: calc(90vh - 200px) !important;
        min-height: 60vh !important;
    }
    
    /* 优化页面结构 */
    .main-content {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    /* 减少页面其他元素的视觉重量 */
    .header {
        padding: 0.5rem 1rem;
        height: auto;
        min-height: 60px;
    }
    
    /* 开场白宽度控制 - 关键修复 */
    .message {
        max-width: 90% !important; /* 限制所有消息宽度 */
    }
    
    /* 精确控制系统消息(开场白)宽度 */
    .message.system {
        width: 90% !important; /* 固定宽度比例 */
        max-width: 90% !important;
    }
    
    .message.system .message-content {
        width: calc(100% - 40px) !important; /* 考虑头像宽度 */
        max-width: calc(100% - 40px) !important;
        box-sizing: border-box;
    }
    
    /* 确保消息内容不溢出 */
    .message-content {
        padding: 0.8rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto; /* 允许断词 */
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    /* 确保段落内容也受控 */
    .message-content p {
        width: 100%;
        max-width: 100%;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }
    
    /* 优化建议按钮布局 */
    .suggestion-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.8rem;
        width: 100%;
    }
    
    .chip {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        white-space: normal;
        text-align: center;
        flex: 1 0 calc(50% - 0.5rem); /* 每行两个 */
        min-width: 0;
    }
}

/* iOS设备特殊优化 */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        .chat-container {
            height: 85vh !important;
        }
        
        .messages-container {
            height: calc(85vh - 140px) !important;
        }
        
        /* iOS特有的文本渲染优化 */
        .message-content {
            -webkit-hyphens: auto;   /* WebKit (Safari/Chrome) */
            -ms-hyphens: auto;      /* IE/Edge */
            hyphens: auto;          /* 标准属性 */
            -webkit-text-size-adjust: 100%;
        }
    }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
    .chat-container {
        height: calc(92vh - 100px) !important;
    }
    
    .messages-container {
        height: calc(92vh - 180px) !important;
    }
    
    /* 更严格的消息宽度控制 */
    .message {
        max-width: 85% !important;
    }
    
    .message.system {
        width: 85% !important;
        max-width: 85% !important;
    }
    
    /* 减小头像尺寸以节省空间 */
    .avatar {
        width: 32px;
        height: 32px;
    }
    
    .message.system .message-content {
        width: calc(100% - 35px) !important;
        max-width: calc(100% - 35px) !important;
    }
    
    /* 建议按钮进一步优化 */
    .chip {
        flex: 1 0 100%;
        margin-bottom: 0.3rem;
    }
}

/* 超小屏幕优化 */
@media (max-width: 375px) {
    /* 进一步减小消息宽度 */
    .message {
        max-width: 82% !important;
    }
    
    .message.system {
        width: 82% !important;
        max-width: 82% !important;
    }
    
    /* 减小内边距 */
    .message-content {
        padding: 0.6rem;
        font-size: 0.85rem;
    }
    
    /* 再次减小头像 */
    .avatar {
        width: 28px;
        height: 28px;
    }
    
    .message.system .message-content {
        width: calc(100% - 32px) !important;
        max-width: calc(100% - 32px) !important;
    }
}

/* 强制应用样式 */
.chat-container, .messages-container {
    max-height: none !important;
}