/**
 * 多语言UI优化样式
 * 特别针对非中文语言的显示优化
 */

/* ========== 全局字体优化 ========== */
html {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* 中文优化 */
html[lang="zh-CN"],
html[lang="zh"],
body:lang(zh-CN),
body:lang(zh) {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', 'STHeiti', 'SimSun', sans-serif;
}

/* 英文优化 */
html[lang="en-US"],
html[lang="en"],
body:lang(en-US),
body:lang(en) {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: 0.01em;
}

/* 韩语优化 */
html[lang="ko-KR"],
html[lang="ko"],
body:lang(ko-KR),
body:lang(ko) {
    font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', 'Nanum Gothic', sans-serif;
    word-spacing: 0.1em;
}

/* 俄语优化 */
html[lang="ru-RU"],
html[lang="ru"],
body:lang(ru-RU),
body:lang(ru) {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: 0.02em;
}

/* 波斯语优化（RTL） */
html[lang="fa-IR"],
html[lang="fa"],
body:lang(fa-IR),
body:lang(fa) {
    font-family: 'Tahoma', 'Arial', 'Helvetica', sans-serif;
    direction: rtl;
    text-align: right;
}

/* 阿拉伯语优化（RTL） */
html[lang="ar-SA"],
html[lang="ar"],
body:lang(ar-SA),
body:lang(ar) {
    font-family: 'Tahoma', 'Arial', 'Helvetica', sans-serif;
    direction: rtl;
    text-align: right;
}

/* ========== 语言选择器美化 ========== */
.language-selector {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.language-selector select {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    padding: 8px 35px 8px 15px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 120px;
}

.language-selector select:hover {
    background-color: rgba(255, 255, 255, 1);
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.language-selector select:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.8);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

/* RTL语言选择器位置调整 */
html[lang="fa-IR"] .language-selector,
html[lang="ar-SA"] .language-selector,
body:lang(fa-IR) .language-selector,
body:lang(ar-SA) .language-selector {
    right: auto;
    left: 20px;
}

/* ========== 文本内容优化 ========== */
/* 标题优化 */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.4;
    font-weight: 600;
}

/* 英文标题优化 */
html[lang="en-US"] h1,
html[lang="en-US"] h2,
html[lang="en-US"] h3,
body:lang(en-US) h1,
body:lang(en-US) h2,
body:lang(en-US) h3 {
    letter-spacing: -0.02em;
    line-height: 1.3;
}

/* 段落优化 */
p {
    line-height: 1.8;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 英文段落优化 */
html[lang="en-US"] p,
body:lang(en-US) p {
    line-height: 1.7;
    letter-spacing: 0.01em;
}

/* 韩语段落优化 */
html[lang="ko-KR"] p,
body:lang(ko-KR) p {
    line-height: 1.9;
    word-spacing: 0.05em;
}

/* 俄语段落优化 */
html[lang="ru-RU"] p,
body:lang(ru-RU) p {
    line-height: 1.8;
    letter-spacing: 0.01em;
}

/* RTL语言段落优化 */
html[lang="fa-IR"] p,
html[lang="ar-SA"] p,
body:lang(fa-IR) p,
body:lang(ar-SA) p {
    line-height: 2;
    text-align: right;
}

/* ========== 按钮优化 ========== */
.btn,
button,
.downloadBtn,
.disableBtn {
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    line-height: 1.5;
}

/* 英文按钮优化 */
html[lang="en-US"] .btn,
html[lang="en-US"] button,
html[lang="en-US"] .downloadBtn,
body:lang(en-US) .btn,
body:lang(en-US) button,
body:lang(en-US) .downloadBtn {
    letter-spacing: 0.3px;
    padding: 12px 28px;
}

/* RTL语言按钮优化 */
html[lang="fa-IR"] .btn,
html[lang="ar-SA"] .btn,
html[lang="fa-IR"] button,
html[lang="ar-SA"] button,
body:lang(fa-IR) .btn,
body:lang(ar-SA) .btn,
body:lang(fa-IR) button,
body:lang(ar-SA) button {
    direction: rtl;
}

/* ========== 卡片和容器优化 ========== */
.card,
.payresult-container,
.plan-box,
.top-container {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.card:hover,
.plan-box:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* ========== 表格优化 ========== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* RTL语言表格优化 */
html[lang="fa-IR"] table,
html[lang="ar-SA"] table,
body:lang(fa-IR) table,
body:lang(ar-SA) table {
    direction: rtl;
}

/* ========== 列表优化 ========== */
ul, ol {
    padding-left: 20px;
}

/* RTL语言列表优化 */
html[lang="fa-IR"] ul,
html[lang="ar-SA"] ul,
html[lang="fa-IR"] ol,
html[lang="ar-SA"] ol,
body:lang(fa-IR) ul,
body:lang(ar-SA) ul,
body:lang(fa-IR) ol,
body:lang(ar-SA) ol {
    padding-left: 0;
    padding-right: 20px;
}

/* ========== 表单元素优化 ========== */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    padding: 10px 15px;
    font-size: 16px;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* RTL语言表单优化 */
html[lang="fa-IR"] input,
html[lang="ar-SA"] input,
html[lang="fa-IR"] textarea,
html[lang="ar-SA"] textarea,
body:lang(fa-IR) input,
body:lang(ar-SA) input,
body:lang(fa-IR) textarea,
body:lang(ar-SA) textarea {
    direction: rtl;
    text-align: right;
}

/* ========== 导航栏优化 ========== */
.top-banner-box,
.navbar,
.nav {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

/* RTL语言导航栏优化 */
html[lang="fa-IR"] .top-banner-box,
html[lang="ar-SA"] .top-banner-box,
body:lang(fa-IR) .top-banner-box,
body:lang(ar-SA) .top-banner-box {
    direction: rtl;
}

/* ========== 页脚优化 ========== */
.footer-box {
    text-align: center;
}

/* RTL语言页脚优化 */
html[lang="fa-IR"] .footer-box,
html[lang="ar-SA"] .footer-box,
body:lang(fa-IR) .footer-box,
body:lang(ar-SA) .footer-box {
    direction: rtl;
    text-align: right;
}

/* ========== 响应式优化 ========== */
@media (max-width: 768px) {
    .language-selector {
        top: 5px;
        right: 10px;
    }
    
    .language-selector select {
        font-size: 12px;
        padding: 6px 30px 6px 12px;
        min-width: 100px;
    }
    
    /* RTL语言移动端优化 */
    html[lang="fa-IR"] .language-selector,
    html[lang="ar-SA"] .language-selector,
    body:lang(fa-IR) .language-selector,
    body:lang(ar-SA) .language-selector {
        right: auto;
        left: 10px;
    }
    
    /* 移动端字体大小优化 */
    html[lang="en-US"] p,
    html[lang="ru-RU"] p,
    body:lang(en-US) p,
    body:lang(ru-RU) p {
        font-size: 15px;
    }
    
    html[lang="ko-KR"] p,
    body:lang(ko-KR) p {
        font-size: 15px;
    }
}

/* ========== 特殊字符和长文本处理 ========== */
/* 处理长单词（如德语、俄语） */
.word-break {
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

html[lang="ru-RU"] *,
html[lang="de"] *,
body:lang(ru-RU) *,
body:lang(de) * {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ========== 动画优化 ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* ========== 价格显示优化 ========== */
.price_amount,
.price_tag {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ========== 图标和符号对齐 ========== */
.icon-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* RTL语言图标对齐 */
html[lang="fa-IR"] .icon-text,
html[lang="ar-SA"] .icon-text,
body:lang(fa-IR) .icon-text,
body:lang(ar-SA) .icon-text {
    flex-direction: row-reverse;
}

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* ========== 加载状态优化 ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: rgba(102, 126, 234, 1);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== 工具提示优化 ========== */
[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-top: 5px;
}

/* ========== 打印样式优化 ========== */
@media print {
    .language-selector {
        display: none;
    }
    
    html[lang="fa-IR"],
    html[lang="ar-SA"],
    body:lang(fa-IR),
    body:lang(ar-SA) {
        direction: rtl;
    }
}

