/* ==========================================================================
   EWER CMS — ENHANCED BACKGROUND SYSTEM
   Adds: animated gradient, grid overlay, floating orbs, glassmorphism accents
   Works in both light and dark mode.
   ========================================================================== */

/* ── 1. CSS CUSTOM PROPERTIES ─────────────────────────────────────────── */
:root {
  --bg-gradient-light: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 30%, #f5f0ff 60%, #fdf2ff 100%);
  --bg-gradient-dark:  linear-gradient(135deg, #0a0f1e 0%, #0d1b2a 30%, #0f1729 60%, #0c1322 100%);
  --orb-1-light: radial-gradient(circle at 20% 30%, rgba(99,102,241,0.18) 0%, transparent 55%);
  --orb-2-light: radial-gradient(circle at 80% 70%, rgba(139,92,246,0.14) 0%, transparent 50%);
  --orb-3-light: radial-gradient(circle at 60% 10%, rgba(59,130,246,0.10) 0%, transparent 45%);
  --orb-1-dark:  radial-gradient(circle at 20% 30%, rgba(99,102,241,0.25) 0%, transparent 55%);
  --orb-2-dark:  radial-gradient(circle at 80% 70%, rgba(139,92,246,0.20) 0%, transparent 50%);
  --orb-3-dark:  radial-gradient(circle at 60% 10%, rgba(56,189,248,0.12) 0%, transparent 45%);
  --grid-light: rgba(99,102,241,0.06);
  --grid-dark:  rgba(99,102,241,0.08);
}

/* ── 2. BODY BACKGROUND ───────────────────────────────────────────────── */
body {
  background-color: unset !important;
  background-image:
    var(--orb-1-light),
    var(--orb-2-light),
    var(--orb-3-light),
    var(--bg-gradient-light) !important;
  background-repeat: no-repeat !important;
  background-attachment: fixed !important;
  background-size: cover !important;
  min-height: 100vh;
  position: relative;
}

/* ── 3. GRID OVERLAY (::before already used for map, so we use a layer) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-light) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-light) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* ── 4. FLOATING ORBS ANIMATION ───────────────────────────────────────── */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  animation: orbFloat 14s ease-in-out infinite;
  will-change: transform;
}

.bg-orb-1 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(99,102,241,0.22) 0%, transparent 70%);
  top: -120px;
  left: -100px;
  animation-delay: 0s;
}

.bg-orb-2 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(139,92,246,0.18) 0%, transparent 70%);
  bottom: -80px;
  right: -80px;
  animation-delay: -5s;
  animation-direction: reverse;
}

.bg-orb-3 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(59,130,246,0.14) 0%, transparent 70%);
  top: 40%;
  right: 15%;
  animation-delay: -9s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(24px, -20px) scale(1.04); }
  66%       { transform: translate(-16px, 14px) scale(0.97); }
}

/* ── 5. ENSURE CONTENT SITS ABOVE OVERLAYS ───────────────────────────── */
.navbar,
.container,
.auth-container,
.loading-overlay,
#loadingOverlay {
  position: relative;
  z-index: 1;
}

/* ── 6. NAVBAR — GLASSMORPHISM ────────────────────────────────────────── */
.navbar {
  background: rgba(255,255,255,0.80) !important;
  backdrop-filter: blur(14px) saturate(1.6) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.6) !important;
  border-bottom: 1px solid rgba(99,102,241,0.14) !important;
  box-shadow: 0 1px 24px rgba(99,102,241,0.08) !important;
}

/* ── 7. CARDS — GLASSMORPHISM, LIGHT MODE ─────────────────────────────── */
.card,
.stat-card,
.auth-card {
  background: rgba(255,255,255,0.82) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(99,102,241,0.12) !important;
  box-shadow: 0 4px 24px rgba(99,102,241,0.07), 0 1px 4px rgba(0,0,0,0.04) !important;
}

.card:hover,
.stat-card:hover {
  box-shadow: 0 8px 32px rgba(99,102,241,0.13), 0 2px 8px rgba(0,0,0,0.05) !important;
  border-color: rgba(99,102,241,0.22) !important;
}

/* ── 8. AUTH SCREEN — PREMIUM BACKDROP ───────────────────────────────── */
.auth-container {
  background: transparent !important;
}

.auth-card {
  background: rgba(255,255,255,0.90) !important;
  backdrop-filter: blur(20px) saturate(1.8) !important;
  -webkit-backdrop-filter: blur(20px) saturate(1.8) !important;
  border: 1px solid rgba(99,102,241,0.18) !important;
  box-shadow:
    0 20px 60px rgba(99,102,241,0.15),
    0 4px 16px rgba(0,0,0,0.06),
    inset 0 1px 0 rgba(255,255,255,0.9) !important;
  border-radius: 16px !important;
}

/* Login identity mark: kept separate from the authenticated top-bar logo. */
.auth-brand-mark {
  width: 104px;
  height: 104px;
  margin: 0 auto 1rem;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 24px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(15,118,67,0.20);
  box-shadow:
    0 12px 30px rgba(15,118,67,0.13),
    0 3px 10px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.95);
}

