/* ==================== 全局样式 ==================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    max-width: 1200px;
    margin: auto;
    background-color: #f0f2f5;
}

.container {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ==================== 导航栏样式 ==================== */
.navbar {
    background: #4299e1;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 50px;
    height: 100%;
}

.nav-logo h2 {
    color: white;
    cursor: pointer;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.nav-menu {
    display: flex;
    list-style: none;
    text-align: center;
    margin: 0;
}

.nav-item {
    line-height: 40px;
    margin-left: 1.5rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    transition: all 0.3s ease-out;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.nav-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
}

.nav-link::before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(transparent 50%, rgba(255, 255, 255, 0.1) 50%);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.nav-link:hover::before {
    transform: translateY(0);
}


/* ==================== 头部样式 ==================== */
.header {
    text-align: center;
    margin-bottom: 30px;
}

/* ==================== 表单区域样式 ==================== */
.form-section {
    margin-bottom: 24px;
}

.input-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.input-container {
    position: relative;
}

/* 文本域样式 */
textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    resize: vertical;
    font-family: monospace;
    font-size: 14px;
}

textarea.error {
    border-color: #ff4d4f;
    box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.1);
}

/* 标签行样式 */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.label-title {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.label-subtitle {
    font-size: 14px;
    color: #666;
    text-align: right;
}

/* 自动转换提示 */
.auto-convert-info {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: space-between;
}


.error-message {
    font-size: 12px;
    color: #ff4d4f;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    display: none;
}

/* 自定义选择器 */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-input {
    width: 100%;
    padding: 8px 12px;
    padding-right: 30px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    background-color: #fff;
    font-size: 14px;
    cursor: pointer;
    box-sizing: border-box;
}

.custom-select-input:focus {
    border-color: #40a9ff;
    outline: 0;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.custom-select-arrow {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: #bfbfbf;
    pointer-events: none;
    font-size: 12px;
}

/* 下拉菜单 */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid #d9d9d9;
    outline: none;
    box-sizing: border-box;
    font-size: 14px;
}

.options-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
}

.options-list li {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 14px;
}

.options-list li:hover,
.options-list li.selected {
    background-color: #a2f89b;
}

