/* 浅灰主题 */
.theme-light-gray {
    background-color: #f8f9fa; /* 浅灰背景 */
    color: #212529; /* 深灰文本颜色 */
}

.theme-light-gray .content-wrapper{
    background-color: #f8f9fa; /* 浅灰背景 */
    color: #212529; /* 深灰文本颜色 */
}

.theme-light-gray .navbar {
    background-color: #ffffff !important; /* 白色导航栏 */
    color: #212529;
    border-bottom: 1px solid #dee2e6;
}

.theme-light-gray a:hover {
    color: #0056b3; /* 深蓝链接 */
}

.theme-light-gray .table {
    color: #212529;
}

/* 淡黄主题 */
.theme-light-yellow {
    background-color: #fffbe6; /* 淡黄色背景 */
    color: #5a3e00; /* 深棕文本颜色 */
}

.theme-light-yellow .content-wrapper{
    background-color: #fffbe6; /* 淡黄色背景 */
    color: #5a3e00; /* 深棕文本颜色 */
}

.theme-light-yellow .navbar {
    background-color: #fff9cc !important; /* 深黄色导航栏 */
    color: #5a3e00;
    border-bottom: 1px solid #ffec99;
}

.theme-light-yellow a {
    color: #b08900; /* 棕黄链接 */
}

.theme-light-yellow a:hover {
    color: #805d00; /* 深棕链接 */
}

.theme-light-yellow .table {
    color: #5a3e00;
}

/* 淡绿色主题 */
.theme-light-green {
    background-color: #e9f7ef; /* 淡绿色背景 */
    color: #0c513d; /* 深绿色文本颜色 */
}

.theme-light-green .content-wrapper{
    background-color: #e9f7ef; /* 淡绿色背景 */
    color: #0c513d; /* 深绿色文本颜色 */
}

.theme-light-green .navbar {
    background-color: #d4edda !important; /* 深绿色导航栏 */
    color: #0c513d;
    border-bottom: 1px solid #c3e6cb;
}

.theme-light-green #footer {
    background-color: #d4edda !important; /* 深绿色导航栏 */
    color: #0c513d;
    border-bottom: 1px solid #c3e6cb;
}

.theme-light-green a {
    color: #198754; /* 绿色链接 */
}

.theme-light-green a:hover {
    color: #146c43; /* 深绿色链接 */
}

.theme-light-green .table {
    color: #0c513d;
}

/* Dark 模式主题 */
.theme-dark {
    background-color: #121212; /* 深黑背景 */
    color: #f5f5f5; /* 浅灰文本颜色 */
}

.theme-dark .content-wrapper{
    background-color: #121212; /* 深黑背景 */
    color: #f5f5f5; /* 浅灰文本颜色 */
}

.theme-dark .navbar {
    background-color: #1e1e1e !important; /* 深灰导航栏 */
    color: #f5f5f5;
    border-bottom: 1px solid #333333;
}

.theme-dark a {
    color: #66d9ff; /* 浅蓝色链接 */
}

.theme-dark a:hover {
    color: #33bbff; /* 高亮蓝色链接 */
}

.theme-dark .table {
    color: #f5f5f5;
    background-color: #1e1e1e; /* 深灰表格背景 */
    border-color: #333333; /* 表格边框颜色 */
}

.theme-dark .table-striped tbody tr:nth-of-type(odd) {
    background-color: #2c2c2c; /* 条纹背景 */
}

.theme-dark .table-striped tbody tr:nth-of-type(even) {
    background-color: #1e1e1e; /* 深灰背景 */
}

/* Global Styles */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'SimSun', 'Arial', sans-serif;
    line-height: 1.6;
    font-weight: 400;
    font-size: large;
    overflow: auto;
}

h3, h4 {
    margin-top: 20px;
    font-weight: bold;
}

p {
    text-indent: 2em;
}

/* Container Styles */
.container-fluid {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* 内容容器样式 */
.content-wrapper {
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* 轻微阴影 */
    flex-grow: 1; /* 允许内容容器填充剩余空间 */
    box-sizing: border-box;
}

/* 左右两列样式 */
#original-text, #translated-text {
    height: 100%; /* 填充父容器高度 */
    overflow-y: auto; /* 确保滚动条正常显示 */
    box-sizing: border-box;
    flex-grow: 1; /* 允许内容容器填充剩余空间 */
    padding: 20px;
}

/* 滚动条美化 */
#original-text::-webkit-scrollbar,
#translated-text::-webkit-scrollbar {
    width: 8px;
}

#original-text::-webkit-scrollbar-thumb,
#translated-text::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

#original-text::-webkit-scrollbar-thumb:hover,
#translated-text::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* 导航栏样式 */
.navbar {
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1);
}

/* 表单和按钮样式 */
form, button, select {
    color: inherit;
}

/* 超链接样式 */
a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: #007bff;
    text-decoration: underline;
}

/* 调整当没有翻译时的布局 */
#content-center {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 父容器不滚动 */
}

.centered-content {
    width: 65%; /* 内容占据 60% 的宽度 */
    margin: 0 auto;
    flex-grow: 1; /* 允许内容容器填充剩余空间 */
    overflow-y: auto; /* 启用滚动条 */
    box-sizing: border-box;
}

