/* ============================================================
   SEO Fury Admin Dashboard
   Modern SaaS-style CSS  |  All classes use sf- prefix
   Font: Inter  |  Dark header  |  Light body
   ============================================================ */

/* ----- Reset & Base ----- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ----- 1. Root Container ----- */
.sf-admin-root {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f1f5f9;
  color: #111827;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----- 2. Header ----- */
.sf-admin-header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ----- 3. Logo ----- */
.sf-admin-header .sf-logo {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

/* ----- 4. Navigation (inside header) ----- */
.sf-admin-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.sf-admin-nav a {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 14px;
  font-weight: 500;
  padding: 16px 14px;
  position: relative;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.sf-admin-nav a:hover {
  color: #ffffff;
}

.sf-admin-nav a.active {
  color: #ffffff;
  opacity: 1;
}

.sf-admin-nav a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  background: #3b82f6;
  border-radius: 2px 2px 0 0;
}

/* ----- 5. Header Right (user / logout) ----- */
.sf-admin-header .sf-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.sf-admin-header .sf-header-right .sf-user-email {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 400;
}

.sf-admin-header .sf-header-right .sf-btn-logout {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0 12px;
  height: 32px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  font-family: inherit;
}

.sf-admin-header .sf-header-right .sf-btn-logout:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ----- 6. Container ----- */
.sf-admin-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ----- 7. Card ----- */
.sf-admin-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid #e2e8f0;
}

.sf-admin-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 16px;
  line-height: 1.4;
}

/* ----- 8. KPI Grid ----- */
.sf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

/* ----- 9. KPI Card ----- */
.sf-kpi-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: 20px 24px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sf-kpi-card .sf-kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: #111827;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.sf-kpi-card .sf-kpi-label {
  font-size: 13px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.sf-kpi-card.blue,
.sf-kpi-card.sf-kpi-blue   { border-left-color: #3b82f6; }
.sf-kpi-card.green,
.sf-kpi-card.sf-kpi-green  { border-left-color: #10b981; }
.sf-kpi-card.purple,
.sf-kpi-card.sf-kpi-purple { border-left-color: #8b5cf6; }
.sf-kpi-card.amber,
.sf-kpi-card.sf-kpi-amber  { border-left-color: #f59e0b; }

/* ----- 10. Charts Grid ----- */
.sf-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

/* ----- 11. Tables Grid ----- */
.sf-tables-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

/* ----- 12. Admin Table ----- */
.sf-admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.sf-admin-table th {
  background: #f8fafc;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.sf-admin-table td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
  vertical-align: middle;
}

.sf-admin-table tbody tr {
  transition: background 0.15s ease;
}

.sf-admin-table tbody tr:hover {
  background: #f8fafc;
}

.sf-admin-table tbody tr:last-child td {
  border-bottom: none;
}

/* ----- 13. Badges ----- */
.sf-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

/* Status badges */
.sf-badge.active,
.sf-badge.paid {
  background: #ecfdf5;
  color: #065f46;
}

.sf-badge.inactive,
.sf-badge.void {
  background: #fef2f2;
  color: #991b1b;
}

.sf-badge.unpaid {
  background: #fffbeb;
  color: #92400e;
}

/* Plan badges */
.sf-badge.free {
  background: #f1f5f9;
  color: #475569;
}

.sf-badge.pro_starter {
  background: #eff6ff;
  color: #1d4ed8;
}

.sf-badge.pro_business {
  background: #f5f3ff;
  color: #6d28d9;
}

.sf-badge.pro_agency {
  background: #fdf4ff;
  color: #a21caf;
}

.sf-badge.lifetime {
  background: #fefce8;
  color: #a16207;
}

/* ----- 14. Inputs & Selects ----- */
.sf-input,
.sf-select {
  height: 38px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  color: #111827;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.sf-input:focus,
.sf-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.sf-input::placeholder {
  color: #94a3b8;
}

.sf-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

textarea.sf-input {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ----- 15. Buttons ----- */
.sf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
  border: none;
  outline: none;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;

  /* Default: Primary */
  background: #3b82f6;
  color: #ffffff;
}

.sf-btn:hover {
  background: #2563eb;
}

.sf-btn:active {
  transform: scale(0.98);
}

.sf-btn.secondary {
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #e2e8f0;
}

.sf-btn.secondary:hover {
  background: #e2e8f0;
}

.sf-btn.danger {
  background: #ef4444;
  color: #ffffff;
}

.sf-btn.danger:hover {
  background: #dc2626;
}

.sf-btn.success {
  background: #10b981;
  color: #ffffff;
}

.sf-btn.success:hover {
  background: #059669;
}

.sf-btn.sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
}

.sf-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ----- 16. Row (flex utility) ----- */
.sf-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ----- 17. Domain Tag ----- */
.sf-domain {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  margin: 2px;
  color: #334155;
  gap: 4px;
}

.sf-domain button {
  border: 0;
  background: transparent;
  color: #ef4444;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease;
}

.sf-domain button:hover {
  color: #dc2626;
}

/* ----- 18. Pagination ----- */
.sf-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 8px 0;
}

.sf-pagination .sf-btn {
  min-width: 36px;
}

.sf-pagination .sf-page-info {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

/* ----- 19. Muted Text ----- */
.sf-muted {
  color: #94a3b8;
  font-size: 12px;
}

/* ----- 20. Spinner ----- */
.sf-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: sf-spin 0.6s linear infinite;
  display: inline-block;
}

.sf-spinner.lg {
  width: 36px;
  height: 36px;
  border-width: 4px;
}

/* ----- 21. Empty State ----- */
.sf-empty {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.6;
}

.sf-empty .sf-empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: block;
}

/* ----- 22. Toggle / Collapsible Section ----- */
.sf-toggle-section {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  margin-bottom: 12px;
  overflow: hidden;
}

.sf-toggle-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  transition: background 0.15s ease;
}

.sf-toggle-header:hover {
  background: #f8fafc;
}

.sf-toggle-header::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.sf-toggle-header.open::after {
  transform: rotate(-135deg);
}

.sf-toggle-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
  padding: 0 20px;
}

