﻿/* ============================================
   LensCabin Admin — Shopro 风格多标签后台
   ============================================ */

:root {
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 64px;
  --topbar-h: 56px;
  --tabbar-h: 40px;

  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --sidebar-active: #0f3460;
  --sidebar-text: #a2a3b7;
  --sidebar-text-active: #ffffff;

  --topbar-bg: #ffffff;
  --topbar-border: #e8e8e8;

  --tabbar-bg: #f5f5f9;
  --tab-active-bg: #ffffff;
  --tab-active-border: #4e73df;

  --content-bg: #f0f2f5;
  --card-bg: #ffffff;

  --accent: #4e73df;
  --accent-light: #eef2ff;
  --accent-hover: #3a5fc8;
  --success: #1cc88a;
  --warning: #f6c23e;
  --danger: #e74a3b;
  --info: #36b9cc;

  --text: #1a1a2e;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --border: #e3e6f0;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 0.15rem 1.75rem rgba(58,59,69,.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
  --font: 'Inter', 'Noto Sans SC', -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: var(--font); font-size: 14px; color: var(--text); background: var(--content-bg); }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .25s ease;
  z-index: 100;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }
.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-logo svg { width: 28px; height: 28px; flex-shrink: 0; }
.sidebar-logo .logo-text { font-size: 18px; font-weight: 700; color: #fff; white-space: nowrap; }
.sidebar.collapsed .logo-text { display: none; }

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.menu-group { margin-bottom: 4px; }
.menu-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  user-select: none;
}
.menu-group-title:hover { color: var(--sidebar-text-active); background: var(--sidebar-hover); }
.menu-group-title .arrow {
  margin-left: auto;
  transition: transform .25s;
  font-size: 10px;
  opacity: .5;
}
.menu-group-title .arrow.open { transform: rotate(90deg); }
.sidebar.collapsed .menu-group-title .arrow { display: none; }
.sidebar.collapsed .menu-group-title { justify-content: center; padding: 10px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px 9px 48px;
  color: var(--sidebar-text);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  border-left: 3px solid transparent;
}
.menu-item:hover { color: var(--sidebar-text-active); background: var(--sidebar-hover); }
.menu-item.active {
  color: var(--sidebar-text-active);
  background: var(--sidebar-active);
  border-left-color: var(--accent);
}
.sidebar.collapsed .menu-item { padding: 9px 10px; justify-content: center; }
.menu-item .menu-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; }
.menu-item.active .menu-icon { opacity: 1; }
.menu-group-children { overflow: hidden; transition: max-height .3s ease; }
.menu-group-children.collapsed { max-height: 0 !important; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  color: var(--sidebar-text);
  background: none;
  border: none;
  width: 100%;
  font-size: 13px;
  transition: color .2s;
  white-space: nowrap;
}
.sidebar-toggle:hover { color: #fff; }
.sidebar.collapsed .sidebar-toggle span { display: none; }

/* ---- Main Area ---- */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---- Top Bar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  flex-shrink: 0;
}
.topbar-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  background: var(--content-bg);
  transition: all .2s;
}
.topbar-search input:focus { border-color: var(--accent); background: #fff; }
.topbar-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); width: 16px; height: 16px;
}
.topbar-right { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.topbar-btn {
  width: 36px; height: 36px; border: none; background: none;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all .2s; position: relative;
}
.topbar-btn:hover { background: var(--content-bg); color: var(--text); }
.topbar-btn .badge {
  position: absolute; top: 4px; right: 4px;
  width: 16px; height: 16px; background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 600; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.topbar-avatar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 20px; cursor: pointer;
  transition: background .2s;
}
.topbar-avatar:hover { background: var(--content-bg); }
.topbar-avatar img {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  background: var(--border);
}
.topbar-avatar .avatar-name { font-size: 13px; font-weight: 500; white-space: nowrap; }

/* ---- Tab Bar ---- */
.tabbar {
  height: var(--tabbar-h);
  background: var(--tabbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 4px;
  gap: 2px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 32px;
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all .2s;
  position: relative;
}
.tab-item:hover { color: var(--text); background: rgba(0,0,0,.02); }
.tab-item.active {
  background: var(--tab-active-bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 -1px 0 var(--tab-active-border);
}
.tab-item .tab-close {
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; opacity: 0; transition: all .2s;
  border: none; background: none; color: var(--text-muted);
}
.tab-item:hover .tab-close { opacity: .6; }
.tab-item .tab-close:hover { opacity: 1; background: rgba(0,0,0,.08); }
.tab-item:only-child .tab-close { display: none; }

/* ---- Content Area ---- */
.content-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--content-bg);
}
.tab-page { display: none; }
.tab-page.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Dashboard Cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  transition: all .2s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: #eef2ff; color: var(--accent); }
.stat-icon.green { background: #e8faf1; color: var(--success); }
.stat-icon.orange { background: #fef6e6; color: var(--warning); }
.stat-icon.red { background: #fde8e6; color: var(--danger); }
.stat-info h3 { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-info p { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }
.panel {
  background: var(--card-bg); border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.panel-header h3 { font-size: 15px; font-weight: 600; }
.panel-header .panel-action { font-size: 12px; color: var(--accent); cursor: pointer; }
.panel-body { padding: 20px; }
.panel-body .empty { text-align: center; padding: 40px 0; color: var(--text-muted); font-size: 13px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table thead th {
  text-align: left; padding: 10px 12px; font-weight: 600;
  color: var(--text-secondary); border-bottom: 1px solid var(--border);
  font-size: 12px; text-transform: uppercase; letter-spacing: .3px;
}
table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
table tbody tr:hover { background: #f8f9fc; }
table tbody tr:last-child td { border-bottom: none; }

/* ---- Status Badges ---- */
.badge {
  display: inline-flex; padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-success { background: #e8faf1; color: #1cc88a; }
.badge-warning { background: #fef6e6; color: #f6c23e; }
.badge-danger { background: #fde8e6; color: #e74a3b; }
.badge-info { background: #e8f4fd; color: #36b9cc; }

/* ---- Order Agent Status ---- */
.agent-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.agent-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; border: 1px solid var(--border);
  text-align: center; transition: all .2s;
}
.agent-card:hover { box-shadow: var(--shadow-sm); }
.agent-card .agent-status {
  width: 10px; height: 10px; border-radius: 50%;
  margin: 0 auto 8px;
}
.agent-card .agent-status.idle { background: var(--text-muted); }
.agent-card .agent-status.working { background: var(--success); animation: pulse 1.5s infinite; }
.agent-card .agent-status.blocked { background: var(--warning); }
.agent-card .agent-status.error { background: var(--danger); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(28,200,138,.4); }
  50% { box-shadow: 0 0 0 6px rgba(28,200,138,0); }
}
.agent-card .agent-name { font-size: 13px; font-weight: 600; }
.agent-card .agent-role { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ---- Page Header ---- */
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 600; }
.page-header p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ---- Welcome Widget ---- */
.welcome-card {
  background: linear-gradient(135deg, var(--sidebar-bg), var(--sidebar-active));
  border-radius: var(--radius);
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 24px;
}
.welcome-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.welcome-card p { opacity: .7; font-size: 14px; }

/* ---- Activity List ---- */
.activity-list { display: flex; flex-direction: column; gap: 12px; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
}
.activity-text { font-size: 13px; line-height: 1.5; }
.activity-text .highlight { color: var(--accent); font-weight: 500; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- Responsive ---- */
@media (max-width: 992px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
  .agent-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
  .sidebar-overlay.open { display: block; }
  .stats-grid { grid-template-columns: 1fr; }
  .agent-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .topbar-search { display: none; }
  .content-area { padding: 12px; }
}
/* ---- Modal ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }
.form-input, .form-select { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; font-family: var(--font); background: #fff; }
.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(78,115,223,.1); }

/* ---- Buttons ---- */
.btn-accent { padding: 8px 16px; background: var(--accent); color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .2s; font-family: var(--font); white-space: nowrap; }
.btn-accent:hover { background: var(--accent-hover, #3a5fc8); }
.btn-muted { padding: 8px 16px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 13px; cursor: pointer; font-family: var(--font); }
.btn-muted:hover { background: #f8f9fc; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 4px; }
.btn-danger { color: var(--danger); }

/* ---- Product Image ---- */
.prod-img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: #f0ede8; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 60px 0; color: var(--text-muted); }
.empty-state p { margin-top: 8px; font-size: 14px; color: var(--text-secondary); }
.badge-primary { background: #e8f4fd; color: #4e73df; }
.badge-secondary { background: #f0f0f0; color: #858796; }
