/* ============================================
   PearAdmin 风格后台管理 CSS
   基于 Layui 扩展，现代化后台 UI
   ============================================ */

/* ===== CSS Variables ===== */
:root {
  --pear-sidebar-width: 220px;
  --pear-sidebar-collapse: 60px;
  --pear-header-height: 52px;
  --pear-tab-height: 38px;
  --pear-sidebar-bg: #1e293b;
  --pear-sidebar-hover: #334155;
  --pear-sidebar-active: #165dff;
  --pear-header-bg: #ffffff;
  --pear-body-bg: #f0f2f5;
  --pear-card-bg: #ffffff;
  --pear-text-primary: #1d2129;
  --pear-text-secondary: #4e5969;
  --pear-text-muted: #86909c;
  --pear-border: #e5e6eb;
  --pear-primary: #165dff;
  --pear-success: #00b42a;
  --pear-warning: #ff7d00;
  --pear-danger: #f53f3f;
  --pear-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset (scoped to admin shell, not iframe sub-pages) ===== */
.pear-admin, .pear-admin *, .pear-admin *::before, .pear-admin *::after,
.pear-login, .pear-login *, .pear-login *::before, .pear-login *::after {
  box-sizing: border-box; margin: 0; padding: 0;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  font-size: 14px;
  color: var(--pear-text-primary);
  background: var(--pear-body-bg);
  overflow: hidden;
}

/* ===== Layout ===== */
.pear-admin {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.pear-sidebar {
  width: var(--pear-sidebar-width);
  min-width: var(--pear-sidebar-width);
  background: var(--pear-sidebar-bg);
  color: #c9cdd4;
  display: flex;
  flex-direction: column;
  transition: all var(--pear-transition);
  overflow: hidden;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
}
.pear-sidebar.collapsed {
  width: var(--pear-sidebar-collapse);
  min-width: var(--pear-sidebar-collapse);
}

/* Sidebar Logo */
.pear-logo {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.pear-logo .logo-icon {
  width: 34px;
  height: 34px;
  background: var(--pear-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}
.pear-logo .logo-text {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
}
.pear-sidebar.collapsed .logo-text { display: none; }

/* Sidebar Nav */
.pear-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}
.pear-sidebar-nav::-webkit-scrollbar { width: 4px; }
.pear-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.pear-menu {}
.pear-menu .menu-group { margin-bottom: 4px; }
.pear-menu .menu-group-title {
  padding: 12px 20px 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
}
.pear-sidebar.collapsed .menu-group-title { display: none; }

.pear-menu .menu-item {
  display: flex;
  align-items: center;
  padding: 11px 20px;
  margin: 2px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  gap: 10px;
  font-size: 14px;
  color: #c9cdd4;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}
.pear-menu .menu-item:hover {
  background: var(--pear-sidebar-hover);
  color: #fff;
}
.pear-menu .menu-item.active {
  background: var(--pear-sidebar-active);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(22,93,255,0.35);
}
.pear-menu .menu-item .menu-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.pear-menu .menu-item .menu-title {
  flex: 1;
  overflow: hidden;
}
.pear-sidebar.collapsed .menu-title,
.pear-sidebar.collapsed .menu-arrow { display: none; }

/* Sidebar Collapse Button */
.pear-sidebar-toggle {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.1);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 16px;
  color: rgba(255,255,255,0.5);
  transition: all 0.2s;
}
.pear-sidebar-toggle:hover { color: #fff; background: rgba(0,0,0,0.2); }

/* ===== Main Area ===== */
.pear-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== Header ===== */
.pear-header {
  height: var(--pear-header-height);
  min-height: var(--pear-header-height);
  background: var(--pear-header-bg);
  border-bottom: 1px solid var(--pear-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.pear-header .header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pear-header .header-left .collapse-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  color: var(--pear-text-secondary);
  transition: all 0.2s;
  background: var(--pear-body-bg);
}
.pear-header .header-left .collapse-btn:hover {
  background: var(--pear-primary);
  color: #fff;
}
.pear-header .header-left .breadcrumb {
  font-size: 14px;
  color: var(--pear-text-secondary);
}
.pear-header .header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.pear-header .header-right .user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.2s;
}
.pear-header .header-right .user-info:hover {
  background: var(--pear-body-bg);
}
.pear-header .header-right .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--pear-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}
.pear-header .header-right .user-name {
  font-size: 13px;
  color: var(--pear-text-primary);
}

/* ===== Tabs ===== */
.pear-tabs {
  height: var(--pear-tab-height);
  min-height: var(--pear-tab-height);
  background: #fff;
  border-bottom: 1px solid var(--pear-border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  overflow: hidden;
  z-index: 40;
}
.pear-tabs .tab-list {
  display: flex;
  align-items: center;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  gap: 2px;
}
.pear-tabs .tab-list::-webkit-scrollbar { height: 0; }
.pear-tabs .tab-item {
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  color: var(--pear-text-secondary);
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}
.pear-tabs .tab-item:hover { background: var(--pear-body-bg); }
.pear-tabs .tab-item.active {
  background: var(--pear-primary);
  color: #fff;
}
.pear-tabs .tab-item .tab-close {
  font-size: 12px;
  opacity: 0.5;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.pear-tabs .tab-item .tab-close:hover {
  opacity: 1;
  background: rgba(0,0,0,0.1);
}
.pear-tabs .tabs-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.pear-tabs .tabs-actions .tab-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  color: var(--pear-text-muted);
  font-size: 14px;
  transition: all 0.2s;
}
.pear-tabs .tabs-actions .tab-action-btn:hover {
  background: var(--pear-body-bg);
  color: var(--pear-text-primary);
}

/* ===== Content ===== */
.pear-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.pear-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ===== User Dropdown ===== */
.user-dropdown { position: relative; }
.user-dropdown .user-info {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  transition: background 0.2s;
}
.user-dropdown .user-info:hover { background: var(--pear-body-bg); }
.user-dropdown .user-arrow {
  font-size: 10px; color: var(--pear-text-muted);
  transition: transform 0.2s;
}
.user-dropdown .user-arrow.up { transform: rotate(180deg); }

.user-menu {
  position: absolute;
  top: calc(var(--pear-header-height) - 6px);
  right: 0;
  width: 240px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 30px rgba(0,0,0,0.12);
  z-index: 200;
  overflow: hidden;
  animation: dropIn 0.2s ease;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-menu-header {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar-lg {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--pear-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600;
  flex-shrink: 0;
}
.menu-nickname { font-size: 15px; font-weight: 600; color: var(--pear-text-primary); }
.menu-role { font-size: 12px; color: var(--pear-text-muted); margin-top: 2px; }
.user-menu-divider { height: 1px; background: var(--pear-border); }
.user-menu-item {
  padding: 12px 18px;
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--pear-text-primary);
  cursor: pointer; transition: background 0.15s;
}
.user-menu-item:hover { background: var(--pear-body-bg); }
.user-menu-item.danger { color: var(--pear-danger); }
.user-menu-item.danger:hover { background: rgba(245,63,63,0.05); }

/* ===== Profile Modal ===== */
.profile-form { padding: 8px 0; }
.profile-form .layui-form-item { margin-bottom: 16px; }
.profile-form .layui-form-label { width: 80px; }

/* ===== Sub-page Styles (inside iframe) ===== */
.iframe-body {
  margin: 0;
  padding: 16px;
  height: auto;
  overflow-y: auto;
  background: var(--pear-body-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  font-size: 14px;
  color: var(--pear-text-primary);
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: all 0.25s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.stat-card .stat-icon-box {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}
.stat-card .stat-info { flex: 1; min-width: 0; }
.stat-card .stat-label {
  font-size: 13px;
  color: var(--pear-text-muted);
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--pear-text-primary);
  line-height: 1.2;
}
.stat-card .stat-sub {
  font-size: 12px;
  color: var(--pear-text-muted);
  margin-top: 2px;
}

/* Colors */
.bg-blue-light { background: rgba(22,93,255,0.08); color: var(--pear-primary); }
.bg-green-light { background: rgba(0,180,42,0.08); color: var(--pear-success); }
.bg-orange-light { background: rgba(255,125,0,0.08); color: var(--pear-warning); }
.bg-red-light { background: rgba(245,63,63,0.08); color: var(--pear-danger); }

/* Card */
.pear-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 16px;
  overflow: hidden;
}
.pear-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--pear-border);
  font-size: 15px;
  font-weight: 600;
  color: var(--pear-text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pear-card-body { padding: 16px 20px; }

/* Status Tags */
.pear-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.pear-tag.blue { background: rgba(22,93,255,0.08); color: var(--pear-primary); }
.pear-tag.green { background: rgba(0,180,42,0.08); color: var(--pear-success); }
.pear-tag.orange { background: rgba(255,125,0,0.08); color: var(--pear-warning); }
.pear-tag.red { background: rgba(245,63,63,0.08); color: var(--pear-danger); }
.pear-tag.gray { background: rgba(134,144,156,0.08); color: var(--pear-text-muted); }

/* Table Enhancements */
.layui-table { border-radius: 8px; }
.layui-table th { background: #f7f8fa !important; font-weight: 600; color: var(--pear-text-primary); }
.layui-table td, .layui-table th { padding: 10px 14px !important; }
.layui-table tr:hover td { background: #f7f8fa !important; }
.layui-table-body { overflow: hidden !important; }
.layui-table-box { overflow: hidden; }

/* Button Enhancements */
.layui-btn {
  border-radius: 6px !important;
  font-size: 13px;
  transition: all 0.2s;
}
.layui-btn-xs { height: 28px; line-height: 28px; padding: 0 10px; }
.layui-btn-sm { height: 34px; line-height: 34px; padding: 0 16px; }
.layui-btn-normal { background: #fff; border: 1px solid var(--pear-border); color: var(--pear-text-primary); }
.layui-btn-normal:hover { color: var(--pear-primary); border-color: var(--pear-primary); }

/* Form Enhancements */
.layui-input, .layui-textarea, .layui-select {
  border-radius: 6px !important;
  border-color: var(--pear-border);
  transition: all 0.2s;
}
.layui-input:focus, .layui-textarea:focus {
  border-color: var(--pear-primary) !important;
  box-shadow: 0 0 0 3px rgba(22,93,255,0.06);
}

/* Card Header Action Button */
.pear-card-header .layui-btn { margin-left: 8px; }

/* Login Page (overlay from sidebar layout) */
.pear-login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 100%);
}
.pear-login .login-card {
  width: 420px;
  padding: 44px 36px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
}
.pear-login .login-card .login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.pear-login .login-card .login-logo .logo-circle {
  width: 60px;
  height: 60px;
  background: var(--pear-primary);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 12px;
}
.pear-login .login-card .login-logo h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--pear-text-primary);
}
.pear-login .login-card .login-logo p {
  font-size: 13px;
  color: var(--pear-text-muted);
  margin-top: 4px;
}
.pear-login .login-card .login-btn {
  width: 100%;
  height: 44px;
  background: var(--pear-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}
.pear-login .login-card .login-btn:hover {
  background: #0e42d2;
  transform: translateY(-1px);
}

/* Chart Section */
.chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 992px) { .chart-row { grid-template-columns: 1fr; } }
.chart-box {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chart-box .chart-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--pear-text-primary);
  margin-bottom: 16px;
  display: block;
}

/* Recent List */
.recent-list {}
.recent-list .recent-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--pear-border);
  gap: 12px;
}
.recent-list .recent-item:last-child { border-bottom: none; }
.recent-list .recent-item .recent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.recent-list .recent-item .recent-info { flex: 1; min-width: 0; }
.recent-list .recent-item .recent-title { font-size: 14px; color: var(--pear-text-primary); }
.recent-list .recent-item .recent-meta { font-size: 12px; color: var(--pear-text-muted); margin-top: 2px; }

/* ===== Animation ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.stat-card { animation: fadeInUp 0.4s ease both; }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
