<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;
}

/* 隐藏滚动条，表格区域仍可滚动 */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* 管理端列表页：占满主区域，表头固定、表体滚动，底部分页 */
.admin-list-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.admin-list-page > .page-header,
.admin-list-page > .filter-card,
.admin-list-page > .tool-card {
  flex-shrink: 0;
}
.admin-list-page > .tool-card {
  margin-bottom: 16px;
}
.admin-list-page > .filter-card {
  margin-bottom: 16px;
}
.admin-list-page > .page-header {
  margin-bottom: 20px;
}
.admin-list-page > .data-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
}
.admin-list-page > .data-card .el-card__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
}
.admin-list-page .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.admin-list-page .table-wrap .el-table {
  height: 100% !important;
}
.admin-list-page .pager {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  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;
  backdrop-filter: blur(10px);
}
.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: #555 !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-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: var(--text-muted) !important; font-size: 11px !important; font-weight: 600 !important; letter-spacing: 0.04em !important; }

.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; }
</style>
