<script setup lang="ts">
import { computed } from 'vue';
import { RouterView } from 'vue-router';
import { ElConfigProvider } from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import en from 'element-plus/es/locale/lang/en';
import ms from 'element-plus/es/locale/lang/ms';
import { useAdminLocale } from './composables/useAdminLocale';

const { locale } = useAdminLocale();

const elLocale = computed(() => {
  if (locale.value.startsWith('zh')) return zhCn;
  if (locale.value.startsWith('ms')) return ms;
  return en;
});
</script>

<template>
  <ElConfigProvider :locale="elLocale">
    <RouterView />
  </ElConfigProvider>
</template>

<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

:root {
  /* 质感绿：深底 + 渐变高光，避免扁平荧光绿 */
  --green-deep:    #145c38;
  --green-mid:     #1f8a52;
  --green-bright:  #2fb56a;
  --green-glow:    #4dd68a;
  --green-surface: rgba(20, 72, 46, 0.45);
  --green-border:  rgba(77, 214, 138, 0.28);
  --green-text:    #9ae8bc;
  --primary:       var(--green-mid);
  --primary-dark:  var(--green-deep);
  --primary-light: var(--green-bright);
  --primary-link:  var(--green-text);
  --primary-on:    #ffffff;
  --primary-grad:  linear-gradient(165deg, #3cc474 0%, #248f54 42%, #1a6b40 100%);
  --primary-grad-hover: linear-gradient(165deg, #4dd68a 0%, #2ea864 42%, #1f7a48 100%);
  --primary-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset, 0 2px 10px rgba(0, 0, 0, 0.45), 0 0 20px rgba(36, 143, 84, 0.18);
  --bg-body:       #000000;
  --bg-card:       rgba(20, 20, 20, 0.85);
  --bg-elevated:   rgba(28, 28, 28, 0.9);
  --bg-hover:      rgba(36, 143, 84, 0.1);
  --text:          #ffffff;
  --text-muted:    #8e8e93;
  --border:        #2a2a2a;
  --border-soft:   var(--green-border);
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 20px rgba(0, 0, 0, 0.55);

  /* Element Plus dark overrides */
  --el-bg-color:              #141414;
  --el-bg-color-page:         #000000;
  --el-bg-color-overlay:      #1c1c1c;
  --el-text-color-primary:    #ffffff;
  --el-text-color-regular:    #cccccc;
  --el-text-color-secondary:  #8e8e93;
  --el-text-color-placeholder:#4a4a4a;
  --el-border-color:          #2a2a2a;
  --el-border-color-light:    #222;
  --el-border-color-lighter:  #1a1a1a;
  --el-fill-color:            #1a1a1a;
  --el-fill-color-blank:      #0d0d0d;
  --el-fill-color-light:      #141414;
  --el-color-primary:         #248f54;
  --el-color-primary-light-3: rgba(47, 181, 106, 0.35);
  --el-color-primary-light-5: rgba(47, 181, 106, 0.2);
  --el-color-primary-light-7: rgba(47, 181, 106, 0.12);
  --el-color-primary-light-9: rgba(47, 181, 106, 0.06);
  --el-color-primary-dark-2:  #1a6b40;
  --el-table-bg-color:             transparent;
  --el-table-tr-bg-color:          transparent;
  --el-table-header-bg-color:      rgba(255,255,255,0.03);
  --el-table-row-hover-bg-color:   rgba(36, 143, 84, 0.08);
  --el-table-border-color:         #222;
  --el-table-text-color:           #ccc;
  --el-table-header-text-color:    #666;
  --el-card-bg-color:              rgba(20,20,20,0.85);
  --el-card-border-color:          #2a2a2a;
}

html, body, #app {
  height: 100%;
  overflow: hidden;
}

/* 页面级隐藏滚动条；可滚动区域保留细滚动条便于发现溢出内容 */
html, body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.admin-list-page .table-wrap,
.dashboard-page,
.page-scroll,
.settlement-page,
.nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.admin-list-page .table-wrap::-webkit-scrollbar,
.dashboard-page::-webkit-scrollbar,
.page-scroll::-webkit-scrollbar,
.settlement-page::-webkit-scrollbar,
.nav::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  display: block;
}
.admin-list-page .table-wrap::-webkit-scrollbar-thumb,
.dashboard-page::-webkit-scrollbar-thumb,
.page-scroll::-webkit-scrollbar-thumb,
.settlement-page::-webkit-scrollbar-thumb,
.nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 3px;
}

