/* ========================================
   AI bloop Admin Dashboard — Styles
   ======================================== */

:root {
  --bg: #0a0c14;
  --bg-alt: #12141f;
  --border: #1e2030;
  --border-light: #262840;
  --text: #e8e9ed;
  --text-muted: #7a7d8e;
  --accent: #1a56db;
  --accent-light: rgba(26,86,219,0.12);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --yellow: #f5c542;
  --font-head: 'Fraunces', serif;
  --font-body: 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ============ LOGIN ============ */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,12,20,0.92);
  backdrop-filter: blur(16px);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 44px 40px;
  width: 400px;
  max-width: 92vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 28px;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
  font-family: var(--font-body);
}
.login-heading {
  text-align: center;
  font-family: var(--font-head);
  font-size: 1.35rem;
  font-weight: 400;
  margin-bottom: 4px;
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 28px;
}
.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.field-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s;
}
.field-input:focus { border-color: var(--accent); }
.login-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  min-height: 20px;
  margin: 10px 0 4px;
}
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: opacity 0.2s, box-shadow 0.2s;
}
.btn-primary:hover { box-shadow: 0 4px 20px rgba(26,86,219,0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============ DASHBOARD ============ */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px 60px;
}

/* Header */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.dash-header-left { display: flex; align-items: center; gap: 12px; }
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 600;
}
.header-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.dash-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.last-updated {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.btn-outline {
  padding: 8px 16px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color 0.2s;
}
.btn-outline:hover { border-color: var(--text-muted); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 6px;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.stat-sub.up { color: var(--green); }
.stat-sub.down { color: var(--red); }

/* Skeleton */
.skeleton-text {
  background: linear-gradient(90deg, var(--border) 25%, var(--border-light) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  color: transparent !important;
  min-width: 60px;
  display: inline-block;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Cards */
.card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.card-head h3 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 500;
}
.badge-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Search */
.search-input {
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  width: 260px;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.data-table tr:last-child td { border-bottom: none; }
.table-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 12px !important;
}
.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 12px !important;
}

/* Badges */
.plan-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
}
.plan-badge.paid { background: var(--green-bg); color: var(--green); }
.plan-badge.free { background: var(--border-light); color: var(--text-muted); }

/* Status */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.green { background: var(--green); }
.status-dot.red { background: var(--red); }

/* Progress bar */
.msg-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-progress-text {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}
.msg-bar {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.msg-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s;
}
.msg-bar-fill.high { background: var(--yellow); }
.msg-bar-fill.full { background: var(--red); }

/* Section error */
.section-error {
  color: var(--red);
  font-size: 13px;
  padding: 12px 0 0;
  text-align: center;
}

/* Footer */
.dash-footer {
  text-align: center;
  padding: 32px 0 16px;
}
.dash-footer a {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}
.dash-footer a:hover { color: var(--text); }

/* Delete button */
.btn-delete {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-delete:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}
.btn-delete svg { width: 15px; height: 15px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(10,12,20,0.8);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 440px;
  max-width: 92vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.modal-title {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 500;
  margin-bottom: 12px;
}
.modal-body {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn-danger {
  padding: 8px 20px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.85; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 10001;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* Responsive */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dashboard { padding: 0 16px 40px; }
  .search-input { width: 180px; }
}
@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr; }
  .dash-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .search-input { width: 100%; }
  .card-head { flex-direction: column; gap: 10px; align-items: flex-start; }
}
