/* Element-Admin 风格后台框架 */
:root {
  --sidebar-width: 210px;
  --sidebar-collapsed-width: 54px;
  --sidebar-bg: #304156;
  --sidebar-text: #bfcbd9;
  --sidebar-active-bg: #263445;
  --primary: #409eff;
  --primary-light: #ecf5ff;
  --success: #67c23a;
  --warning: #e6a23c;
  --danger: #f56c6c;
  --border: #e6ebf5;
  --text: #303133;
  --text-secondary: #606266;
  --text-placeholder: #909399;
  --bg-page: #f0f2f5;
  --header-height: 50px;
  --tabs-height: 34px;
  --shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #66b1ff; }

/* ===== Layout ===== */
.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  transition: width 0.28s;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  z-index: 1001;
}

.sidebar.is-collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-logo {
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: #2b2f3a;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, #67c23a, #409eff);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon .fa-solid {
  font-size: 16px;
  color: #fff;
}

.sidebar-logo .logo-text {
  margin-left: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.sidebar.is-collapsed .logo-text { opacity: 0; width: 0; }

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
}

.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* Menu items */
.menu-item {
  position: relative;
}

.menu-link {
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 20px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  user-select: none;
}

.menu-link:hover {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.menu-link.is-active {
  color: var(--primary);
  background: var(--sidebar-active-bg);
}

.menu-link.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}