/* 管理端列表页：占满主区域，表头固定、表体滚动，底部分页 */
.admin-list-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.admin-list-page > .page-toolbar,
.admin-list-page > .filter-card,
.admin-list-page > .tool-card,
.admin-list-page > .list-chrome,
.admin-list-page > .list-settings {
  flex-shrink: 0;
}
.admin-list-page > .page-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}
.admin-list-page > .tool-card {
  margin-bottom: 8px;
}
.admin-list-page > .filter-card {
  margin-bottom: 8px;
}
.admin-list-page > .list-chrome {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.list-chrome__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  --list-chrome-control-h: 32px;
  --el-component-size: 32px;
}
.list-chrome__left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 12px;
  flex-wrap: nowrap;
}
.list-chrome__filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  flex: 1;
  min-width: 0;
}
.list-chrome__field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.list-chrome__label {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}
.list-chrome__grow {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 8px;
}
.list-chrome__grow.el-form--inline {
  display: flex !important;
  align-items: center;
}
.list-chrome__left .matches-subnav--embedded {
  align-self: center;
  height: var(--list-chrome-control-h);
}
.list-chrome__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.list-chrome :deep(.el-form-item) {
  margin-bottom: 0 !important;
  margin-right: 12px;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.list-chrome :deep(.el-form-item__label) {
  display: inline-flex;
  align-items: center;
  height: var(--list-chrome-control-h);
  line-height: 1;
  padding: 0 8px 0 0;
  margin-bottom: 0 !important;
}
.list-chrome :deep(.el-form-item__content) {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.list-chrome :deep(.el-input__wrapper),
.list-chrome :deep(.el-select__wrapper) {
  height: var(--list-chrome-control-h) !important;
  min-height: var(--list-chrome-control-h) !important;
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
}
.list-chrome :deep(.el-input__inner) {
  height: calc(var(--list-chrome-control-h) - 2px);
  line-height: calc(var(--list-chrome-control-h) - 2px);
}
.list-chrome :deep(.el-button:not(.is-link)) {
  height: var(--list-chrome-control-h) !important;
  min-height: var(--list-chrome-control-h) !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1;
}
.list-chrome :deep(.el-form-item:last-child) {
  margin-right: 0;
}
.admin-list-page > .list-settings {
  margin-bottom: 8px;
}
.list-settings :deep(.el-collapse-item__header) {
  height: 36px;
  line-height: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.05);
}
.list-settings :deep(.el-collapse-item__wrap) {
  border-color: rgba(255, 255, 255, 0.05);
}
.list-settings :deep(.el-collapse-item__content) {
  padding: 8px 10px 10px;
}
.list-settings-block + .list-settings-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.list-settings-title {
  font-size: 12px;
  font-weight: 600;
  color: #aaa;
  margin-bottom: 6px;
}
.admin-list-page > .data-card,
.admin-list-page > .list-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
}
.admin-list-page > .list-panel {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: #121212;
  padding: 0 10px 10px;
}
.admin-list-page > .data-card .el-card__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 12px 12px;
}
.admin-list-page .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.admin-list-page .table-wrap .el-table {
  height: 100% !important;
}
.admin-list-page .table-wrap .el-table th.el-table__cell .cell {
  white-space: nowrap;
}
.admin-list-page .list-hint {
  flex-shrink: 0;
  margin: 0;
  padding: 6px 0 8px;
  font-size: 11px;
  color: #666;
  line-height: 1.4;
}
.admin-list-page .pager {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 0;
}

