<script setup lang="ts">
import { useAuthStore } from '@/stores/auth'
import { computed } from 'vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

const auth = useAuthStore()
const isMobile = computed(() => {
  return /Android|iPhone|iPad|iPod|webOS/i.test(navigator.userAgent) || window.innerWidth < 768
})
</script>

<template>
  <el-config-provider :locale="zhCn">
    <router-view />
  </el-config-provider>
</template>

<style>
/* ═══════════════════════════════════════════════════════════
   企迹 (qiji) — Editorial/Magazine Design System
   Aesthetic: 编辑/杂志风格 | 墨色+朱砂+印泥金 | 站酷小薇体+思源宋体
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Core palette ── */
  --ink: #1C3738;
  --ink-light: #2A4F50;
  --ink-dark: #0F1F20;
  --vermilion: #B8472E;
  --vermilion-light: #D46A4F;
  --vermilion-dark: #8B3522;
  --gold: #C4934A;
  --gold-light: #D4AD6E;
  --gold-dark: #A67736;
  --paper: #F5F0E8;
  --paper-dark: #EBE4D8;
  --surface: #FFFFFF;
  --sage: #4A6741;
  --amber: #C68B3C;
  --warm-gray: #7B7568;
  --warm-border: #E5DFD3;

  /* ── Semantic tokens ── */
  --c-primary: var(--ink);
  --c-primary-light: var(--ink-light);
  --c-primary-bg: #EEF2F2;
  --c-accent: var(--vermilion);
  --c-accent-light: var(--vermilion-light);
  --c-gold: var(--gold);
  --c-success: var(--sage);
  --c-warning: var(--amber);
  --c-danger: var(--vermilion);
  --c-info: #5B7FA5;
  --c-text: #1A1A1A;
  --c-text-secondary: var(--warm-gray);
  --c-text-muted: #AAA59C;
  --c-bg: var(--paper);
  --c-bg-card: var(--surface);
  --c-border: var(--warm-border);

  /* ── Effects ── */
  --shadow-sm: 0 1px 2px rgba(28,55,56,0.04);
  --shadow: 0 2px 6px rgba(28,55,56,0.06);
  --shadow-md: 0 6px 18px rgba(28,55,56,0.08);
  --shadow-lg: 0 12px 36px rgba(28,55,56,0.10);
  --radius: 2px;
  --radius-sm: 2px;
  --radius-xs: 2px;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Sidebar — dark editorial ── */
  --sidebar-bg: var(--ink);
  --sidebar-color: #fff;
  --sidebar-accent: var(--gold);
  --sidebar-nav-text: rgba(255,255,255,0.55);
  --sidebar-nav-text-hover: rgba(255,255,255,0.85);
  --sidebar-nav-text-active: #fff;
  --sidebar-nav-bg-hover: rgba(255,255,255,0.04);
  --sidebar-nav-bg-active: rgba(255,255,255,0.06);
  --sidebar-nav-border-active: var(--gold);
  --sidebar-divider: rgba(255,255,255,0.06);
  --sidebar-brand-color: #fff;
  --sidebar-brand-sub-color: rgba(255,255,255,0.4);
  --sidebar-group-label-color: rgba(255,255,255,0.25);
  --sidebar-footer-role-color: var(--gold);
  --sidebar-footer-name-color: rgba(255,255,255,0.7);

  /* ── Mobile page accent ── */
  --page-accent-color: rgba(196,147,74,0.06);

  /* ── Manager chip tags ── */
  --mgr-chip-text: #fff;

  /* ── Fonts — editorial Chinese ── */
  --font-body: 'Noto Serif SC', STSong, Songti SC, '宋体', serif;
  --font-heading: 'ZCOOL XiaoWei', STSong, Songti SC, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

/* ═══════════════════════════════════════════════════════════
   THEME: Light — 极简功能主义 / Brutally Minimal
   ═══════════════════════════════════════════════════════════ */

