/* ============================================================
   UCManage – Admin Panel Styles
   Design: Apple-inspired minimal, consistent with UserHub UC
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f5f7;
  --surface:   #ffffff;
  --border:    #d2d2d7;
  --text-pri:  #1d1d1f;
  --text-sec:  #6e6e73;
  --text-ter:  #a1a1a6;
  --accent:    #0066cc;
  --accent-hv: #0077ed;
  --accent-bg: rgba(0,102,204,.07);
  --danger:    #ff3b30;
  --danger-bg: rgba(255,59,48,.06);
  --success:   #30d158;
  --success-bg:rgba(48,209,88,.08);
  --warning:   #ff9f0a;
  --warning-bg:rgba(255,159,10,.08);
  --sidebar-w: 224px;
  --header-h:  52px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --tr: 0.17s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-pri);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 30px; height: 30px; background: var(--text-pri);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-name {
  font-size: 15px; font-weight: 700; color: var(--text-pri);
  letter-spacing: -0.3px;
}
.sidebar-logo-name span { color: var(--accent); }
.sidebar-logo-badge {
  font-size: 10px; font-weight: 600; color: var(--text-ter);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 14px 10px 6px;
  flex: 1;
}
.sidebar-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-ter);
  padding: 0 8px; margin-bottom: 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text-sec);
  text-decoration: none; cursor: pointer;
  transition: background var(--tr), color var(--tr);
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg); color: var(--text-pri); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); }
.nav-item svg { flex-shrink: 0; opacity: .65; }
.nav-item.active svg { opacity: 1; }
.nav-item-badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--accent); color: white;
  border-radius: 980px; padding: 1px 7px; line-height: 1.6;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--tr);
}
.sidebar-user:hover { background: var(--bg); }
.sidebar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name  { font-size: 13px; font-weight: 600; }
.sidebar-user-role  { font-size: 11px; color: var(--text-ter); }

/* ── Top Header ───────────────────────────────────────────── */
.header {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--header-h); z-index: 90;
  background: rgba(245,245,247,.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(210,210,215,.6);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
}
.header-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--text-sec);
}
.header-breadcrumb span { color: var(--text-ter); }
.header-breadcrumb strong { color: var(--text-pri); font-weight: 600; }

.header-search {
  flex: 1; max-width: 380px; margin-left: 16px;
  position: relative;
}
.header-search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-ter); pointer-events: none;
}
.header-search input {
  width: 100%; padding: 7px 12px 7px 34px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; color: var(--text-pri);
  background: var(--surface); outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.header-search input::placeholder { color: var(--text-ter); }
.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,204,.1);
}

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.header-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text-sec);
  transition: background var(--tr), color var(--tr);
}
.header-btn:hover { background: rgba(0,0,0,.05); color: var(--text-pri); }

/* ── Main Layout ──────────────────────────────────────────── */
.admin-layout {
  margin-left: var(--sidebar-w);
  padding-top: var(--header-h);
  min-height: 100vh;
}
.admin-content {
  padding: 28px 28px 60px;
  max-width: 1200px;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-head h1 {
  font-size: 26px; font-weight: 700; letter-spacing: -0.6px;
}
.page-head p { font-size: 14px; color: var(--text-sec); margin-top: 4px; }
.page-head-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 20px 22px;
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-sec); letter-spacing: 0.01em; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -1.2px; margin: 6px 0 4px; }
.stat-change {
  font-size: 12px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 3px;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-icon {
  float: right; margin-top: -4px;
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-header p  { font-size: 13px; color: var(--text-sec); margin-top: 2px; }
.card-body { padding: 20px 22px; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  padding: 10px 14px;
  text-align: left; font-size: 11.5px; font-weight: 600;
  color: var(--text-sec); letter-spacing: 0.02em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text-pri); }
.table td {
  padding: 12px 14px; border-bottom: 1px solid rgba(210,210,215,.5);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(245,245,247,.6); }

/* ── Toolbar (search + filters above table) ───────────────── */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.toolbar-search {
  position: relative; flex: 1; min-width: 180px; max-width: 320px;
}
.toolbar-search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-ter); pointer-events: none;
}
.toolbar-search input {
  width: 100%; padding: 7px 12px 7px 32px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; color: var(--text-pri);
  background: var(--bg); outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.toolbar-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,102,204,.09); background: var(--surface); }
.toolbar-search input::placeholder { color: var(--text-ter); }

.select-filter {
  padding: 7px 28px 7px 11px; appearance: none;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; color: var(--text-pri);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a1a1a6'/%3E%3C/svg%3E") no-repeat right 10px center;
  cursor: pointer; outline: none;
  transition: border-color var(--tr);
}
.select-filter:focus { border-color: var(--accent); }