/* 移动端适配 */
@media (max-width: 768px) {
    #original-text, #translated-text {
        height: auto; /* 移动端高度适配 */
        overflow-y: auto;
        padding: 15px;
    }

    #content-section {
        flex-direction: column;
        overflow: visible; /* Allow content to scroll on mobile */
    }

    .content-wrapper {
        margin-bottom: 10px;
    }

    .centered-content {
        width: 100%; /* 移动端内容占满宽度 */
        padding: 15px;
        margin: 0;
    }

    body {
        overflow: auto;
        font-weight: 600;
        font-size:x-large;
    }

    .form-control-sm {
        width: 2rem;
    }
}

/* 确保表格宽度适配父容器 */
.table-responsive {
    overflow-x: auto; /* 启用水平滚动条，仅在需要时显示 */
}

/* 设置表格单元格内容不换行并防止超宽 */
.table {
    table-layout: fixed; /* 固定表格布局，按指定的列宽分配 */
    width: 100%; /* 表格占满容器宽度 */
}

/* 确保表格内容不换行并超出显示省略号 */
.table td,
.table th {
    white-space: nowrap; /* 禁止换行 */
    overflow: hidden; /* 隐藏超出的部分 */
    text-overflow: ellipsis; /* 超出部分显示省略号 */
}

/* 书名链接的样式 */
.clickable-link {
    font-weight: bold;
    text-decoration: underline; /* 下划线提示 */
    cursor: pointer;
}

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

/* Content Section */
#content-section {
    flex-grow: 1;
    overflow: hidden;
}

#original-text, .chat-container {
    overflow-y: auto;
}

#original-text {
    flex-grow: 1;
}

.chat-container {
    display: none;
    background-color: inherit;
    color: inherit;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-container.active {
    display: block;
}

.with-chat{
    width: 50% !important;
    float: left !important;
}

.with-chat #original-text {
    width: 50%;
}

.with-chat .chat-container {
    width: 50%;
}

#main-content {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
}

/* Footer */
#footer {
    flex-shrink: 0;
}

/* Mobile Adaptation */
@media (max-width: 768px) {
    #main-content {
        flex-direction: column;
    }

    #original-text {
        width: 100%;
        flex-grow: 1;
    }

    .chat-container {
        width: 100%;
        position: fixed;
        left: 0;
        z-index: 1000;
        overflow: auto;
    }

    .with-chat #original-text {
        display: none;
    }

    body {
        font-weight: 600;
        font-size: x-large;
    }

    #content-section {
        overflow: hidden;
        flex-grow: 1;
    }
}

/* Chat Messages */
.chat-messages {
    overflow-y: auto;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Fill the available space */
}

/* Message Styles */
.message {
    display: flex;
    margin-bottom: 15px;
}

.message .content {
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 16px;
}

.user-message {
    justify-content: flex-end;
}

.user-message .content {
    background-color: rgba(0, 123, 255, 0.1);
    padding: 10px;
    border-radius: 8px;
    max-width: 80%; /* Optional: Limit width for better readability */
}

.assistant-message {
    justify-content: flex-start;
}

.assistant-message .content {
    background-color: rgba(220, 220, 220, 0.2); /* Light gray background */
    padding: 10px;
    border-radius: 8px;
    text-align: left;
    max-width: 100%; /* Allow full width */
}

.loading {
    font-style: italic;
}

/* Input Form */
#chat-form {
    padding: 10px;
    box-sizing: border-box;
    background-color: inherit;
}

#chat-input {
    width: 100%;
    height: 100px; /* Approximately 5 lines */
    resize: none;
    overflow-y: auto;
    border: 1px solid #ced4da;
    border-radius: 5px;
    background-color: inherit;
    color: inherit;
    font-size: 16px;
    padding: 10px;
}

#chat-input:focus {
    outline: none;
    border-color: #80bdff;
}

.chat-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: -5px;
}

.chat-controls button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.chat-controls button:hover {
    opacity: 0.7;
}

.chat-controls svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.chat-controls .btn-clear {
    margin-right: auto;
}

.chat-controls .btn-send {
    margin-left: auto;
}

/* Remove default button focus outline */
button:focus {
    outline: none;
}

/* Loading Animation */
.loading-dots {
    display: inline-block;
    margin-left: 5px;
}

.loading-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background-color: currentColor;
    border-radius: 50%;
    opacity: 0;
    animation: loadingBlink 1s infinite;
}

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

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

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

@keyframes loadingBlink {
    0%, 80%, 100% {
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
}

/* Selection Prompt */
.selection-prompt {
    position: absolute;
    background-color: #ffffff;
    border: 1px solid #cccccc;
    padding: 5px;
    border-radius: 4px;
    z-index: 2000;
    display: flex;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.selection-prompt button {
    padding: 5px 10px;
    cursor: pointer;
    background-color: transparent;
    border: none;
    font-size: 14px;
    color: #007bff;
}

.selection-prompt button:hover {
    background-color: #f0f0f0;
}

#jump-form, #pagination, .navbar, #footer {
    font-size: 0.7em !important;
}

#footer .btn {
    font-size: 0.6em !important;
}

.no-border {
    border: 0px solid transparent !important;
}