:root[data-theme="light"] {
  /* ── Core palette ── */
  --ink: #1A1A1A;
  --ink-light: #3D3D3D;
  --ink-dark: #0A0A0A;
  --vermilion: #DC2626;
  --vermilion-light: #EF4444;
  --vermilion-dark: #B91C1C;
  --gold: #D4AF37;
  --gold-light: #E5C955;
  --gold-dark: #B8941F;
  --paper: #F5F5F5;
  --paper-dark: #EBEBEB;
  --surface: #FFFFFF;
  --sage: #16A34A;
  --amber: #D97706;
  --warm-gray: #666666;
  --warm-border: #DDDDDD;

  /* ── Semantic tokens ── */
  --c-primary: var(--ink);
  --c-primary-light: var(--ink-light);
  --c-primary-bg: #F5F5F5;
  --c-accent: var(--vermilion);
  --c-accent-light: var(--vermilion-light);
  --c-gold: var(--gold);
  --c-success: var(--sage);
  --c-warning: var(--amber);
  --c-danger: var(--vermilion);
  --c-info: #2563EB;
  --c-text: #1A1A1A;
  --c-text-secondary: #666666;
  --c-text-muted: #999999;
  --c-bg: var(--paper);
  --c-bg-card: var(--surface);
  --c-border: var(--warm-border);

  /* ── Effects ── */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 6px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
  --radius: 0px;
  --radius-sm: 0px;
  --radius-xs: 0px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Sidebar — light minimal ── */
  --sidebar-bg: #FFFFFF;
  --sidebar-color: #1A1A1A;
  --sidebar-accent: var(--gold);
  --sidebar-nav-text: #777777;
  --sidebar-nav-text-hover: #1A1A1A;
  --sidebar-nav-text-active: #1A1A1A;
  --sidebar-nav-bg-hover: #F5F5F5;
  --sidebar-nav-bg-active: #F0F0F0;
  --sidebar-nav-border-active: var(--gold);
  --sidebar-divider: #EEEEEE;
  --sidebar-brand-color: #1A1A1A;
  --sidebar-brand-sub-color: #999999;
  --sidebar-group-label-color: #AAAAAA;
  --sidebar-footer-role-color: var(--gold);
  --sidebar-footer-name-color: #777777;

  /* ── Mobile page accent ── */
  --page-accent-color: rgba(212,175,55,0.04);

  /* ── Manager chip tags ── */
  --mgr-chip-text: #1A1A1A;

  /* ── Fonts — sans-serif minimal ── */
  --font-body: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-heading: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

html, body, #app {
  margin: 0; padding: 0; height: 100%;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Editorial heading style ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════════
   Element Plus Global Overrides — Editorial Remap
   ═══════════════════════════════════════════════════════════ */

/* ── Card: sharp corners, subtle border, refined shadow ── */
.el-card {
  border-radius: 2px !important;
  border: 1px solid var(--c-border) !important;
  box-shadow: var(--shadow) !important;
  transition: box-shadow var(--transition);
  background: var(--surface) !important;
}
.el-card:hover { box-shadow: var(--shadow-md) !important; }
.el-card__header {
  border-bottom: 2px solid var(--gold) !important;
  padding: 16px 20px !important;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: 0.03em;
}
.el-card__body { padding: 20px !important; }

/* ── Button: sharp, decisive ── */
.el-button {
  border-radius: 2px !important;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all var(--transition);
  font-family: var(--font-body);
}
.el-button--primary {
  background: var(--ink) !important;
  border-color: var(--ink) !important;
  color: #fff !important;
}
.el-button--primary:hover {
  background: var(--ink-light) !important;
  border-color: var(--ink-light) !important;
}
.el-button--success {
  background: var(--sage) !important;
  border-color: var(--sage) !important;
}
.el-button--danger {
  background: var(--vermilion) !important;
  border-color: var(--vermilion) !important;
}
.el-button--warning {
  background: var(--amber) !important;
  border-color: var(--amber) !important;
}

/* ── Tag: editorial label style ── */
.el-tag {
  border-radius: 2px !important;
  font-weight: 500;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

/* ── Tabs ── */
.el-tabs__item {
  font-weight: 500;
  font-family: var(--font-heading);
}
.el-tabs__active-bar { background: var(--gold) !important; }
.el-tabs__item.is-active { color: var(--ink) !important; }

/* ── Table ── */
.el-table th.el-table__cell {
  background: var(--c-primary-bg);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-heading);
  letter-spacing: 0.03em;
}
.el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
  background: var(--c-primary-bg);
}

/* ── Pagination ── */
.el-pagination { margin-top: 16px; }

/* ── Dialog ── */
.el-dialog {
  border-radius: 2px !important;
}
.el-dialog__header {
  padding: 20px 24px 0 !important;
  font-weight: 600;
  font-family: var(--font-heading);
}
.el-dialog__body { padding: 20px 24px !important; }

/* ── Menu ── */
.el-menu { border-right: none !important; }