.auth-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 16px;
  background: #ffffff;
}

html.dark .auth-brand-mark,
body.dark-mode .auth-brand-mark {
  background: rgba(255,255,255,0.96);
  border-color: rgba(74,222,128,0.28);
  box-shadow:
    0 14px 34px rgba(0,0,0,0.38),
    0 0 0 1px rgba(74,222,128,0.08);
}

@media (max-width: 480px) {
  .auth-brand-mark {
    width: 88px;
    height: 88px;
    padding: 7px;
    border-radius: 20px;
  }

  .auth-logo {
    border-radius: 13px;
  }
}

/* ── 9. DARK MODE OVERRIDES ───────────────────────────────────────────── */
html.dark body {
  background-image:
    var(--orb-1-dark),
    var(--orb-2-dark),
    var(--orb-3-dark),
    var(--bg-gradient-dark) !important;
}

html.dark body::after {
  background-image:
    linear-gradient(var(--grid-dark) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-dark) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.5;
}

html.dark .bg-orb-1 {
  background: radial-gradient(circle, rgba(99,102,241,0.30) 0%, transparent 70%);
}
html.dark .bg-orb-2 {
  background: radial-gradient(circle, rgba(139,92,246,0.25) 0%, transparent 70%);
}
html.dark .bg-orb-3 {
  background: radial-gradient(circle, rgba(56,189,248,0.18) 0%, transparent 70%);
}

html.dark .navbar {
  background: rgba(15,23,42,0.85) !important;
  backdrop-filter: blur(14px) saturate(1.4) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.4) !important;
  border-bottom: 1px solid rgba(99,102,241,0.20) !important;
  box-shadow: 0 1px 24px rgba(0,0,0,0.35) !important;
}

html.dark .card,
html.dark .stat-card {
  background: rgba(17,28,46,0.80) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(99,102,241,0.18) !important;
  box-shadow: 0 4px 24px rgba(0,0,0,0.30), 0 1px 4px rgba(0,0,0,0.20) !important;
}

html.dark .card:hover,
html.dark .stat-card:hover {
  border-color: rgba(99,102,241,0.35) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.40), 0 0 0 1px rgba(99,102,241,0.20) !important;
}

html.dark .auth-card {
  background: rgba(13,20,36,0.92) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(99,102,241,0.25) !important;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.55),
    0 4px 16px rgba(0,0,0,0.30),
    inset 0 1px 0 rgba(255,255,255,0.05) !important;
}

/* ── 10. STAT-CARD ACCENT LEFT BAR IN DARK MODE WITH GLOW ─────────────── */
html.dark .stat-card {
  border-left-color: var(--primary) !important;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.30),
    -3px 0 12px rgba(99,102,241,0.25) !important;
}

/* ── 11. TABLE ROWS — SUBTLE GLASS ───────────────────────────────────── */
html.dark .table tbody tr:hover {
  background: rgba(99,102,241,0.07) !important;
}

/* ── 12. ZAMBIA PROVINCE MAP — ENHANCED TRANSPARENT WATERMARK ────────── */
body::before {
  content: '';
  position: fixed;

  /* Centre on the viewport — works on every page */
  top: 50vh;
  left: 50vw;
  transform: translate(-50%, -50%);

  /* Fills most of the viewport but leaves breathing room */
  width:  80vw;
  height: 80vh;
  max-width:  900px;
  max-height: 820px;

  background-image: url('/static/images/zambia-map-lines.png');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;

  /*
   * screen blend: pure black in the PNG becomes fully transparent.
   * Only the white glowing province lines remain visible — no box background.
   */
  mix-blend-mode: screen;
  opacity: 0.18;

  pointer-events: none;
  z-index: 0;
  animation: mapPulse 12s ease-in-out infinite, mapFloat 22s ease-in-out infinite;
  will-change: transform, opacity;
}

/* Dark mode — lines glow more prominently on dark backgrounds */
html.dark body::before {
  opacity: 0.32;
}

@keyframes mapPulse {
  0%, 100% { opacity: 0.18; }
  50%       { opacity: 0.26; }
}

/* Dark mode pulse */
html.dark body::before {
  animation: mapPulseDark 12s ease-in-out infinite, mapFloat 22s ease-in-out infinite;
}
@keyframes mapPulseDark {
  0%, 100% { opacity: 0.32; }
  50%       { opacity: 0.45; }
}

@keyframes mapFloat {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  33%      { transform: translate(-50%, -51.5%) scale(1.012); }
  66%      { transform: translate(-50%, -48.5%) scale(0.990); }
}

/* Dark mode map pulse: opacity is higher, handled by html.dark body::before rule above */

/* ── 13. PAGE TRANSITION SMOOTHING ───────────────────────────────────── */
.view {
  animation: viewFadeIn 0.25s ease;
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
