/* ============================================================
   SitePulse AI - Performance-First Glassmorphism CSS Engine
   ============================================================ */

:root {
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --bg-card: rgba(20, 28, 48, 0.85);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(59, 130, 246, 0.4);
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-rose: #ef4444;
  --accent-amber: #f59e0b;
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base rendering */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  /* Single lightweight gradient — no background-attachment:fixed (kills GPU on scroll) */
  background-image: radial-gradient(ellipse at top left, rgba(59, 130, 246, 0.09) 0%, transparent 55%),
                    radial-gradient(ellipse at bottom right, rgba(16, 185, 129, 0.06) 0%, transparent 55%);
  background-size: 100% 100%;
  min-height: 100vh;
  text-rendering: optimizeSpeed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Page Load Fade-in ────────────────────────────────────── */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

main {
  animation: pageIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Glass Cards — blur only once at container level ────────
   Key: contain:layout style paint  →  browser skips re-layout
   Use solid semi-opaque bg instead of heavy blur per-card     */
.glass-card {
  background: var(--bg-card);
  /* backdrop-filter only on top-level cards — reduces GPU layers */
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: 0 4px 20px -6px rgba(0, 0, 0, 0.45);
  /* GPU-friendly transforms only */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  contain: layout style;
  transform: translateZ(0);
  will-change: auto; /* only activate on hover */
}

.glass-card:hover {
  will-change: transform;
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 28px -4px rgba(0, 0, 0, 0.52);
  transform: translateY(-2px);
}

.glass-card:not(:hover) {
  will-change: auto;
}

/* ── Navigation — single blur layer only here ───────────── */
.glass-nav {
  background: rgba(9, 13, 22, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  /* composited layer — keeps it off the main thread */
  transform: translateZ(0);
  will-change: transform;
}

/* ── Glow Helpers ───────────────────────────────────────── */
.glow-emerald { box-shadow: 0 0 18px -4px rgba(16, 185, 129, 0.22); }
.glow-rose    { box-shadow: 0 0 18px -4px rgba(239, 68, 68, 0.22); }
.glow-blue    { box-shadow: 0 0 18px -4px rgba(59, 130, 246, 0.22); }

/* ── Smooth Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar       { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Skeleton Loader ────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}

/* ── Page Transition Overlay ─────────────────────────────── */
#page-transition {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9998;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

#page-transition.leaving {
  opacity: 1;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Toast Notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(20px) scale(0.93); }
}

.toast {
  pointer-events: auto;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform: translateZ(0);
}

.toast.removing {
  animation: toastOut 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.toast-success {
  background: rgba(16, 185, 129, 0.96);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.toast-error {
  background: rgba(239, 68, 68, 0.96);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.toast-info {
  background: rgba(59, 130, 246, 0.96);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* ── Interactive Buttons ─────────────────────────────────── */
button, a[role="button"], .btn {
  transition: transform var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast);
}

button:active, .btn:active {
  transform: scale(0.97);
}

/* ── Status Pulse Dot  ───────────────────────────────────── */
@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.55; transform: scale(1.25); }
}

.status-dot-live {
  animation: statusPulse 2.2s ease-in-out infinite;
}

/* ── Stat Counter Roll-up ─────────────────────────────────── */
.stat-value {
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

/* ── Table rows smooth hover ─────────────────────────────── */
.hover-row {
  transition: background-color var(--transition-fast);
}

.hover-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