/* ── Progress ── */
.el-progress-bar__outer { border-radius: 0 !important; }
.el-progress-bar__inner { border-radius: 0 !important; background: var(--ink) !important; }

/* ── Form ── */
.el-form { max-width: 100%; }
.el-select, .el-date-editor { max-width: 100%; }
.el-table { max-width: 100%; }
.el-table__body-wrapper { overflow-x: auto; }
.el-radio-button__inner {
  min-height: 36px;
  line-height: 36px;
  border-radius: 2px !important;
}
.el-radio-button__orig-radio:checked + .el-radio-button__inner {
  background: var(--ink) !important;
  border-color: var(--ink) !important;
}

/* ── Input & Select borders ── */
.el-input__wrapper {
  border-radius: 2px !important;
  box-shadow: 0 0 0 1px var(--c-border) inset !important;
}
.el-input__wrapper:hover { box-shadow: 0 0 0 1px var(--ink) inset !important; }
.el-input__wrapper.is-focus { box-shadow: 0 0 0 2px var(--ink) inset !important; }
.el-select .el-input__wrapper { border-radius: 2px !important; }

/* ── Date picker ── */
.el-date-editor.el-input { border-radius: 2px !important; }

/* ── Textarea ── */
.el-textarea__inner {
  border-radius: 2px !important;
  font-family: var(--font-body);
}

/* ── Radio ── */
.el-radio__input.is-checked .el-radio__inner {
  background: var(--ink) !important;
  border-color: var(--ink) !important;
}
.el-radio__input.is-checked + .el-radio__label { color: var(--ink) !important; }

/* ── Checkbox ── */
.el-checkbox__input.is-checked .el-checkbox__inner {
  background: var(--ink) !important;
  border-color: var(--ink) !important;
}

/* ── Switch ── */
.el-switch.is-checked .el-switch__core {
  background: var(--ink) !important;
  border-color: var(--ink) !important;
}

/* ── Loading spinner ── */
.el-loading-spinner .circular circle { stroke: var(--gold) !important; }

/* ── Message box ── */
.el-message-box { border-radius: 2px !important; }

/* ── Notification ── */
.el-notification { border-radius: 2px !important; }

/* ── Divider ── */
.el-divider__text {
  font-family: var(--font-heading);
  color: var(--warm-gray);
}

/* ── Image Preview Overlay ── */
.image-preview-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.image-preview-full {
  max-width: 95vw; max-height: 95vh;
  object-fit: contain; cursor: default;
}
.image-preview-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.15); color: #fff;
  border: none; width: 40px; height: 40px; font-size: 20px;
  cursor: pointer; border-radius: 50%; transition: background 0.2s;
}
.image-preview-close:hover { background: rgba(255,255,255,0.35); }

/* ── Screenshot capture mode ── */
.taking-screenshot { background: #fff !important; }
.taking-screenshot * { background-color: transparent; }
.taking-screenshot .el-card,
.taking-screenshot .el-table,
.taking-screenshot .el-table__header,
.taking-screenshot .el-table__body,
.taking-screenshot .filter-bar,
.taking-screenshot .summary-bar,
.taking-screenshot .page-head { background: #fff !important; }
.taking-screenshot .screenshot-hide { display: none !important; }
.taking-screenshot .el-table__fixed-right { display: none !important; }

/* ── Screenshot capture animation ── */
.body-capturing .work-plans-page,
.body-capturing .mini-biz-page,
.body-capturing .key-visits-page {
  position: relative;
}
.body-capturing .work-plans-page::after,
.body-capturing .mini-biz-page::after,
.body-capturing .key-visits-page::after {
  content: '';
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(255,255,255,0.6);
  pointer-events: none;
  animation: capture-flash 0.35s ease-out;
}
@keyframes capture-flash {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Column resize handle ── */
.el-table__header th {
  position: relative !important;
}
/* Exclude gutter (scrollbar spacer) and selection column from resize */
.el-table__header th.el-table__cell--selection .col-resize-handle,
.el-table__header th.gutter .col-resize-handle {
  display: none !important;
}
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 1;
  transition: background 0.15s;
}
.col-resize-handle::after {
  content: '';
  position: absolute;
  right: 1px;
  top: 20%;
  bottom: 20%;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.15s;
}
.el-table__header th:hover .col-resize-handle::after,
.col-resize-handle.is-resizing::after {
  background: var(--gold);
}
.col-resize-handle:hover::after,
.col-resize-handle.is-resizing::after {
  background: var(--gold) !important;
}
/* Prevent text selection while resizing columns */
body.col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}
</style>
