html, body {
    height: 100%;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    font-family: 'Microsoft YaHei', sans-serif;
}

/* 贵大主题色彩 */
:root {
    --gzu-primary: #0056b3;
    --gzu-secondary: #6c757d;
    --gzu-success: #28a745;
    --gzu-info: #17a2b8;
    --gzu-warning: #ffc107;
    --gzu-danger: #dc3545;
    --gzu-light: #f8f9fa;
    --gzu-dark: #343a40;
}

.message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.message:hover {
    transform: translateY(-1px);
}

.message.user {
    background: linear-gradient(135deg, var(--gzu-primary), #007bff);
    color: white;
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant {
    background-color: white;
    color: #212529;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 0.25rem;
}

.message.assistant::before {
    content: "贵大助手";
    font-size: 0.75rem;
    color: #6c757d;
    display: block;
    margin-bottom: 0.5rem;
}

.processing {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-bottom-left-radius: 0.25rem;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-bottom-left-radius: 0.25rem;
}

.message-content {
    margin: 0;
    line-height: 1.5;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

#chatMessages {
    min-height: 400px;
    max-height: 60vh;
    border: 1px solid #dee2e6;
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
}

.typing-indicator {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #e9ecef;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--gzu-primary);
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

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

header {
    border-bottom: 1px solid #dee2e6;
}

footer {
    border-top: 1px solid #dee2e6;
}

header.bg-primary {
    background: linear-gradient(135deg, var(--gzu-primary), #007bff) !important;
}

/* 连接状态指示器 */
.connection-indicator {
    position: relative;
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.connection-indicator.connected {
    background-color: var(--gzu-success);
    animation: pulse 2s infinite;
}

.connection-indicator.disconnected {
    background-color: var(--gzu-danger);
}

.connection-indicator.connecting {
    background-color: var(--gzu-warning);
    animation: pulse 1s infinite;
}

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

/* 输入框样式 */
.input-group-text {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .form-control:focus {
    border-color: var(--gzu-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 86, 179, 0.25);
}

#sendButton {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    font-weight: 500;
}

/* 输入建议 */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
}

.suggestion-chip {
    padding: 0.25rem 0.75rem;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background-color: var(--gzu-primary);
    color: white;
    border-color: var(--gzu-primary);
}

/* 引用链接样式 */
.reference-link {
    color: var(--gzu-primary);
    text-decoration: none;
    font-size: 0.8em;
    margin: 0 0.25rem;
}

.reference-link:hover {
    text-decoration: underline;
}

.reference-sup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    height: 1.2rem;
    margin: 0 0.18rem;
    padding: 0 0.22rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    color: #0b3d91;
    background: #e9f0ff;
    border: 1px solid #b8cdfa;
    vertical-align: super;
    cursor: help;
}

.reference-panel {
    border: 1px solid #dbe4ff;
    background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
}

.reference-panel-header {
    border-bottom: 1px solid #e2e8f7;
    background: linear-gradient(135deg, #1e4d99, #2f6fce);
    color: #fff;
}

.reference-panel-body {
    overflow-y: auto;
}

.reference-empty {
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    text-align: center;
}

.reference-empty i {
    font-size: 2rem;
    opacity: 0.65;
}

.reference-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.reference-item {
    display: flex;
    gap: 0.65rem;
    background: #fff;
    border: 1px solid #e3e9f7;
    border-radius: 0.7rem;
    padding: 0.65rem 0.75rem;
}

.reference-index {
    flex: 0 0 auto;
    min-width: 2.2rem;
    height: 1.6rem;
    border-radius: 999px;
    background: #e9f0ff;
    color: #0b3d91;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.reference-content {
    min-width: 0;
}

.reference-id {
    color: #1f2d4a;
    font-size: 0.9rem;
    font-weight: 600;
    word-break: break-all;
}

.reference-meta {
    color: #61708f;
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

.reference-doc-source {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: #35507f;
    font-weight: 600;
    word-break: break-word;
}

.reference-doc-content {
    margin-top: 0.25rem;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #2a3447;
    background: #f6f9ff;
    border: 1px solid #e5ebfb;
    border-radius: 0.55rem;
    padding: 0.45rem 0.55rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.reference-doc-content.muted {
    color: #7a859d;
    font-style: italic;
    background: #fafbfd;
}

/* 响应式设计 */
@media (max-width: 768px) {
    html, body {
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
    }

    .container-fluid.h-100,
    .container-fluid .row.h-100,
    .container-fluid .col-lg-8 {
        height: 100dvh !important;
        min-height: 100dvh;
    }

    .container-fluid .row.h-100 {
        padding: 0 !important;
        margin: 0;
    }

    .container-fluid .col-lg-8 {
        padding: 0;
    }

    .message {
        max-width: 95%;
    }

    header h4 {
        font-size: 1.1rem;
    }

    header small {
        font-size: 0.75rem;
    }

    #chatMessages {
        min-height: 0;
        max-height: none;
        flex: 1 1 auto;
        border-radius: 0;
    }

    footer {
        flex: 0 0 15dvh;
        min-height: 15dvh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 0.75rem !important;
        border-radius: 0;
    }

    footer .mt-2 {
        display: none !important;
    }

    .mobile-header-meta {
        display: block;
    }

    .mobile-header-tip {
        color: rgba(255, 255, 255, 0.88);
        line-height: 1.35;
    }

}

/* 加载动画 */
.loading-message {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: white;
    border: 1px solid #e9ecef;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    margin-bottom: 1rem;
}

.loading-message .spinner-border {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.welcome-message i {
    font-size: 3rem;
    color: var(--gzu-primary);
    margin-bottom: 1rem;
}

.welcome-message h5 {
    color: var(--gzu-primary);
    margin-bottom: 1rem;
}

.welcome-message p {
    color: #6c757d;
    margin-bottom: 1.5rem;
}