/* ============================================================
   AI Rankings — Admin CMS design system
   Built on the same tokens as static/css/main.css (colors, radii,
   shadows, fonts) so the admin panel reads as part of the same
   product rather than a bolted-on back office.
   ============================================================ */

.admin-shell { display: flex; min-height: 100vh; background: var(--paper); }

/* ---------- Sidebar ---------- */
.admin-sidebar {
  width: 240px; flex: none;
  background: linear-gradient(180deg, #16261F, #0E1915);
  color: #fff;
  padding: 20px 0 16px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.admin-sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 18px; margin-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-sidebar .brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 17px; color: #fff;
  box-shadow: 0 4px 14px -4px rgba(15,110,86,0.55);
}
.admin-sidebar .brand-text { font-weight: 700; font-size: 14.5px; line-height: 1.25; }
.admin-sidebar .brand-text span { display: block; font-weight: 500; font-size: 10.5px; color: rgba(255,255,255,0.45); letter-spacing: 0.05em; text-transform: uppercase; margin-top: 1px; }

.admin-nav-label {
  padding: 14px 20px 6px; font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255,255,255,0.32);
}
.admin-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: #B9C4BC; text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
}
.admin-nav a .icon { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.admin-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav a.active { background: rgba(255,255,255,0.1); color: #fff; }
.admin-nav a.active .icon { color: var(--gold); opacity: 1; }
.admin-nav .nav-count {
  margin-left: auto; background: rgba(255,255,255,0.14); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
}
[dir="rtl"] .admin-nav .nav-count { margin-left: 0; margin-right: auto; }

.admin-sidebar-footer {
  margin-top: auto; padding: 14px 20px 0; border-top: 1px solid rgba(255,255,255,0.08);
}
.admin-sidebar-footer .admin-user { font-size: 12px; color: rgba(255,255,255,0.5); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-sidebar-footer a {
  color: #B9C4BC; text-decoration: none; font-size: 13px;
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
}
.admin-sidebar-footer a:hover { color: #fff; }
.admin-sidebar-footer a .icon { width: 15px; height: 15px; }

.admin-main { flex: 1; min-width: 0; }

/* ---------- Topbar ---------- */
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 32px; border-bottom: 1px solid var(--line);
  background: rgba(250, 250, 248, 0.85); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
}
.admin-topbar h1 { font-size: 20px; margin: 0; line-height: 1.3; }
.admin-topbar-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.admin-topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.admin-content { padding: 28px 32px 64px; }
.admin-content > p.admin-intro { color: var(--ink-soft); font-size: 13.5px; line-height: 1.7; margin: -8px 0 24px; max-width: 720px; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 32px; }
.stat-card {
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 18px 20px; background: var(--paper-raised);
  transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .icon-tile { width: 36px; height: 36px; margin-bottom: 12px; border-radius: 10px; }
.stat-card .icon-tile .icon { width: 17px; height: 17px; }
.stat-card.tone-gold .icon-tile { background: linear-gradient(145deg, var(--gold-glow), transparent); color: var(--gold); border-color: rgba(201,162,39,0.3); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.stat-value a { color: inherit; text-decoration: none; }
.stat-value a:hover { color: var(--accent); }
.stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Cards + tables ---------- */
.admin-card { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-raised); overflow: hidden; margin-bottom: 26px; }
.admin-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.admin-card-header h2, .admin-card-header h3 { font-size: 14.5px; margin: 0; font-weight: 600; }
.admin-card-header .view-all { font-size: 12.5px; color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.admin-card-header .view-all:hover { text-decoration: underline; }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table thead th {
  text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); padding: 11px 20px; background: var(--paper); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
[dir="rtl"] .admin-table thead th { text-align: right; }
.admin-table tbody td { padding: 13px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(15,110,86,0.035); }
.admin-table .col-actions { text-align: right; white-space: nowrap; }
[dir="rtl"] .admin-table .col-actions { text-align: left; }
.admin-table .muted { color: var(--ink-soft); }
.admin-table .mono { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.admin-table .cell-truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Badges + pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 20px; line-height: 1.6; }
[dir="rtl"] .badge { padding: 3px 8px 3px 10px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-published { background: var(--accent-glow); color: var(--accent-2); }
.badge-draft { background: var(--line-soft); color: var(--ink-soft); }
.badge-muted { background: var(--line-soft); color: var(--ink-faint); }

/* ---------- Row actions ---------- */
.row-actions { display: inline-flex; align-items: center; gap: 14px; }
.row-actions a { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 13px; }
.row-actions a:hover { text-decoration: underline; }
.row-actions form { display: inline; margin: 0; }
.btn-text-danger { background: none; border: none; color: #B0432A; cursor: pointer; font-size: 13px; font-weight: 600; padding: 0; font-family: inherit; }
.btn-text-danger:hover { text-decoration: underline; }

/* ---------- Flash messages ---------- */
.admin-flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13.5px; }
.admin-flash-success { background: #EAF4F0; color: var(--accent-2); }
.admin-flash-error { background: #FBF0EC; color: #8A3B24; }

/* ---------- Empty state ---------- */
.admin-empty { padding: 48px 20px; text-align: center; color: var(--ink-soft); font-size: 13.5px; }
.admin-empty .icon { width: 26px; height: 26px; margin: 0 auto 10px; color: var(--ink-faint); display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .admin-content { padding: 22px 18px 48px; }
  .admin-topbar { padding: 16px 18px; flex-wrap: wrap; }
}
@media (max-width: 780px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; padding: 10px 0; }
  .admin-sidebar .brand { display: none; }
  .admin-nav-label { display: none; }
  .admin-nav { flex-direction: row; padding: 0 8px; }
  .admin-nav a { white-space: nowrap; }
  .admin-sidebar-footer { border-top: none; margin-top: 0; padding: 0 12px; display: flex; align-items: center; }
  .admin-sidebar-footer .admin-user { display: none; }
}
