/*
 * css/motion.css — AffiliPRO Motion & Glow Layer
 * Versi: 1.0 | By: Claude UI/Motion Designer
 * Include di semua HTML:
 *   <link rel="stylesheet" href="css/motion.css">
 * ============================================================
 */

/* ============================================================
   1. ANIMATED CANVAS BACKGROUND (dikendalikan motion.js)
   ============================================================ */
#motionBg {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
  transition: opacity 1s ease;
}
[data-theme="light"] #motionBg {
  opacity: 0.45;
}

/* Pastikan semua konten di atas canvas */
.sidebar, .main, .nav-item, .topbar, .content,
.ccard, .stat-card, .raport-card {
  position: relative;
  z-index: 1;
}

/* ============================================================
   2. SPLASH SCREEN — Entrance Dashboard
   ============================================================ */
#splashScreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #07090f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  pointer-events: all;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}
#splashScreen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: splashEnter 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes splashEnter {
  from { opacity: 0; transform: scale(0.7) translateY(30px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.splash-box {
  width: 72px; height: 72px;
  background: #00b87a;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 22px; color: #000;
  box-shadow: 0 0 60px rgba(0,184,122,0.7), 0 0 120px rgba(0,184,122,0.3);
  animation: splashGlow 2s ease infinite;
}
@keyframes splashGlow {
  0%,100% { box-shadow: 0 0 60px rgba(0,184,122,0.7), 0 0 120px rgba(0,184,122,0.3); }
  50%      { box-shadow: 0 0 80px rgba(0,184,122,0.9), 0 0 160px rgba(0,184,122,0.5); }
}
.splash-title {
  font-size: 28px; font-weight: 900; letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 30%, #00b87a 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: splashEnter 0.9s 0.15s cubic-bezier(0.22,1,0.36,1) both;
}
.splash-sub {
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.3);
  letter-spacing: 0.15em; text-transform: uppercase;
  animation: splashEnter 0.9s 0.3s cubic-bezier(0.22,1,0.36,1) both;
}
.splash-bar-wrap {
  margin-top: 48px;
  width: 180px; height: 3px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
  animation: splashEnter 0.9s 0.4s cubic-bezier(0.22,1,0.36,1) both;
}
.splash-bar {
  height: 100%;
  background: linear-gradient(90deg, #00b87a, #00e89a);
  border-radius: 99px;
  animation: splashProgress 1.8s 0.5s ease forwards;
  width: 0%;
  box-shadow: 0 0 12px rgba(0,184,122,0.8);
}
@keyframes splashProgress {
  0%   { width: 0%; }
  60%  { width: 80%; }
  100% { width: 100%; }
}

/* ============================================================
   3. PAGE CONTENT ENTRANCE (stagger after splash)
   ============================================================ */
.motion-fade-in {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22,1,0.36,1);
}
.motion-fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}
/* Stagger delays untuk stat cards */
.stat-card:nth-child(1) { transition-delay: 0.05s; }
.stat-card:nth-child(2) { transition-delay: 0.12s; }
.stat-card:nth-child(3) { transition-delay: 0.19s; }
.stat-card:nth-child(4) { transition-delay: 0.26s; }

/* Stagger untuk chart cards */
.ccard:nth-child(1) { transition-delay: 0.08s; }
.ccard:nth-child(2) { transition-delay: 0.18s; }

/* ============================================================
   4. GLOW BUTTON SYSTEM
   ============================================================ */

/* Primary action glow */
.btn-glow,
.tf-btn.active,
.s-btn.active,
.tab-btn.active {
  box-shadow: 0 0 14px rgba(0,184,122,0.45), 0 0 28px rgba(0,184,122,0.2) !important;
}

/* Nav item active glow */
.nav-item.active,
.s-icon.active {
  box-shadow: inset 0 0 0 1px rgba(0,184,122,0.35),
              0 0 16px rgba(0,184,122,0.12) !important;
}

/* Sidebar logo persistent glow */
.logo-box, .s-logo {
  box-shadow: 0 0 22px rgba(0,184,122,0.55), 0 0 44px rgba(0,184,122,0.2) !important;
  transition: box-shadow 0.3s ease !important;
}
.logo-box:hover, .s-logo:hover {
  box-shadow: 0 0 32px rgba(0,184,122,0.8), 0 0 64px rgba(0,184,122,0.35) !important;
}