.menu-icon {
  width: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.menu-icon .fa-solid {
  width: 16px;
  font-size: 14px;
  text-align: center;
  color: inherit;
}

.menu-link .menu-icon .fa-solid {
  color: var(--sidebar-text);
}

.menu-link:hover .menu-icon .fa-solid,
.menu-link.is-active .menu-icon .fa-solid {
  color: inherit;
}

.menu-arrow {
  font-size: 10px;
  transition: transform 0.28s;
  color: #8896a8;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.menu-title {
  margin-left: 10px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.menu-arrow.is-open { transform: rotate(90deg); }

.sidebar.is-collapsed .menu-title,
.sidebar.is-collapsed .menu-arrow { display: none; }

.sidebar.is-collapsed .menu-link { padding: 0; justify-content: center; }
.sidebar.is-collapsed .menu-icon { margin: 0; }

/* Submenu */
.submenu {
  overflow: hidden;
  transition: max-height 0.28s ease;
  background: #1f2d3d;
}

.submenu.is-collapsed { max-height: 0 !important; }

.submenu .menu-link {
  height: 44px;
  padding-left: 48px;
  font-size: 13px;
}

.submenu .submenu .menu-link { padding-left: 62px; }
.submenu .submenu .submenu .menu-link { padding-left: 76px; }
.submenu .submenu .submenu .submenu .menu-link { padding-left: 90px; }

/* ===== Main ===== */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Header */
.navbar {
  height: var(--header-height);
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 100;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hamburger {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: background 0.2s;
}

.hamburger:hover { background: #f5f7fa; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-placeholder);
}

.breadcrumb span { color: var(--text-secondary); }
.breadcrumb span:last-child { color: var(--text); font-weight: 500; }
.breadcrumb .sep { color: #c0c4cc; }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-tool {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 16px;
  transition: background 0.2s;
}

.nav-tool:hover { background: #f5f7fa; color: var(--primary); }

.nav-tool .fa-solid { font-size: 15px; }

.nav-tool-sub {
  font-size: 10px;
  margin-left: 1px;
  font-weight: 600;
}

/* 按钮内图标 */
.btn,
.btn-new-dim,
.btn-new-type,
.btn-add-field,
.btn-add-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn .fa-solid,
.btn-new-dim .fa-solid,
.btn-new-type .fa-solid {
  font-size: 13px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.user-info:hover { background: #f5f7fa; }

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #409eff, #67c23a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.user-name {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Tabs */
.tabs-bar {
  height: var(--tabs-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 8px;
  flex-shrink: 0;
  overflow-x: auto;
}

.tabs-bar::-webkit-scrollbar { height: 0; }

.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.tab-item:hover { color: var(--primary); }

.tab-item.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.tab-close {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-placeholder);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  padding: 0;
  flex-shrink: 0;
}

.tab-close:hover {
  background: #c0c4cc;
  color: #fff;
}

/* Content */
.app-main {
  flex: 1;
  overflow: hidden;
  padding: 16px;
}

#pageContainer {
  height: 100%;
}

.page-panel {
  display: none;
  height: 100%;
  animation: fadeIn 0.2s ease;
}

.page-panel.is-active { display: block; }

.page-iframe {
  width: 100%;
  height: calc(100vh - var(--header-height) - var(--tabs-height) - 32px);
  border: none;
  display: block;
  background: var(--bg-page);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Card ===== */
.page-card {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  padding: 20px;
  min-height: calc(100vh - var(--header-height) - var(--tabs-height) - 48px);
}

/* ===== Placeholder page ===== */
.page-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-placeholder);
}

.page-placeholder .icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.todo-link { cursor: pointer; }
.todo-link:hover { color: var(--primary); }

.page-placeholder h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.page-placeholder p {
  font-size: 13px;
  max-width: 400px;
  text-align: center;
  line-height: 1.6;
}

.page-placeholder .tag {
  margin-top: 16px;
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  font-size: 12px;
}

/* ===== Dashboard ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  border-left: 4px solid var(--primary);
}

.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red { border-left-color: var(--danger); }

.stat-card .label {
  font-size: 13px;
  color: var(--text-placeholder);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .trend {
  font-size: 12px;
  color: var(--success);
  margin-top: 6px;
}

.stat-card .trend.down { color: var(--danger); }

.dashboard-section {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  margin-bottom: 16px;
}

.dashboard-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.quick-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid var(--border);
}

.quick-link:hover {
  background: var(--primary-light);
  border-color: #b3d8ff;
}

.quick-link .ql-icon { font-size: 24px; }
.quick-link .ql-text { font-size: 12px; color: var(--text-secondary); }

.todo-list { list-style: none; }

.todo-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f5f7fa;
  font-size: 13px;
}

.todo-list li:last-child { border-bottom: none; }

.todo-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.todo-badge.urgent { background: #fef0f0; color: var(--danger); }
.todo-badge.normal { background: #fdf6ec; color: var(--warning); }
.todo-badge.low { background: #f0f9eb; color: var(--success); }

/* ===== Table (通用列表模板) ===== */
.search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.form-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-item label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.form-input, .form-select {
  height: 32px;
  padding: 0 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  min-width: 160px;
}

.form-input:focus, .form-select:focus { border-color: var(--primary); }

.search-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  height: 32px;
  padding: 0 16px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover { background: #66b1ff; border-color: #66b1ff; }

.btn-default {
  background: #fff;
  color: var(--text-secondary);
  border-color: #dcdfe6;
}

.btn-default:hover { color: var(--primary); border-color: #c6e2ff; background: var(--primary-light); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-add { background: var(--primary-light); color: var(--primary); border-color: #b3d8ff; }
.btn-edit { background: #f0f9eb; color: var(--success); border-color: #c2e7b0; }
.btn-delete { background: #fef0f0; color: var(--danger); border-color: #fbc4c4; }
.btn-add:hover, .btn-edit:hover, .btn-delete:hover { opacity: 0.85; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: #fafafa;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f5f7fa;
  color: var(--text);
}

.data-table tr:hover td { background: #fafcff; }

.data-table .col-check { width: 40px; text-align: center; }
.data-table .col-index { width: 60px; text-align: center; color: var(--text-placeholder); }
.data-table .col-actions { white-space: nowrap; }

.tag-label {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.tag-success { background: #f0f9eb; color: var(--success); }
.tag-warning { background: #fdf6ec; color: var(--warning); }
.tag-info { background: #ecf5ff; color: var(--primary); }

.action-link {
  color: var(--primary);
  cursor: pointer;
  margin-right: 12px;
  font-size: 13px;
}

.action-link:hover { color: #66b1ff; }
.action-link.danger { color: var(--danger); }
.action-link.danger:hover { color: #f78989; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.page-btn {
  min-width: 28px;
  height: 28px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover { color: var(--primary); border-color: var(--primary); }
.page-btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Dark mode */
body.is-dark {
  --bg-page: #141414;
  --text: #e5e5e5;
  --text-secondary: #a3a3a3;
  --border: #303030;
}

body.is-dark .navbar,
body.is-dark .tabs-bar,
body.is-dark .page-card,
body.is-dark .stat-card,
body.is-dark .dashboard-section {
  background: #1f1f1f;
}

body.is-dark .data-table th { background: #262626; }
body.is-dark .data-table tr:hover td { background: #262626; }
body.is-dark .form-input,
body.is-dark .form-select { background: #262626; border-color: #434343; color: #e5e5e5; }

/* Responsive */
@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-links { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(0); }
  .sidebar.is-collapsed { transform: translateX(-100%); width: var(--sidebar-width); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-links { grid-template-columns: repeat(2, 1fr); }
  .user-name { display: none; }
}
