/* RTL Styles for Arabic Version */

/* 基本文档方向设置 */
html[dir="rtl"] body {
    text-align: right;
    direction: rtl;
    font-family: 'Amiri', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 列表项样式 - 确保圆点在右侧 */
html[dir="rtl"] ul {
    padding-right: 0;
    padding-left: 0;
    margin-right: 0;
    margin-left: 0;
    list-style-type: none;
}

html[dir="rtl"] .port-classifications,
html[dir="rtl"] .port-kpis {
    list-style-position: inside;
    padding-right: 20px;
    padding-left: 0;
}

html[dir="rtl"] .port-classifications li,
html[dir="rtl"] .port-kpis li {
    text-align: right;
    position: relative;
    padding-right: 20px;
    margin-right: 0;
    list-style-type: none;
    margin-bottom: 8px;
}

html[dir="rtl"] .port-classifications li::before,
html[dir="rtl"] .port-kpis li::before {
    content: "•";
    position: absolute;
    right: 0;
    top: 0;
    display: inline-block;
    width: 20px;
    text-align: center;
}

/* 修复列表中的strong标签位置 */
html[dir="rtl"] .port-classifications li strong,
html[dir="rtl"] .port-kpis li strong {
    display: inline-block;
    margin-left: 8px;
}

/* 导航和标题对齐 */
html[dir="rtl"] .logo-container {
    margin-right: 0;
    margin-left: 20px;
}

/* 修改 .controls-group 的样式 */
.controls-group {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-right: 20px;
  width: 100%;
}

/* select2 容器样式 */
.select2-container {
  width: 200px !important;  /* PC端固定宽度 */
}

/* legend 容器样式 */
.legend {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* 重新定义图例项目的RTL布局，确保圆点在右侧 */
html[dir="rtl"] .legend-item {
    position: relative;
    padding: 0.5rem 1rem;
    text-align: right;
    display: block;
    flex-direction: initial;
}

html[dir="rtl"] .legend-color {
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    left: auto !important;
}

html[dir="rtl"] .legend-item span {
    text-align: right;
    padding-right: 15px;
    display: inline-block;
}

/* Select2 下拉菜单RTL支持 */
html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow {
    left: 1px;
    right: auto;
}

html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-right: 10px;
    padding-left: 20px;
    text-align: right;
}

html[dir="rtl"] .select2-results {
    text-align: right;
}

/* 国家列表容器 */
html[dir="rtl"] .country-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

html[dir="rtl"] .country-item {
    padding-right: 20px;
    padding-left: 15px;
    position: relative;
    text-align: right;
}

html[dir="rtl"] .country-item-name {
    display: inline-block;
    text-align: right;
    padding-right: 5px;
}

html[dir="rtl"] .country-item:before {
    right: 0;
    left: auto;
    content: "•";
    position: absolute;
    display: inline-block;
    width: 20px;
    text-align: center;
    transform: none;
}

/* 移动端竖屏下每行显示两个国家项目 */
@media (max-width: 576px) and (orientation: portrait) {
    html[dir="rtl"] .country-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    html[dir="rtl"] .country-item {
        padding-right: 15px;
        padding-left: 5px;
        font-size: 0.9em;
    }
}

/* 港口信息部分 */
html[dir="rtl"] .section-title,
html[dir="rtl"] .section-subtitle,
html[dir="rtl"] .section-content p,
html[dir="rtl"] .port-classifications li,
html[dir="rtl"] .port-kpis li {
    text-align: right;
}

html[dir="rtl"] .port-classifications li strong,
html[dir="rtl"] .port-kpis li strong {
    margin-right: 0;
    margin-left: 5px;
}

/* 统计信息网格 */
html[dir="rtl"] .stats-grid {
    direction: rtl;
}

html[dir="rtl"] .stats-item {
    text-align: right;
}

/* 页脚样式 */
html[dir="rtl"] .footer-title,
html[dir="rtl"] .footer-description,
html[dir="rtl"] .footer-links li a,
html[dir="rtl"] .contact-info li {
    text-align: right;
}

html[dir="rtl"] .contact-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .contact-item svg {
    margin-right: 0;
    margin-left: 10px;
}

html[dir="rtl"] .social-links {
    justify-content: flex-start;
}

html[dir="rtl"] .social-link {
    margin-right: 0;
    margin-left: 15px;
}

html[dir="rtl"] .footer-bottom {
    flex-direction: row-reverse;
}

html[dir="rtl"] .footer-bottom-links a {
    margin-right: 0;
    margin-left: 20px;
}

html[dir="rtl"] .footer-bottom-links a:last-child {
    margin-left: 0;
}

/* 阿拉伯语字体大小调整 */
html[dir="rtl"] h1, 
html[dir="rtl"] h2, 
html[dir="rtl"] h3 {
    font-size: 1.1em;
    line-height: 1.5;
}

html[dir="rtl"] p, 
html[dir="rtl"] li, 
html[dir="rtl"] a {
    font-size: 1em;
    line-height: 1.6;
}

/* 媒体查询，适应移动设备 */
@media screen and (max-width: 768px) {
  .controls-group {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-right: 0;
  }
  
  /* 移动端下的 select2 容器样式 */
  .select2-container {
    width: 100% !important;
    min-width: 100% !important;
  }
  
  /* 移动端下的 legend 样式 */
  .legend {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* 页脚链接列表 */
html[dir="rtl"] .footer-links li {
    text-align: right;
    position: relative;
    padding-right: 15px;
    margin-right: 0;
    list-style-type: none;
    margin-bottom: 8px;
}

html[dir="rtl"] .footer-links li::before {
    content: "•";
    position: absolute;
    right: 0;
    top: 0;
    display: inline-block;
    width: 15px;
    text-align: center;
}

/* 联系信息列表 */
html[dir="rtl"] .contact-info li.contact-item {
    padding-right: 0;
}

html[dir="rtl"] .contact-info li.contact-item::before {
    content: none;
}

/* Contact information alignment */
.contact-info {
    direction: rtl;
    text-align: right;
}

.contact-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.contact-item svg {
    order: 2;
}

.contact-item span {
    order: 1;
}

/* Ensure links in contact info are right-aligned */
.contact-item a {
    text-align: right;
    display: inline-block;
}

/* Footer links alignment */
.footer-links {
    text-align: right;
}

/* Ensure footer columns are properly aligned */
.footer-column {
    text-align: right;
}

/* Additional RTL styles can be added here */
.country-list[dir="rtl"] .country-group-title {
    text-align: right;
}

.country-list[dir="rtl"] .country-item {
    text-align: right;
}

/* 确保地图控件在 RTL 模式下正确显示 */
.leaflet-control-container .leaflet-control {
    margin-right: 10px !important;
}

/* Select2 RTL 支持 */
.select2-container--default[dir="rtl"] .select2-selection--single {
    text-align: right;
}