/* 全局样式 */
* {
    box-sizing: border-box;
}
body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    margin: 0;
    padding: 0;
    color: #333;
    background-color: #f9f9f9;
    padding-top: 70px; /* 为固定的头部区域留出空间 */
}

/* 头部区域样式 */
.header {
    background-color: #fff;
    border-bottom: 1px solid #e5e5e5;
    padding: 15px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 40px;
    width: auto;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: 40px;
}

.nav-link {
    color: #333;
    text-decoration: none;
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    background-color: #f5f5f5;
    color: #007bff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.language-switch {
    display: flex;
    gap: 1px;
    background: #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
}

.lang-btn {
    padding: 8px 12px;
    background: white;
    border: none;
    cursor: pointer;
    color: #666;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: #f5f5f5;
}

.lang-btn.active {
    background: #007bff;
    color: white;
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: #4285f4;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.3s;
}

.login-btn:hover {
    background-color: #357abd;
    color: white;
    text-decoration: none;
}

.login-btn i {
    font-size: 18px;
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 8px 0;
    min-width: 180px;
    margin-top: 8px;
}

.user-menu:hover .user-dropdown {
    display: block;
}

.username {
    display: block;
    padding: 8px 16px;
    border-bottom: 1px solid #e5e5e5;
    font-weight: 500;
    color: #333;
}

.dropdown-content a {
    display: block;
    padding: 8px 16px;
    color: #666;
    text-decoration: none;
    transition: all 0.3s ease;
}

.dropdown-content a:hover {
    background: #f5f5f5;
    color: #007bff;
}

@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }
    
    .header-content {
        justify-content: space-between;
    }
    
    .header-right {
        gap: 10px;
    }
    
    .language-switch {
        display: none;
    }
    
    .login-btn {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
    }
}

/* 主体区域样式 */
.main-container {
    margin: 20px;
    display: flex;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background-color: #fff;
    overflow: hidden;
    height: calc(100vh - 170px); /* 调整高度以留出底部区域空间 */
}

.input-section,
.output-section {
    flex: 1; /* 让两个区域宽度相等 */
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%; /* 让输入和输出区域高度填满主体区域 */
    overflow-x: auto; /* 当内容溢出时显示水平滚动条 */
    overflow-y: visible; /* 修改为 visible 允许子元素超出 */
}

.input-section::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 1px;
    background-color: #e5e5e5; /* 中间的分割线 */
}

#code-input {
    width: 100%;
    height: 100%;
    padding: 15px;
    font-size: 16px;
    border: none;
    resize: none;
    outline: none;
}

/* 添加输入框 placeholder 样式 */
#code-input::placeholder {
    color: #999;  /* 淡灰色 */
    font-size: 14px;
    opacity: 0.6;  /* 降低不透明度使其更淡 */
    font-style: italic;  /* 斜体 */
}

/* 确保输入框获得焦点时 placeholder 消失 */
#code-input:focus::placeholder {
    opacity: 0;
    transition: opacity 0.3s ease;  /* 添加淡出动画 */
}

/* 优化后的 options 样式 */
.options {
    padding: 15px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px; /* 增加元素之间的间距 */
    border-bottom: 1px solid #e5e5e5; /* 选项区底部的分割线 */
    background-color: #f7f7f7; /* 添加背景色 */
}

.options select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    appearance: none; /* 去除默认样式 */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="black" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position-x: calc(100% - 10px);
    background-position-y: 50%;
    padding-right: 30px;
    transition: border-color 0.2s ease-in-out;
    position: relative;
}

.options select:hover {
    border-color: #999;
}

.options select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.icon-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    transition: background-color 0.2s ease-in-out;
}

.icon-wrapper i {
    color: #999;
    cursor: pointer;
    font-size: 18px;
    transition: color 0.3s ease;
}

.icon-wrapper:hover {
    background-color: #f0f0f0;
}

.icon-wrapper i.active {
    color: #90ee90; /* 设置激活状态为绿色 */
}

/* 添加工具提示样式 */
.icon-wrapper .tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
}

.icon-wrapper:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.output-divider {
    height: 1px;
    background-color: #e5e5e5; /* 选项区与输出区之间的分割线 */
}

/* 修改输出区域样式以适应 Word A4 纸宽度 */
.output-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
    width: 595px; /* Word A4 纸的标准宽度（21cm ≈ 595px） */
    margin: 0 auto; /* 居中显示 */
    overflow-x: auto; /* 当内容溢出时显示水平滚动条 */
    overflow-y: visible; /* 允许垂直方向自由伸展 */
}

#code-output {
    width: 100%;
    position: relative;
    min-height: 200px;
    height: auto !important;
    overflow: visible !important;
    padding: 10px;
    background-color: #fff;
    border-radius: 4px;
    font-family: monospace;
    white-space: pre;
    tab-size: 4;
}