/* 控制台等非列表页：允许内部滚动（滚动条已全局隐藏） */
.dashboard-page,
.page-scroll {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.12'/%3E%3C/svg%3E"),
    linear-gradient(rgba(0,0,0,0.97), rgba(0,0,0,0.97)),
    radial-gradient(ellipse 90% 45% at 50% -8%, rgba(31, 138, 82, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 30% at 80% 100%, rgba(20, 92, 56, 0.08), transparent 50%);
  background-size: 150px, cover, cover;
  background-color: #000;
  color: #fff;
  -webkit-font-smoothing: antialiased;
}

/* ── Element Plus 全局暗色覆盖 ── */
.el-card {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
}
.el-card__header {
  border-bottom-color: #1e1e1e !important;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.el-table { background: transparent !important; color: #ccc !important; }
.el-table::before { background-color: #222 !important; }
.el-table th.el-table__cell {
  background: rgba(255,255,255,0.02) !important;
  color: #888 !important;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom-color: #1e1e1e !important;
}
.el-table td.el-table__cell { border-bottom-color: #161616 !important; color: #bbb !important; }
.el-table--striped .el-table__body tr.el-table__row--striped td { background: rgba(255,255,255,0.015) !important; }
.el-table__body tr:hover > td { background: rgba(36, 143, 84, 0.07) !important; }

.el-input__wrapper {
  background: #0d0d0d !important;
  box-shadow: 0 0 0 1px #2a2a2a inset !important;
  border-radius: var(--radius-sm) !important;
}
.el-input__wrapper:hover  { box-shadow: 0 0 0 1px #3a3a3a inset !important; }
.el-input__wrapper.is-focus {
  box-shadow: 0 0 0 1px var(--green-mid) inset, 0 0 0 3px rgba(47, 181, 106, 0.15) !important;
}
.el-input__inner { color: #fff !important; background: transparent !important; }
.el-input__inner:-webkit-autofill,
.el-input__inner:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #0d0d0d inset !important;
  -webkit-text-fill-color: #fff !important;
}

.el-button { background: #141414 !important; border-color: #2a2a2a !important; color: #aaa !important; }
.el-button:hover { background: #1e1e1e !important; border-color: #3a3a3a !important; color: #fff !important; }
.el-button--primary {
  background: var(--primary-grad) !important;
  border: 1px solid var(--green-border) !important;
  color: var(--primary-on) !important;
  font-weight: 700 !important;
  box-shadow: var(--primary-shadow) !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}
.el-button--primary:hover {
  background: var(--primary-grad-hover) !important;
  border-color: rgba(120, 230, 170, 0.4) !important;
  color: var(--primary-on) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 24px rgba(47, 181, 106, 0.28) !important;
}
.el-button--success {
  background: var(--green-surface) !important;
  border: 1px solid var(--green-border) !important;
  color: var(--green-text) !important;
  backdrop-filter: blur(6px);
}
.el-button--success:hover {
  background: rgba(36, 143, 84, 0.35) !important;
  border-color: rgba(120, 230, 170, 0.45) !important;
  color: #d4fde5 !important;
}
.el-button--warning  { background: rgba(251,191,36,0.1) !important; border-color: rgba(251,191,36,0.35) !important; color: #fbbf24 !important; }
.el-button--danger   { background: rgba(255,69,58,0.1) !important;  border-color: rgba(255,69,58,0.35) !important;  color: #ff453a !important; }
.el-button--primary.is-plain {
  background: rgba(36, 143, 84, 0.12) !important;
  border-color: var(--green-border) !important;
  color: var(--green-text) !important;
  box-shadow: none !important;
}
.el-button--primary.is-plain:hover {
  background: rgba(36, 143, 84, 0.22) !important;
  border-color: rgba(120, 230, 170, 0.45) !important;
  color: #d4fde5 !important;
}
.el-button--danger.is-plain {
  background: rgba(255, 69, 58, 0.08) !important;
  border-color: rgba(255, 69, 58, 0.35) !important;
  color: #ff6b62 !important;
  box-shadow: none !important;
}
.el-button--danger.is-plain:hover {
  background: rgba(255, 69, 58, 0.16) !important;
  border-color: rgba(255, 120, 110, 0.5) !important;
  color: #ff8a82 !important;
}
.el-button.is-text,
.el-button.is-link.el-button--default {
  color: var(--green-text) !important;
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
.el-button.is-text:hover,
.el-button.is-link.el-button--default:hover {
  color: #d4fde5 !important;
  background: rgba(36, 143, 84, 0.1) !important;
}
.el-button--primary.is-plain {
  background: rgba(36, 143, 84, 0.12) !important;
  border-color: var(--green-border) !important;
  color: var(--green-text) !important;
}
.el-button--primary.is-plain:hover {
  background: rgba(36, 143, 84, 0.22) !important;
  border-color: rgba(120, 230, 170, 0.45) !important;
  color: #d4fde5 !important;
}
.el-button--danger.is-plain {
  background: rgba(255, 69, 58, 0.08) !important;
  border-color: rgba(255, 69, 58, 0.35) !important;
  color: #ff6961 !important;
}
.el-button--danger.is-plain:hover {
  background: rgba(255, 69, 58, 0.18) !important;
  border-color: rgba(255, 120, 110, 0.5) !important;
  color: #ff8a82 !important;
}

.el-tag { border-radius: 4px !important; font-size: 11px !important; font-weight: 600 !important; }
.el-tag--success {
  background: linear-gradient(135deg, rgba(36, 143, 84, 0.35), rgba(20, 92, 56, 0.5)) !important;
  border: 1px solid var(--green-border) !important;
  color: #c8f5d8 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.el-tag--warning { background: rgba(251,191,36,0.1) !important; border-color: rgba(251,191,36,0.3) !important; color: #fbbf24 !important; }
.el-tag--danger  { background: rgba(255,69,58,0.1) !important; border-color: rgba(255,69,58,0.3) !important; color: #ff453a !important; }
.el-tag--info    { background: rgba(255,255,255,0.06) !important; border-color: #3a3a3a !important; color: #aaa !important; }

/* 表格操作按钮：渐变绿 + 白字 */
.el-button.is-link.el-button--primary,
.el-button.is-link.el-button--success {
  color: #ffffff !important;
  background: var(--primary-grad) !important;
  border: 1px solid var(--green-border) !important;
  border-radius: 6px !important;
  padding: 5px 11px !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 1px 6px rgba(0, 0, 0, 0.35) !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.el-button.is-link.el-button--primary:hover,
.el-button.is-link.el-button--primary:focus,
.el-button.is-link.el-button--success:hover,
.el-button.is-link.el-button--success:focus {
  color: #ffffff !important;
  background: var(--primary-grad-hover) !important;
  border-color: rgba(120, 230, 170, 0.45) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.16) inset, 0 2px 10px rgba(0, 0, 0, 0.4), 0 0 16px rgba(47, 181, 106, 0.25) !important;
}

.el-form-item__label { color: #aaa !important; font-size: 12px !important; font-weight: 600 !important; letter-spacing: 0.02em !important; }

/* ── Dialog / overlay：实心背景，避免噪点透底发糊 ── */
.el-overlay {
  background-color: rgba(0, 0, 0, 0.72) !important;
  backdrop-filter: none !important;
}
.el-dialog {
  background: #1a1a1a !important;
  border: 1px solid #333 !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65) !important;
}
.el-dialog__header {
  border-bottom: 1px solid #2a2a2a !important;
  padding: 16px 20px 14px !important;
  margin-right: 0 !important;
}
.el-dialog__title {
  font-size: 16px !important;
  font-weight: 700 !important;
  color: #f0f0f0 !important;
  letter-spacing: 0.02em !important;
}
.el-dialog__headerbtn .el-dialog__close {
  color: #888 !important;
}
.el-dialog__headerbtn:hover .el-dialog__close {
  color: #fff !important;
}
.el-dialog__body {
  padding: 18px 20px !important;
  font-size: 14px !important;
  color: #ddd !important;
}
.el-dialog__footer {
  border-top: 1px solid #2a2a2a !important;
  padding: 12px 20px 16px !important;
}
.el-dialog .el-form-item__label {
  font-size: 13px !important;
  color: #aaa !important;
}
.el-dialog .el-descriptions__label {
  color: #888 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  background: #141414 !important;
}
.el-dialog .el-descriptions__content {
  color: #e0e0e0 !important;
  font-size: 13px !important;
  background: #1a1a1a !important;
}
.el-dialog .el-descriptions__cell {
  border-color: #2a2a2a !important;
}
.user-edit-dialog .el-dialog__body,
.agent-edit-dialog .el-dialog__body,
.create-account-dialog .el-dialog__body {
  max-height: min(70vh, 640px);
  overflow-y: auto;
}

.el-statistic__head { color: #555 !important; font-size: 11px !important; font-weight: 700 !important; letter-spacing: 0.06em !important; text-transform: uppercase !important; }
.el-statistic__content .el-statistic__number { font-size: 26px !important; font-weight: 800 !important; color: #fff !important; }

.el-input-number .el-input__wrapper { background: #0d0d0d !important; }
.el-date-editor .el-input__wrapper  { background: #0d0d0d !important; }
.el-date-editor .el-input__inner { color: #fff !important; }
.el-picker-panel {
  background: #1c1c1c !important;
  border-color: #333 !important;
  color: #ddd !important;
}
.el-picker-panel__footer { background: #1c1c1c !important; border-top-color: #333 !important; }
.el-date-picker__header-label,
.el-date-table th,
.el-date-table td .el-date-table-cell__text { color: #ccc !important; }
.el-time-panel { background: #1c1c1c !important; border-color: #333 !important; }
.el-time-spinner__item { color: #aaa !important; }
.el-time-spinner__item.is-active:not(.is-disabled) { color: #fff !important; }
</style>
