/* ═══════════════════════════════════════════════════════
   LibraryTao – Admin stylesheet
   ═══════════════════════════════════════════════════════ */

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

:root {
  --primary:    #6c63ff;
  --primary-dk: #574fd6;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --success:    #10b981;
  --bg:         #f0f2f7;
  --card-bg:    #ffffff;
  --sidebar-bg: #1e1e2e;
  --sidebar-w:  220px;
  --text:       #1e1e2e;
  --muted:      #6b7280;
  --border:     #e5e7eb;
  --radius:     10px;
  --shadow:     0 2px 10px rgba(0,0,0,.08);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
  display: flex; min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ─────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50; overflow-y: auto;
}
.sidebar-logo { color: #fff; font-size: 1.1rem; font-weight: 700; padding: 20px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; color: #a1a1b8; font-size: .88rem;
  transition: all .15s; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-bottom { padding: 12px 0; border-top: 1px solid rgba(255,255,255,.08); }
.nav-item-form { margin: 0; }
.nav-item-button {
  width: 100%; background: none; border: none; text-align: left; font: inherit;
}

/* ── Main content area ───────────────────────────────── */
.admin-content {
  margin-left: var(--sidebar-w);
  flex: 1; padding: 28px 32px;
  max-width: calc(100vw - var(--sidebar-w));
  min-height: 100vh;
}
.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 24px; color: var(--text); }
.section-title { font-size: 1.1rem; font-weight: 600; margin: 24px 0 12px; }

/* ── Cards ───────────────────────────────────────────── */
.card { background: var(--card-bg); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

/* ── Stats grid ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); text-align: center; }
.stat-card.stat-active { background: var(--primary); color: #fff; }
.stat-card.stat-active .stat-label { color: rgba(255,255,255,.8); }
.stat-num { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* ── Quick actions ───────────────────────────────────── */
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card-bg); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead tr { background: #f8f9fa; }
th { text-align: left; padding: 11px 14px; font-weight: 600; color: var(--muted); white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.row-highlight td { background: #fffbf0 !important; }

/* ── Forms ───────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 5px; color: var(--muted); }
.field input[type=text], .field input[type=url], .field input[type=password], .field input[type=email],
.field input[type=number], .field textarea, .field select, select.role-select {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; background: #fff; transition: border .2s;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.toggle-label { display: flex; align-items: center; gap: 8px; font-weight: normal; color: var(--text); cursor: pointer; }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; max-width: 480px; }
.search-bar input { flex: 1; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: .9rem; }
.search-bar input:focus { outline: none; border-color: var(--primary); }

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary, .btn-outline, .btn-danger, .btn-warning, .btn-xs, .btn-sm {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 18px; border-radius: 8px; border: none; font-size: .88rem;
  font-weight: 600; cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); text-decoration: none; color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; color: #fff; }
.btn-warning { background: var(--warning); color: #1e1e2e; }
.btn-warning:hover { background: #d97706; text-decoration: none; }
.btn-xs { padding: 3px 10px; font-size: .78rem; border-radius: 6px; background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-xs:hover { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }

/* ── Badges ──────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-running  { background: #dbeafe; color: #1e40af; }
.badge-paused   { background: #f3f4f6; color: #6b7280; }
.badge-done     { background: #dcfce7; color: #166534; }
.badge-failed   { background: #fee2e2; color: #991b1b; }

/* ── Progress bar ────────────────────────────────────── */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar.sm { height: 5px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #a78bfa); border-radius: 4px; transition: width .5s ease; }

/* ── Alerts ──────────────────────────────────────────── */
.alert { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .88rem; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .88rem; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.empty-msg { color: var(--muted); padding: 12px 0; }

/* ── Settings sections ───────────────────────────────── */
.settings-section { background: var(--card-bg); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.settings-section h2 { font-size: .95rem; font-weight: 700; margin-bottom: 16px; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; }
.settings-section code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: .85rem; }

/* ── Modal ───────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px; overflow-y: auto; }
.modal { background: var(--card-bg); border-radius: 14px; padding: 28px 32px; width: 100%; max-width: 520px; box-shadow: 0 8px 40px rgba(0,0,0,.2); }
.modal h2 { margin-bottom: 18px; }

/* ── Login page ──────────────────────────────────────── */
body.login-page { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e1e2e 0%, #2e1e4e 100%); min-height: 100vh; }
.login-box { background: var(--card-bg); border-radius: 16px; padding: 40px 44px; width: 100%; max-width: 400px; box-shadow: 0 8px 40px rgba(0,0,0,.3); }
.login-box h1 { color: var(--primary); font-size: 1.5rem; margin-bottom: 4px; }
.login-box h2 { font-size: 1.1rem; margin-bottom: 24px; color: var(--muted); }

/* ── Role select (inline) ────────────────────────────── */
select.role-select { width: auto; padding: 4px 8px; font-size: .82rem; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .admin-sidebar { position: relative; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; }
  .admin-content { margin-left: 0; max-width: 100%; }
  .field-row { grid-template-columns: 1fr; }
}
