/* ==========================================
   后台管理通用样式（机构后台+超管后台）
   ========================================== */

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; color: #333; background: #f0f2f5; }
a { text-decoration: none; color: inherit; }
:root {
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-light: #eff6ff;
  --sidebar-bg: #1e293b; --sidebar-width: 220px;
  --gray-50: #f9fafb; --gray-100: #f3f4f6; --gray-200: #e5e7eb;
  --gray-400: #9ca3af; --gray-500: #6b7280; --gray-700: #374151; --gray-900: #111827;
  --success: #10b981; --danger: #ef4444; --warning: #f59e0b; --info: #3b82f6;
}

/* ── Admin Layout ── */
.admin-body { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.admin-sidebar {
  width: var(--sidebar-width); background: var(--sidebar-bg);
  flex-shrink: 0; display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 200; overflow-y: auto;
}
.admin-sidebar-logo {
  padding: 20px 18px; display: flex; align-items: center; gap: 10px;
  font-size: 1.05rem; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.admin-sidebar-logo i { font-size: 1.3rem; color: #60a5fa; }
.admin-nav { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; font-size: .9rem;
  color: rgba(255,255,255,.65); transition: .2s;
}
.admin-nav a i { width: 18px; text-align: center; }
.admin-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.admin-nav a.active { background: var(--primary); color: #fff; }
.nav-logout { margin-top: auto !important; color: rgba(255,255,255,.4) !important; }
.nav-logout:hover { color: #fff !important; background: rgba(239,68,68,.3) !important; }

/* ── Main ── */
.admin-main {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ── Topbar ── */
.admin-topbar {
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.admin-page-title { font-size: 1.05rem; font-weight: 700; }
.admin-topbar-right { display: flex; align-items: center; gap: 16px; font-size: .88rem; }
.topbar-view-site { color: var(--primary); display: flex; align-items: center; gap: 5px; }
.topbar-view-site:hover { text-decoration: underline; }
.topbar-user { color: var(--gray-500); display: flex; align-items: center; gap: 5px; }

/* ── Content ── */
.admin-content { padding: 24px; flex: 1; }
.mb20 { margin-bottom: 20px; }
.mt20 { margin-top: 20px; }

/* ── Stat Cards ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff;
}
.bg-blue { background: #3b82f6; } .bg-green { background: #10b981; }
.bg-orange { background: #f59e0b; } .bg-purple { background: #8b5cf6; }
.bg-red { background: #ef4444; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--gray-900); }
.stat-label { font-size: .82rem; color: var(--gray-500); margin-top: 2px; }

/* ── Quick Actions ── */
.section-title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; color: var(--gray-700); }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.action-item {
  background: #fff; border-radius: 10px; padding: 18px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: .9rem; font-weight: 500; color: var(--gray-700);
  border: 1.5px solid var(--gray-200); transition: .2s;
}
.action-item i { font-size: 1.6rem; color: var(--primary); }
.action-item:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ── Alerts ── */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px;
  font-size: .9rem; display: flex; align-items: center; gap: 8px;
}
.alert a { font-weight: 600; text-decoration: underline; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger   { background: #fee2e2; color: #991b1b; }
.alert-warning  { background: #fef3c7; color: #92400e; }
.alert-info     { background: #dbeafe; color: #1e40af; }

/* ── Tables ── */
.table-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.table-wrap { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.admin-table th {
  background: var(--gray-50); padding: 12px 14px; text-align: left;
  font-weight: 600; color: var(--gray-500); border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--gray-50); }
.td-ellipsis { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
code { background: var(--gray-100); padding: 2px 6px; border-radius: 4px; font-size: .82rem; color: var(--primary); }

/* ── Table Action Buttons ── */
.btn-table-action, .btn-table-success, .btn-table-danger {
  display: inline-flex; align-items: center; padding: 4px 12px;
  border-radius: 5px; font-size: .82rem; font-weight: 500; cursor: pointer;
  border: 1.5px solid; transition: .15s; margin-right: 4px;
}
.btn-table-action { color: var(--primary); border-color: var(--primary); background: transparent; }
.btn-table-action:hover { background: var(--primary-light); }
.btn-table-success { color: var(--success); border-color: var(--success); background: transparent; }
.btn-table-success:hover { background: #d1fae5; }
.btn-table-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-table-danger:hover { background: #fee2e2; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 4px; font-size: 1rem; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: var(--gray-100); color: var(--gray-500); }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ── Filter Tabs ── */
.filter-tabs { display: flex; gap: 6px; }
.filter-tabs a {
  padding: 6px 14px; border-radius: 6px; font-size: .85rem;
  background: var(--gray-100); color: var(--gray-700); transition: .15s;
}
.filter-tabs a:hover { background: var(--primary-light); color: var(--primary); }
.filter-tabs a.active { background: var(--primary); color: #fff; }

/* ── Forms ── */
.form-card { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.form-section-title {
  font-size: .95rem; font-weight: 700; color: var(--primary);
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--primary-light);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
  padding: 9px 12px; border: 1.5px solid var(--gray-200); border-radius: 8px;
  background: #fff; font-size: .9rem; transition: .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); outline: none; }
.form-group small { font-size: .78rem; color: var(--gray-400); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--gray-200); }
.form-inline-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0; }

/* Domain specific */
.domain-input-wrap { display: flex; align-items: center; background: var(--gray-50); border: 1.5px solid var(--gray-200); border-radius: 8px; overflow: hidden; }
.domain-input-wrap input { padding: 9px 14px; border: none; background: transparent; font-size: .95rem; width: 200px; }
.domain-input-wrap input:focus { outline: none; }
.domain-suffix { padding: 9px 14px; background: var(--gray-100); color: var(--gray-500); font-size: .9rem; white-space: nowrap; border-left: 1px solid var(--gray-200); }
.domain-explain { background: var(--primary-light); border-radius: 8px; padding: 14px 16px; font-size: .88rem; color: var(--gray-700); margin-bottom: 16px; }
.domain-explain p { margin-bottom: 6px; }
.domain-explain p:last-child { margin-bottom: 0; }
.domain-current { margin: 12px 0; font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.domain-current a { color: var(--primary); font-weight: 600; }
.domain-note { background: var(--gray-50); border-radius: 8px; padding: 14px 16px; font-size: .85rem; color: var(--gray-600); }
.domain-note ul { padding-left: 18px; margin-top: 6px; }
.domain-note li { margin-bottom: 4px; }
.text-green { color: var(--success); } .text-orange { color: var(--warning); }
.text-gray { color: var(--gray-400); }

/* Image preview */
.img-preview { margin-bottom: 8px; }
.img-preview img { max-height: 80px; border-radius: 6px; border: 1px solid var(--gray-200); }
.banner-preview img { max-height: 60px; max-width: 300px; }
.link-primary { color: var(--primary); } .link-primary:hover { text-decoration: underline; }

/* Pagination */
.pagination { padding: 20px 0; }
.pagination ul { display: flex; gap: 6px; list-style: none; }
.pagination li a, .pagination li.active a {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 7px; font-size: .88rem;
  border: 1.5px solid var(--gray-200); background: #fff; color: var(--gray-700); transition: .15s;
}
.pagination li a:hover { border-color: var(--primary); color: var(--primary); }
.pagination li.active a { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 20px; background: var(--primary); color: #fff;
  border: 2px solid var(--primary); border-radius: 8px; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 20px; background: transparent; color: var(--primary);
  border: 2px solid var(--primary); border-radius: 8px; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn-outline:hover { background: var(--primary-light); }
.btn-block { width: 100%; }
.empty-box { text-align: center; padding: 60px 20px; color: var(--gray-400); background: #fff; border-radius: 12px; }
.empty-box i { font-size: 3rem; margin-bottom: 12px; display: block; }
.empty-box a { color: var(--primary); font-weight: 600; }

/* ── Login Page ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%); }
.login-box { background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 2.5rem; color: var(--primary); display: block; margin-bottom: 10px; }
.login-logo h1 { font-size: 1.4rem; font-weight: 800; }
.login-logo p { font-size: .88rem; color: var(--gray-500); margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }
.input-icon input { width: 100%; padding: 11px 12px 11px 38px; border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: .95rem; }
.input-icon input:focus { border-color: var(--primary); outline: none; }
.login-btn { margin-top: 6px; padding: 13px; font-size: 1rem; }
.login-back { text-align: center; font-size: .85rem; color: var(--gray-500); margin-top: 16px; }
.login-back a { color: var(--primary); }
