/* ═══════════════════════════════════════
   Admin Dashboard — Premium Stylesheet
   ═══════════════════════════════════════ */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --sidebar-bg: #0f172a;
  --sidebar-hover: rgba(99,102,241,.15);
  --sidebar-active: rgba(99,102,241,.25);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #e2e8f0;
  --topbar-bg: #ffffff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 4px 16px rgba(0,0,0,.08);
  --transition: all .22s cubic-bezier(.4,0,.2,1);
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #162032;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --topbar-bg: #1e293b;
  --shadow: 0 4px 16px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.65; overflow: hidden; height: 100vh;
}
a { text-decoration: none; color: var(--primary); }
input, textarea, select, button { font-family: inherit; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════ */
.login-page {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  transition: opacity .4s;
}
.login-page .bubbles {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.bubble {
  position: absolute; border-radius: 50%;
  background: rgba(99,102,241,.1);
  animation: float 8s infinite ease-in-out;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-40px) rotate(180deg); }
}
.login-card {
  position: relative; z-index: 1;
  background: rgba(30,41,59,.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  padding: 44px 40px;
  width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.login-logo {
  font-size: 1.8rem; font-weight: 800; color: white;
  text-align: center; margin-bottom: 6px; letter-spacing: -.5px;
}
.login-logo span { color: var(--primary-light); }
.login-subtitle {
  text-align: center; color: #64748b; font-size: .88rem;
  margin-bottom: 32px;
}
.login-form .field { margin-bottom: 18px; }
.login-form label {
  display: block; font-size: .82rem; font-weight: 600;
  color: #94a3b8; margin-bottom: 7px; letter-spacing: .3px;
}
.login-form input {
  width: 100%; padding: 12px 16px;
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.1);
  border-radius: 10px; color: white; font-size: .92rem; outline: none;
  transition: var(--transition);
}
.login-form input:focus {
  border-color: var(--primary);
  background: rgba(99,102,241,.08);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.login-form input::placeholder { color: #475569; }
.login-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none; border-radius: 10px; color: white;
  font-size: 1rem; font-weight: 700; cursor: pointer; margin-top: 6px;
  transition: var(--transition);
  box-shadow: 0 8px 24px rgba(99,102,241,.4);
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(99,102,241,.5); }
.login-btn:active { transform: translateY(0); }
.login-error {
  margin-top: 12px; color: #f87171; font-size: .84rem;
  text-align: center; min-height: 20px;
}

/* ═══════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════ */
#app { display: flex; height: 100vh; opacity: 0; transition: opacity .3s; }
#app.visible { opacity: 1; }

/* ─── Sidebar ─── */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  transition: width .25s;
}
.sidebar.collapsed { width: 64px; }

.sidebar-brand {
  height: 64px; padding: 0 20px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0; overflow: hidden;
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: white;
}
.sidebar-brand .brand-text {
  font-size: 1.05rem; font-weight: 800; color: white;
  white-space: nowrap;
}
.sidebar-brand .brand-text span { color: var(--primary-light); }

.sidebar-body { flex: 1; padding: 16px 10px; overflow-y: auto; }

.nav-group-title {
  font-size: .68rem; font-weight: 700; letter-spacing: 1px;
  color: #475569; padding: 0 10px; margin: 14px 0 6px;
  text-transform: uppercase; white-space: nowrap; overflow: hidden;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  cursor: pointer; font-size: .88rem; font-weight: 500;
  color: var(--sidebar-text); margin-bottom: 3px;
  transition: var(--transition); white-space: nowrap; overflow: hidden;
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--primary-light);
}
.nav-item .icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  background: rgba(255,255,255,.04);
}
.nav-item.active .icon { background: rgba(99,102,241,.2); }
.nav-item .badge {
  margin-left: auto; background: var(--danger); color: white;
  padding: 1px 7px; border-radius: 50px; font-size: .7rem; font-weight: 700;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  cursor: pointer; transition: var(--transition);
  color: var(--sidebar-text); overflow: hidden;
}
.sidebar-user:hover { background: var(--sidebar-hover); color: white; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: .9rem;
}
.user-name { font-size: .88rem; font-weight: 600; white-space: nowrap; }
.user-role { font-size: .74rem; color: #475569; }

/* ─── Main ─── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Topbar */
.topbar {
  height: 64px; background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.menu-toggle {
  width: 36px; height: 36px; border: none; background: var(--surface2);
  border-radius: 8px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 1rem; color: var(--text-muted);
  transition: var(--transition);
}
.menu-toggle:hover { background: var(--border); }
.breadcrumb { font-size: .88rem; color: var(--text-muted); }
.breadcrumb strong { color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-btn {
  width: 38px; height: 38px; border: none; background: var(--surface2);
  border-radius: 10px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 1rem; color: var(--text-muted);
  transition: var(--transition); position: relative;
}
.topbar-btn:hover { background: var(--border); color: var(--text); }
.topbar-badge {
  position: absolute; top: 4px; right: 4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--danger); color: white;
  font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--topbar-bg);
}

/* Content area */
.content { flex: 1; overflow-y: auto; padding: 28px 28px 40px; }

/* Page header */
.page-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-title h2 { font-size: 1.35rem; font-weight: 800; }
.page-title p { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Stat Cards ─── */
.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
@media(max-width:900px) { .stat-row { grid-template-columns: 1fr 1fr; } }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.stat-body .num { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat-body .label { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }
.stat-body .trend { font-size: .75rem; margin-top: 4px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ─── Card ─── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: .95rem; font-weight: 700; }
.card-body { padding: 22px; }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  background: var(--surface2); padding: 11px 14px;
  font-weight: 600; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); text-align: left;
  white-space: nowrap;
}
td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 50px;
  font-size: .74rem; font-weight: 700;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-default { background: var(--surface2); color: var(--text-muted); }
[data-theme="dark"] .badge-success { background: rgba(16,185,129,.15); color: #34d399; }
[data-theme="dark"] .badge-warning { background: rgba(245,158,11,.15); color: #fbbf24; }
[data-theme="dark"] .badge-danger  { background: rgba(239,68,68,.15); color: #f87171; }
[data-theme="dark"] .badge-info    { background: rgba(59,130,246,.15); color: #60a5fa; }

.action-btns { display: flex; gap: 6px; }
.btn-icon {
  width: 30px; height: 30px; border: none; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; transition: var(--transition);
  background: var(--surface2); color: var(--text-muted);
}
.btn-icon:hover { background: var(--primary); color: white; }
.btn-icon.danger:hover { background: var(--danger); color: white; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px; border-radius: 9px; border: none;
  cursor: pointer; font-size: .875rem; font-weight: 600;
  transition: var(--transition);
}
.btn-primary {
  background: var(--primary); color: white;
  box-shadow: 0 4px 12px rgba(99,102,241,.3);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 18px rgba(99,102,241,.4); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }

/* ─── Form ─── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-full { grid-column: 1 / -1; }
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: .82rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: 7px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font-size: .9rem; outline: none; transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 80px; }
.field select { cursor: pointer; }

/* ─── Quill Editor override ─── */
.ql-toolbar.ql-snow {
  border-color: var(--border) !important;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  background: var(--surface2) !important;
}
.ql-container.ql-snow {
  border-color: var(--border) !important;
  border-radius: 0 0 var(--radius) var(--radius) !important;
  font-size: .95rem !important; min-height: 320px;
  background: var(--surface);
}
[data-theme="dark"] .ql-toolbar.ql-snow { background: #162032 !important; }
[data-theme="dark"] .ql-container.ql-snow { background: #1e293b; }
[data-theme="dark"] .ql-editor { color: var(--text) !important; }
[data-theme="dark"] .ql-toolbar button { color: #94a3b8 !important; fill: #94a3b8 !important; }
[data-theme="dark"] .ql-toolbar button:hover { color: white !important; fill: white !important; }

/* ─── Search/Filter bar ─── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 20px;
}
.search-input {
  padding: 9px 14px 9px 36px; border: 1.5px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font-size: .875rem; outline: none; transition: var(--transition);
  position: relative;
}
.search-input:focus { border-color: var(--primary); }
.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 300px; }
.search-wrap::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: .8rem; }
.search-wrap input { width: 100%; padding: 9px 12px 9px 32px; border: 1.5px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font-size: .875rem; outline: none; transition: var(--transition); }
.search-wrap input:focus { border-color: var(--primary); }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; transition: opacity .25s;
}
.modal-overlay.show { opacity: 1; }
.modal {
  background: var(--surface); border-radius: 18px;
  width: 100%; max-width: 640px;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
  max-height: 90vh; overflow-y: auto;
  transform: scale(.95); transition: transform .25s;
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border: none; background: var(--surface2);
  border-radius: 8px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 1rem; color: var(--text-muted);
}
.modal-close:hover { background: var(--danger); color: white; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Toast ─── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: #0f172a; color: white;
  padding: 13px 20px; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  transform: translateY(80px) scale(.95);
  opacity: 0; transition: all .3s cubic-bezier(.4,0,.2,1);
  font-size: .88rem; display: flex; align-items: center; gap: 8px;
}
#toast.show { transform: translateY(0) scale(1); opacity: 1; }
#toast.success { background: linear-gradient(135deg, #059669, #10b981); }
#toast.error { background: linear-gradient(135deg, #dc2626, #ef4444); }
#toast.info { background: linear-gradient(135deg, #0284c7, #0ea5e9); }

/* ─── Dashboard grid ─── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media(max-width:780px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-full { grid-column: 1 / -1; }

/* Recent post item */
.post-list-item {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.post-list-item:last-child { border-bottom: none; }
.post-list-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.post-list-title { flex: 1; font-size: .875rem; font-weight: 500; color: var(--text); }
.post-list-title:hover { color: var(--primary); cursor: pointer; }
.post-list-date { font-size: .76rem; color: var(--text-light); white-space: nowrap; }

/* ─── Empty state ─── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ─── Notification dropdown ─── */
.notif-drop {
  position: absolute; top: 48px; right: 0;
  width: 320px; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--border); z-index: 300;
  overflow: hidden; display: none;
}
.notif-drop.show { display: block; }
.notif-item {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-size: .84rem; transition: background .15s; cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface2); }
.notif-title { font-weight: 600; margin-bottom: 3px; }
.notif-desc { color: var(--text-muted); font-size: .78rem; }