/* All buttons — smoother transitions */
button, .nav-item, .s-icon, .tab-btn, .tf-btn, .s-btn,
.back-btn, .icon-btn, .theme-toggle, .prod-card,
.stat-card, .ccard, .soc-row, .notif-row {
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Hover ripple glow for interactive buttons */
.tf-btn:hover, .s-btn:hover, .tab-btn:hover {
  border-color: rgba(0,184,122,0.6) !important;
  color: #00b87a !important;
  box-shadow: 0 0 12px rgba(0,184,122,0.25) !important;
}

/* Stat card enhanced hover */
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,184,122,0.12), 0 0 0 1px rgba(0,184,122,0.2) !important;
}

/* Chart card hover */
.ccard:hover {
  box-shadow: 0 0 0 1px rgba(0,184,122,0.15), 0 8px 40px rgba(0,0,0,0.2) !important;
}

/* Back button glow */
.back-btn:hover {
  box-shadow: 0 0 16px rgba(0,184,122,0.2) !important;
}

/* ============================================================
   5. GLOW TEXT — Numbers & Values
   ============================================================ */
.stat-val {
  text-shadow: 0 0 20px rgba(0,184,122,0.25);
}
.pill.up {
  box-shadow: 0 0 8px rgba(0,184,122,0.2);
}
.pill.dn {
  box-shadow: 0 0 8px rgba(239,68,68,0.2);
}

/* Page title glow */
.page-title, .topbar-title {
  filter: drop-shadow(0 0 8px rgba(0,184,122,0.2));
}

/* ============================================================
   6. SIDEBAR GLOW RING (logo animation)
   ============================================================ */
.logo-box::after, .s-logo::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid rgba(0,184,122,0.4);
  animation: ringPulse 3s ease infinite;
  pointer-events: none;
}
.logo-box { position: relative; }
.s-logo   { position: relative; }

@keyframes ringPulse {
  0%,100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 0.9; transform: scale(1.08); }
}

/* ============================================================
   7. ACCENT UNDERLINE on active nav
   ============================================================ */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: linear-gradient(180deg, transparent, #00b87a, transparent);
  border-radius: 99px;
  animation: accentBar 2s ease infinite;
}
@keyframes accentBar {
  0%,100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* ============================================================
   8. SMOOTH SCROLLBAR TRACK (glowing)
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0,184,122,0.25);
  border-radius: 3px;
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0,184,122,0.5);
}

/* ============================================================
   9. THEME TOGGLE BUTTON — Enhanced
   ============================================================ */
.theme-toggle {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.theme-toggle:hover {
  box-shadow: 0 0 14px rgba(0,184,122,0.3) !important;
  transform: scale(1.08);
}
.theme-toggle:active {
  transform: scale(0.95);
}

/* ============================================================
   10. LIGHT MODE — GLOW ADJUSTMENTS
   ============================================================ */
[data-theme="light"] .stat-card:hover {
  box-shadow: 0 8px 32px rgba(0,184,122,0.15), 0 0 0 1px rgba(0,184,122,0.25) !important;
}
[data-theme="light"] .logo-box,
[data-theme="light"] .s-logo {
  box-shadow: 0 0 18px rgba(0,184,122,0.45), 0 0 36px rgba(0,184,122,0.15) !important;
}
[data-theme="light"] #motionBg {
  opacity: 0.3;
}
[data-theme="light"] .page-title,
[data-theme="light"] .topbar-title {
  filter: drop-shadow(0 0 6px rgba(0,184,122,0.15));
}
[data-theme="light"] .btn-glow,
[data-theme="light"] .tf-btn.active,
[data-theme="light"] .s-btn.active,
[data-theme="light"] .tab-btn.active {
  box-shadow: 0 0 10px rgba(0,184,122,0.35), 0 0 20px rgba(0,184,122,0.12) !important;
}

/* ============================================================
   11. PAGE TRANSITIONS (untuk navigasi antar halaman)
   ============================================================ */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main {
  animation: pageIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ============================================================
   12. MOBILE RESPONSIVE ADJUSTMENTS
   ============================================================ */
@media (max-width: 767px) {
  .splash-box  { width: 56px; height: 56px; font-size: 17px; }
  .splash-title { font-size: 20px; }
  .stat-card:hover { transform: none; } /* disable lift on touch */
  #motionBg { opacity: 0.6; }
}

/* ============================================================
   13. NOTIF DOT — Enhanced pulse
   ============================================================ */
.notif-dot.show {
  box-shadow: 0 0 0 0 rgba(239,68,68,0.5);
  animation: notifPulse 1.8s infinite;
}
@keyframes notifPulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