.sf-toggle-body.open {
  max-height: 600px;
  padding: 12px 20px 16px;
}

/* ----- 23. Copy Button ----- */
.sf-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  padding: 0;
  margin-left: 6px;
  flex-shrink: 0;
}

.sf-copy-btn:hover {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.sf-copy-btn.copied {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

/* ----- 24. Avatar ----- */
.sf-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3b82f6;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ----- 25. Progress Bar ----- */
.sf-progress {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
}

.sf-progress-bar {
  height: 100%;
  background: #3b82f6;
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 0;
}

/* ----- 26. Status Dot ----- */
.sf-status-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
  background: #cbd5e1;
}

.sf-status-dot.active,
.sf-status-dot.sf-dot-green  { background: #10b981; }
.sf-status-dot.inactive,
.sf-status-dot.sf-dot-red    { background: #ef4444; }
.sf-status-dot.pending  { background: #f59e0b; }

/* ----- 27. Toast Notification ----- */
.sf-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  animation: sf-slideIn 0.3s ease forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 380px;
}

.sf-toast.success {
  border-left: 4px solid #10b981;
}

.sf-toast.error {
  border-left: 4px solid #ef4444;
}

.sf-toast.warning {
  border-left: 4px solid #f59e0b;
}

.sf-toast.fade-out {
  animation: sf-fadeOut 0.3s ease forwards;
}

/* ============================================================
   Keyframe Animations
   ============================================================ */

@keyframes sf-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes sf-fadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sf-slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes sf-fadeOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ============================================================
   Utility Helpers
   ============================================================ */

.sf-text-right  { text-align: right; }
.sf-text-center { text-align: center; }
.sf-text-left   { text-align: left; }
.sf-font-mono   { font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace; font-size: 13px; }
.sf-truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-flex        { display: flex; }
.sf-flex-col    { display: flex; flex-direction: column; }
.sf-gap-sm      { gap: 8px; }
.sf-gap-md      { gap: 16px; }
.sf-gap-lg      { gap: 24px; }
.sf-mt-sm       { margin-top: 8px; }
.sf-mt-md       { margin-top: 16px; }
.sf-mb-sm       { margin-bottom: 8px; }
.sf-mb-md       { margin-bottom: 16px; }

/* ============================================================
   Responsive Breakpoints
   ============================================================ */

@media (max-width: 1024px) {
  .sf-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sf-kpi-grid {
    grid-template-columns: 1fr;
  }

  .sf-charts-grid {
    grid-template-columns: 1fr;
  }

  .sf-tables-grid {
    grid-template-columns: 1fr;
  }

  .sf-admin-nav {
    flex-wrap: wrap;
    gap: 0;
  }

  .sf-admin-nav a {
    padding: 10px 10px;
    font-size: 13px;
  }

  .sf-admin-header {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 8px;
  }

  .sf-admin-container {
    padding: 16px;
  }

  .sf-admin-card {
    padding: 16px;
  }

  .sf-admin-table {
    font-size: 13px;
  }

  .sf-admin-table th,
  .sf-admin-table td {
    padding: 10px 8px;
  }

  .sf-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

/* ----- 28. Error Card ----- */
.sf-admin-card.sf-error-card {
  border-left: 4px solid #ef4444;
  color: #b91c1c;
}

/* ----- 29. KPI Sub Text ----- */
.sf-kpi-sub {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 2px;
}

/* ----- 30. Small buttons/selects ----- */
.sf-btn-sm,
.sf-btn.sf-btn-sm { padding: 0 10px; height: 30px; font-size: 13px; border-radius: 6px; }
.sf-select-sm,
.sf-select.sf-select-sm { padding: 5px 8px; font-size: 13px; height: 30px; }
.sf-actions { white-space: nowrap; }

/* ----- 31. Progress Wrap ----- */
.sf-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ----- 32. License Key Mono ----- */
.sf-license-key {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: #374151;
}

/* ----- 33. User Cell ----- */
.sf-user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ----- 34. Verified / Unverified icons ----- */
.sf-verified   { color: #059669; font-weight: 700; font-size: 16px; }
.sf-unverified { color: #dc2626; font-weight: 700; font-size: 16px; }

/* ----- 35. Plan Badges (extended) ----- */
.sf-badge.all        { background: #f1f5f9; color: #475569; }
.sf-badge.admin      { background: #fce7f3; color: #be185d; }
.sf-badge.user-role  { background: #f1f5f9; color: #64748b; }
.sf-badge.amber      { background: #fef3c7; color: #b45309; }

/* ----- 36. Charts Grid canvas height ----- */
.sf-charts-grid .sf-admin-card { min-height: 280px; }
.sf-charts-grid canvas { max-height: 220px; }

/* ----- 37. Toggle Icon (used by JS) ----- */
.sf-toggle-icon { font-size: 12px; color: #9ca3af; transition: transform 0.2s ease; }

@media (max-width: 480px) {
  .sf-admin-header .sf-header-right .sf-user-email {
    display: none;
  }

  .sf-kpi-card .sf-kpi-value {
    font-size: 24px;
  }

  .sf-row {
    flex-direction: column;
    align-items: stretch;
  }

  .sf-row .sf-input,
  .sf-row .sf-select {
    width: 100%;
  }
}
