/* =====================================================================
 * oc_country_switcher.css — 国家/地区切换器样式
 * 同时适配 header.php 的 #promoBtn（常规页）与 _sidebar.php 的 uc-jd-nav（用户中心）
 * 设计：
 *   - 默认外观：一个 chip：🌐 国旗 + 中文名 + ▼，点击展开下拉面板
 *   - 下拉面板：分国家/地区列表（每个项：旗帜 emoji + 中文名 + 选中 ✓ + 文案）
 *   - 移动端：chip 全宽；面板全屏 90vh
 *   - 颜色：电商红 #dc2626 主色 + 浅蓝 #1e90ff hover
 *   - 严格遵守 JS 规范：基于 jQuery，与现有 oc_global.js 一致
 * ===================================================================== */
:root {
  --oc-cs-z: 9999;
  --oc-cs-bg: #ffffff;
  --oc-cs-text: #1e293b;
  --oc-cs-text-mute: #64748b;
  --oc-cs-border: #e2e8f0;
  --oc-cs-hover: #f8fafc;
  --oc-cs-primary: #dc2626;
  --oc-cs-link: #1e90ff;
  --oc-cs-shadow: 0 12px 32px rgba(15, 23, 42, .12);
  --oc-cs-radius: 10px;
}

.oc-cs-root { position: relative; display: inline-block; font-size: 13px; z-index: 99999; }

/* === Chip 触发器 === */
.oc-cs-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: #fff; border: 1px solid var(--oc-cs-border);
  border-radius: 999px; cursor: pointer;
  color: var(--oc-cs-text); font-size: 13px; line-height: 1.2;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
  white-space: nowrap;
  user-select: none;
}
.oc-cs-chip:hover { background: #fef2f2; border-color: #fecaca; }
.oc-cs-chip .flag { font-size: 16px; line-height: 1; }
.oc-cs-chip .flag img { width: 22px; height: 22px; border-radius: 50%; display: block; object-fit: contain; }
.oc-cs-chip .name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.oc-cs-chip .arrow {
  display: inline-block; width: 8px; height: 8px;
  border-right: 1.5px solid var(--oc-cs-text-mute);
  border-bottom: 1.5px solid var(--oc-cs-text-mute);
  transform: translateY(-2px) rotate(45deg);
  transition: transform .2s ease;
}
.oc-cs-root.is-open .oc-cs-chip { background: #fef2f2; border-color: var(--oc-cs-primary); box-shadow: 0 2px 8px rgba(220,38,38,.15); }
.oc-cs-root.is-open .oc-cs-chip .arrow { transform: translateY(1px) rotate(-135deg); }

/* === 下拉面板 === */
.oc-cs-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 300px; max-height: 420px; overflow: auto;
  background: var(--oc-cs-bg); border: 1px solid var(--oc-cs-border);
  border-radius: var(--oc-cs-radius);
  box-shadow: var(--oc-cs-shadow);
  padding: 8px 0;
  display: none;
  z-index: var(--oc-cs-z);
}
.oc-cs-root.is-open .oc-cs-panel { display: block; }

/* 头部：当前 + 分组 */
.oc-cs-panel-head {
  padding: 10px 14px 6px;
  font-size: 11px;
  color: var(--oc-cs-text-mute);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  border-bottom: 1px solid var(--oc-cs-border);
  margin-bottom: 4px;
}
.oc-cs-panel-head .current-flag { font-size: 14px; margin-right: 4px; }

/* 列表项 */
.oc-cs-list { list-style: none; margin: 0; padding: 0; }
.oc-cs-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  cursor: pointer; color: var(--oc-cs-text);
  font-size: 13.5px;
  transition: background .12s ease;
}
.oc-cs-item:hover { background: var(--oc-cs-hover); }
.oc-cs-item.is-current { background: #fef2f2; color: var(--oc-cs-primary); font-weight: 600; }
.oc-cs-item .flag { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
/* 2026-08-09 方案 B：下拉列表 SVG 圆形国旗 */
.oc-cs-item .flag img { width: 20px; height: 20px; border-radius: 50%; display: block; object-fit: contain; margin: 0 auto; }
.oc-cs-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.oc-cs-item .curr-mark {
  display: none;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--oc-cs-primary);
  flex-shrink: 0;
}
.oc-cs-item.is-current .curr-mark { display: inline-block; }

/* 底部链接 */
.oc-cs-panel-foot {
  border-top: 1px solid var(--oc-cs-border);
  padding: 8px 14px;
  font-size: 12px;
}
.oc-cs-panel-foot a {
  color: var(--oc-cs-link);
  text-decoration: none;
}
.oc-cs-panel-foot a:hover { text-decoration: underline; }

/* === 顶栏促销位（替换 #promoBtn）专用样式 === */
.oc-promo-slot { display: inline-flex; align-items: center; }
.oc-promo-slot .oc-cs-chip {
  padding: 6px 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
}
.oc-promo-slot .oc-cs-chip:hover { background: #f1f5f9; color: var(--oc-cs-text); }
.oc-promo-slot .oc-cs-chip .name { max-width: 90px; font-size: 12.5px; }
.oc-promo-slot .oc-cs-chip .flag { font-size: 14px; }
.oc-promo-slot .oc-cs-chip .arrow { width: 7px; height: 7px; }

/* === 仅显示 flag 模式（顶栏 #promoBtn 2026-08-09）：隐藏 name+arrow ===
   个人中心 .uc-cs-slot 不加此 class，保持原 flag+name+arrow。 */
.oc-cs-flag-only .name,
.oc-cs-flag-only .arrow { display: none !important; }
.oc-cs-flag-only .flag { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
/* 方案 B：SVG 圆形国旗（顶栏 28px，无背景不裁切）；emoji 字符按正常字号 */
.oc-cs-flag-only .flag img {
  width: 28px; height: 28px;
  display: block;
  object-fit: contain;
  border-radius: 50%;
}

/* === 用户中心 uc-jd-nav 专用（与 #promoBtn 平级） === */
.uc-cs-slot { display: inline-block; vertical-align: middle; margin: 0 4px; }
.uc-cs-slot .oc-cs-chip {
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(255,255,255,.5);
}
.uc-cs-slot .oc-cs-chip .name { max-width: 90px; }

/* === 加载状态 === */
.oc-cs-loading {
  padding: 20px;
  text-align: center;
  color: var(--oc-cs-text-mute);
  font-size: 13px;
}
.oc-cs-loading .spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid #f1f5f9; border-top-color: var(--oc-cs-primary);
  border-radius: 50%;
  animation: oc-cs-spin .8s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes oc-cs-spin { to { transform: rotate(360deg); } }

/* === 移动端 === */
@media (max-width: 640px) {
  .oc-cs-panel {
    position: fixed; top: 60px; left: 16px; right: 16px;
    width: auto; max-height: calc(100vh - 80px);
  }
  .oc-cs-panel-foot {
    padding: 12px 14px;
  }
}