.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.toolbar-count { font-size: 13px; color: var(--text-sec); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  cursor: pointer; border: none; text-decoration: none;
  transition: background var(--tr), transform var(--tr), box-shadow var(--tr), border-color var(--tr);
}
.btn-pri {
  background: var(--text-pri); color: white;
}
.btn-pri:hover { background: #3d3d3f; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-pri:active { transform: translateY(0); }

.btn-sec {
  background: var(--surface); color: var(--text-pri);
  border: 1.5px solid var(--border);
}
.btn-sec:hover { border-color: #b0b0b5; background: var(--bg); }

.btn-ghost {
  background: none; color: var(--text-sec); padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text-pri); }

.btn-danger {
  background: none; color: var(--danger);
  border: 1.5px solid #ffb3b0;
}
.btn-danger:hover { border-color: var(--danger); background: var(--danger-bg); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 6px; }

.icon-btn {
  width: 30px; height: 30px; padding: 0; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1.5px solid var(--border);
  cursor: pointer; color: var(--text-sec);
  transition: background var(--tr), border-color var(--tr), color var(--tr);
}
.icon-btn:hover { background: var(--bg); border-color: #b0b0b5; color: var(--text-pri); }

/* ── Status Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; padding: 3px 10px;
  border-radius: 980px; white-space: nowrap;
}
.badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.badge-success { color: #1a8f3f; background: var(--success-bg); }
.badge-danger  { color: #c0392b; background: var(--danger-bg); }
.badge-warning { color: #c07000; background: var(--warning-bg); }
.badge-neutral { color: var(--text-sec); background: rgba(0,0,0,.05); }
.badge-accent  { color: var(--accent); background: var(--accent-bg); }
.badge-no-dot::before { display: none; }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* User cell */
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell-info .user-name  { font-size: 13.5px; font-weight: 500; }
.user-cell-info .user-email { font-size: 12px; color: var(--text-sec); }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-sec); gap: 12px; flex-wrap: wrap;
}
.pagination-pages { display: flex; align-items: center; gap: 4px; }
.pg-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; font-size: 13px; font-weight: 500;
  border: 1.5px solid transparent; cursor: pointer;
  background: none; color: var(--text-sec); font-family: var(--font);
  transition: background var(--tr), border-color var(--tr), color var(--tr);
}
.pg-btn:hover { background: var(--bg); color: var(--text-pri); border-color: var(--border); }
.pg-btn.active { background: var(--text-pri); color: white; border-color: var(--text-pri); }
.pg-btn:disabled { opacity: .35; cursor: default; }
.pg-btn:disabled:hover { background: none; border-color: transparent; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); backdrop-filter: blur(4px);
  z-index: 300; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 480px;
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity:0; transform:scale(.97) translateY(6px); } to { opacity:1; transform:none; } }
.modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px; border-radius: 7px;
  background: none; border: none; cursor: pointer; color: var(--text-sec);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--tr); font-size: 18px; line-height: 1;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: rgba(245,245,247,.5); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Form ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-sec); margin-bottom: 6px;
}
.form-input {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; color: var(--text-pri);
  background: var(--surface); outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.form-input::placeholder { color: var(--text-ter); }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,102,204,.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 12px; color: var(--text-ter); margin-top: 4px; }

/* ── Toast ────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 980px;
  font-size: 13.5px; font-weight: 500;
  background: var(--text-pri); color: white;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease forwards;
  white-space: nowrap;
}
@keyframes toast-in  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; transform:translateY(5px); } }
.toast.hiding { animation: toast-out .16s ease forwards; }
.toast-icon { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.toast.success .toast-icon { background: var(--success); }
.toast.error   .toast-icon { background: var(--danger); }
.toast.info    .toast-icon { background: var(--accent); }

/* ── Login page ───────────────────────────────────────────── */
.login-bg {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 20px; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 36px 36px 28px;
}
.login-logo {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-bottom: 28px;
}
.login-logo-icon {
  width: 38px; height: 38px; background: var(--text-pri); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.login-logo-text { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.login-logo-text span { color: var(--accent); }
.login-logo-badge {
  font-size: 10px; font-weight: 600; color: white;
  background: var(--accent); border-radius: 4px; padding: 2px 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.login-title    { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 6px; }
.login-subtitle { font-size: 14px; color: var(--text-sec); margin-bottom: 28px; }
.btn-login {
  width: 100%; padding: 13px;
  background: var(--text-pri); color: white;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font); font-size: 15px; font-weight: 600;
  letter-spacing: -0.1px; margin-top: 4px;
  transition: background var(--tr), transform var(--tr), box-shadow var(--tr);
}
.btn-login:hover { background: #3d3d3f; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { background: var(--text-ter); cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Chart area (simple bar chart) ───────────────────────── */
.chart-wrap { padding: 8px 0; }
.chart-bars {
  display: flex; align-items: flex-end; gap: 6px; height: 100px;
}
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar {
  width: 100%; border-radius: 4px 4px 0 0;
  transition: opacity var(--tr);
}
.chart-bar:hover { opacity: .75; }
.chart-label { font-size: 11px; color: var(--text-ter); white-space: nowrap; }

/* ── Detail row / KV list ─────────────────────────────────── */
.kv-list { display: flex; flex-direction: column; gap: 10px; }
.kv-item { display: flex; align-items: baseline; gap: 12px; font-size: 13.5px; }
.kv-key   { flex: 0 0 110px; color: var(--text-sec); font-size: 12.5px; }
.kv-val   { color: var(--text-pri); font-weight: 500; flex: 1; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px; color: var(--text-sec); text-align: center;
}
.empty-state svg { color: var(--text-ter); margin-bottom: 16px; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-pri); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--tr); }
  .sidebar.open { transform: translateX(0); }
  .admin-layout { margin-left: 0; }
  .header { left: 0; }
  .admin-content { padding: 20px 16px 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Misc helpers ─────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.ml-auto { margin-left: auto; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.text-sec { color: var(--text-sec); }
.text-sm  { font-size: 13px; }
.fw-500   { font-weight: 500; }
.fw-600   { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
