<template>
  <router-view />
</template>

<script setup>
import { onMounted } from 'vue'

onMounted(() => {
  const saved = localStorage.getItem('theme')
  if (saved) {
    document.documentElement.classList.toggle('dark', saved === 'dark')
  } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
    document.documentElement.classList.add('dark')
  }
})
</script>

<style>
/* Light mode (default) */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #3b82f6;
  --primary-weak: #eff6ff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(2, 8, 23, 0.05), 0 1px 2px rgba(2, 8, 23, 0.03);
  --shadow-lg: 0 10px 30px rgba(2, 8, 23, 0.08);

  --pill-bg: #0f172a;
  --pill-text: #f8fafc;
  --pill-border: rgba(255,255,255,0.06);
}

/* Dark mode */
html.dark {
  --bg: #020617;
  --surface: #0f172a;
  --surface-hover: #1e293b;
  --text: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #1e293b;
  --border-strong: #334155;
  --primary: #60a5fa;
  --primary-weak: rgba(59,130,246,0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);

  --pill-bg: #1e293b;
  --pill-text: #f8fafc;
  --pill-border: #334155;
}

* { box-sizing: border-box; }

html, body, #app {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

.page {
  padding: 22px;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  transition: background .2s ease, border-color .2s ease;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Element Plus overrides */
.el-button {
  border-radius: 8px;
  font-weight: 500;
}
.el-button--primary {
  --el-button-bg-color: #3b82f6;
  --el-button-border-color: #3b82f6;
  --el-button-hover-bg-color: #2563eb;
  --el-button-hover-border-color: #2563eb;
}
html.dark .el-button--primary {
  --el-button-bg-color: #3b82f6;
  --el-button-border-color: #3b82f6;
  --el-button-hover-bg-color: #2563eb;
  --el-button-hover-border-color: #2563eb;
}
.el-input__wrapper {
  border-radius: 10px;
}
.el-tag {
  border-radius: 6px;
}
.el-dialog {
  border-radius: 16px;
}
.el-dialog__header {
  padding: 18px 20px 10px;
  font-weight: 700;
}
.el-dialog__body {
  padding: 10px 20px 18px;
}
.el-table {
  --el-table-header-bg-color: var(--surface-hover);
  --el-table-row-hover-bg-color: var(--surface-hover);
  --el-table-border-color: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.el-table th.el-table__cell {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
}
.el-pagination .btn-prev,
.el-pagination .btn-next,
.el-pager li {
  border-radius: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(128,128,128,0.25);
  border-radius: 4px;
}
html.dark ::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.25);
}
::-webkit-scrollbar-track {
  background: transparent;
}
</style>