/* 确保 SyntaxHighlighter 容器适应 A4 宽度 */
.syntaxhighlighter {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.syntaxhighlighter .line {
    height: auto !important;
    line-height: 1.5em !important;
    white-space: pre !important;
}

.syntaxhighlighter .gutter {
    height: 100% !important;
    overflow: visible !important;
}

.syntaxhighlighter .gutter .line {
    border-right: 3px solid #ddd !important;
    padding-right: 0.5em !important;
}

.syntaxhighlighter table {
    height: auto !important;
    table-layout: fixed !important;
}

.syntaxhighlighter table td {
    vertical-align: top !important;
}

.syntaxhighlighter table td.gutter {
    width: 3em !important;
}

/* 底部区域样式 */
footer, .footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #fff;
    border-top: 1px solid #e5e5e5;
    margin-top: 20px;
    width: 100%;
    position: relative;
    left: 0;
    right: 0;
    box-sizing: border-box;
    max-width: none;
}

/* 确保footer容器不被限制宽度 */
.footer-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* 重写任何可能限制footer的样式 */
.info-section, .main-container, body > div {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

/* 媒体查询，适配小屏幕 */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        height: auto;
    }
    .input-section::after {
        display: none; /* 小屏幕时隐藏中间分割线 */
    }
}

.resizer {
    width: 5px;
    background-color: #ccc;
    cursor: col-resize;
}

/* 滚动条样式 */
.output-section::-webkit-scrollbar {
    width: 8px; /* 滚动条的宽度 */
    height: 8px; /* 水平滚动条的高度 */
}

.output-section::-webkit-scrollbar-track {
    background: #f1f1f1; /* 滚动条轨道的背景颜色 */
}

.output-section::-webkit-scrollbar-thumb {
    background: #888; /* 滚动条滑块的背景颜色 */
    border-radius: 4px; /* 滚动条滑块的圆角 */
}

.output-section::-webkit-scrollbar-thumb:hover {
    background: #555; /* 鼠标悬停时滚动条滑块的背景颜色 */
}

.options {
    height: 80px;
}

.icon-wrapper {
    margin-right: 10px;
    position: relative;
    display: inline-flex; /* 使用flex布局 */
    align-items: center; /* 垂直居中 */
    justify-content: center; /* 水平居中 */
    width: 30px;
    height: 30px;
    border-radius: 4px;
    transition: background-color 0.2s ease-in-out;
}

.icon-wrapper i {
    color: #999;
    cursor: pointer;
    font-size: 18px;
    transition: color 0.3s ease;
    /* 去掉可能影响居中的边距 */
    margin: 0;
    padding: 0;
}

.tooltip {
    visibility: hidden;
    background-color: transparent;
    color: #888; /* 灰色文字 */
    font-size: 12px; /* 10号字体 */
    text-align: center;
    border-radius: 0; /* 去掉边框圆角 */
    padding: 0; /* 去掉内边距 */
    position: absolute;
    z-index: 1;
    bottom: 120%; /* 调整位置 */
    left: 50%;
    transform: translateX(-50%); /* 水平居中 */
    white-space: nowrap; /* 防止文字换行 */
    opacity: 0;
    transition: opacity 0.3s;
}

.icon-wrapper:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.header-text {
    color: #008000;
}

/* 语言切换按钮样式 */
.language-switch {
    display: flex;
    gap: 0;
    margin-left: 10px;
}

.lang-btn {
    padding: 2px 8px;
    font-size: 14px;
    border: 1px solid #ddd;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s;
}

/* 左边按钮圆角 */
.lang-btn:first-child {
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
}

/* 右边按钮圆角 */
.lang-btn:last-child {
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
}

/* 移除相邻按钮的左边框 */
.lang-btn + .lang-btn {
    border-left: none;
}

.lang-btn.active {
    background-color: #4a90e2;
    color: white;
    border: 1px solid #4a90e2;
}

/* 语言文本显示逻辑 */
body[data-lang="zh"] [lang="en"],
body[data-lang="en"] [lang="zh"] {
    display: none;
}

/* 如果页面使用了老的zh-text/en-text类，也保持兼容 */
body[data-lang="zh"] .en-text,
body[data-lang="en"] .zh-text {
    display: none;
}

.icon-text {
    margin-left: 5px;
}

/* 老版本文字链接样式 */
.text-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    margin-right: 15px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    border-radius: 4px;
    transition: background-color 0.2s ease-in-out;
}

.text-link:hover {
    background-color: #f0f0f0;
}

#old-version-link {
    color: #2a982a;
    font-weight: 500;
}

/* 增强字体选择器下拉菜单样式 */
select.font-select {
    height: auto !important;
    max-height: 34px; /* 默认状态的高度 */
}

select.font-select option {
    padding: 6px 10px;
    line-height: 1.5;
}

select.font-select optgroup {
    font-weight: bold;
    background-color: #f8f9fa;
    color: #495057;
}

/* 让下拉菜单在展开状态下足够大 */
select.font-select:focus {
    max-height: none !important;
}

/* 渲染模式选择框样式 */
.render-mode-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.render-mode-control:hover {
    border-color: #999;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.render-mode-control label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #333;
    font-weight: 500;
    white-space: nowrap;
}

.render-mode-control label i {
    color: #666;
    font-size: 14px;
}

.render-mode-control select {
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23666" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    cursor: pointer;
    min-width: 120px;
    transition: all 0.3s ease;
}

.render-mode-control select:hover {
    border-color: #999;
}

.render-mode-control select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.render-mode-control select option {
    padding: 8px 12px;
    font-size: 14px;
}