.options-list li.optgroup-label {
    font-weight: bold;
    background: linear-gradient(to right, #4299e1, #40a9ff);
    color: white;
    cursor: default;
    font-size: 13px;
    padding: 8px 12px;
    letter-spacing: 0.5px;
    border-left: 4px solid #0050b3;
    margin-top: 4px;
}

.options-list li.optgroup-label:first-child {
    margin-top: 0px;
}

.options-list li.optgroup-label:hover {
    background-color: #fafafa;
}

.options-list li.option-item {
    padding-left: 20px;
    border-left: 2px solid #e8e8e8;
}

/* ==================== 结果区域样式 ==================== */
.result-section {
    position: relative;
}

.result-section h3 {
    margin-top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.copy-btn {
    position: absolute;
    top: -5px;
    right: 5px;
    padding: 6px 10px;
    font-size: 12px;
    background-color: #f0f0f0;
    border-color: #d9d9d9;
}

.copy-btn:hover {
    background-color: #e0e0e0;
    border-color: #40a9ff;
}

pre {
    white-space: pre-wrap;
    word-break: break-all;
    color: #f8f8f2;
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin-top: 0;
    position: relative;
}

.error-result {
    background: #fff2f0;
    color: #cf1322;
    border: 1px solid #ffccc7;
}

/* 代码高亮相关 */
pre[class*="language-"] {
    position: relative;
}

pre[class*="language-"][data-line] {
    padding-left: 3.8em;
    counter-reset: linenumber;
}

pre[class*="language-"][data-line] > code[class*="language-"] {
    position: relative;
    white-space: inherit;
}

.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid #999;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.line-numbers-rows > span {
    pointer-events: none;
    display: block;
    counter-increment: linenumber;
}

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: #999;
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

/* ==================== 历史记录面板样式 ==================== */
.history-panel {
    position: fixed;
    top: 100px;
    right: 20px;
    width: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.3s ease;
    max-height: 80vh;
    overflow: hidden;
    border: 1px solid #d9d9d9;
    display: none; /* 默认隐藏 */
}

/* 美化历史记录弹窗并调整位置 */
.history-panel-dropdown {
    position: absolute;
    top: 60px; /* 调整距离顶部的位置 */
    right: 20px; /* 调整距离右边的位置 */
    width: 350px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    border: 1px solid #e8e8e8;
}

.history-panel-dropdown.show {
    display: block;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    background-color: #fafafa;
    border-radius: 8px 8px 0 0;
}

.history-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.history-content {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-list li {
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.history-list li:hover {
    background-color: #f5f5f5;
}

.history-empty {
    text-align: center;
    color: #999;
    padding: 20px;
}

.history-actions {
    display: flex;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.history-btn {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #d9d9d9;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.history-btn.clear {
    color: #ff4d4f;
    border-color: #ff4d4f;
}

.history-btn:hover {
    opacity: 0.8;
}

/* 展开状态 */
.history-panel.expanded {
    display: block;
}

/* 折叠状态 */
.history-panel.collapsed {
    display: none;
}

.history-toggle-inline {
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: background-color 0.3s;
}

.history-toggle-inline:hover {
    background: #40a9ff;
}

.history-toggle-inline:focus {
    outline: 2px solid rgba(24, 144, 255, 0.2);
    outline-offset: 2px;
}

/* ==================== 按钮样式 ==================== */
.btn {
    background-color: #4299e1;
    border-color: #4299e1;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    align-items: center;
    gap: 5px;
}

.btn:hover {
    background-color: #40a9ff;
    border-color: #40a9ff;
}

.btn-secondary {
    background-color: #f0f0f0;
    border-color: #bfbfbf;
    color: rgba(0, 0, 0, 0.85);
}

.btn-secondary:hover {
    background-color: #e0e0e0;
    border-color: #40a9ff;
    color: #40a9ff;
}

/* ==================== 通知和指示器 ==================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background: #52c41a;
    color: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
}

.converting-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background: #4299e1;
    color: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
}

/* ==================== 页脚样式 ==================== */
.footer {
    text-align: center;
    margin-top: 30px;
    color: #999;
    font-size: 12px;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
        max-width: 100%;
    }

    .container {
        padding: 15px;
    }

    .btn {
        margin-bottom: 10px;
        padding: 12px 16px;
        font-size: 14px;
    }

    .btn-secondary {
        background-color: #f0f0f0;
        border-color: #bfbfbf;
    }

    .copy-btn {
        background-color: #f0f0f0;
        border-color: #bfbfbf;
    }

    textarea {
        min-height: 150px;
    }

    pre {
        padding: 0.5em;
        font-size: 0.9em;
    }

    .history-panel {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        margin-bottom: 20px;
        max-width: none;
    }

    .history-panel.collapsed {
        width: 100%;
        height: auto;
        border-radius: 8px;
    }

    .history-panel.collapsed .history-header {
        border-radius: 8px;
    }

    .label-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .label-subtitle {
        margin-top: 5px;
        text-align: left;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .btn span[role="img"] {
        margin-right: 0;
    }

    .btn:not(.copy-btn) {
        font-size: 13px;
    }
}

/* ==================== 语言选择器样式 ==================== */
.language-selector-container {
    position: relative;
    margin-bottom: 20px;
}

.language-tab {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.language-tab:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.language-tab.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
}

.language-tab.active:hover {
    background-color: #0069d9;
    transform: translateY(-2px);
}


.primary-language-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.primary-language-tab {
    padding: 6px 12px;
    background-color: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.primary-language-tab:hover {
    border-color: #4299e1;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.primary-language-tab.has-submenu::after {
    content: "▼";
    font-size: 10px;
    margin-left: 5px;
}

.primary-language-tab.active {
    background-color: #4299e1;
    color: white;
    border-color: #4299e1;
}

.primary-language-tab.active.has-submenu::after {
    content: "▲";
}

.secondary-language-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: 4px;
}

.dropdown-arrow {
    position: absolute;
    top: -6px;
    left: 30px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-left: 1px solid #d9d9d9;
    border-top: 1px solid #d9d9d9;
    transform: rotate(45deg);
}

.dropdown-content {
    padding: 8px;
}

.secondary-options-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
}

.secondary-option-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 14px;
    border-radius: 4px;
}

.secondary-option-item:hover {
    background-color: #0086cd;
}

.secondary-option-item.selected {
    background-color: #0086cd;
    font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .primary-language-tabs {
        padding: 8px;
    }

    .primary-language-tab {
        padding: 4px 8px;
        font-size: 13px;
    }
}
