/* ==========================================================================
   E-RAPORT KURIKULUM MERDEKA - PWA & MOBILE APP MODE STYLESHEET
   Native Mobile Experience, Bottom Navigation & PWA Standalone Enhancements
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. PWA BOTTOM NAVIGATION BAR (App Bar Bawah Mobile)
   -------------------------------------------------------------------------- */
.pwa-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
  padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom, 0px)) 0.5rem;
  transition: transform 0.3s ease, background 0.3s ease;
}

@media (max-width: 768px) {
  .pwa-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
  }

  /* Padding kompensasi agar konten paling bawah tidak tertutup Bottom Bar */
  .content-wrapper {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

.pwa-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-decoration: none !important;
  color: #64748b;
  padding: 0.35rem 0.2rem;
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pwa-nav-item .pwa-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
  transition: transform 0.2s ease, color 0.2s ease;
  position: relative;
}

.pwa-nav-item .pwa-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
  transition: color 0.2s ease;
}

.pwa-nav-item:active {
  transform: scale(0.92);
}

.pwa-nav-item:hover {
  color: #4f46e5;
}

.pwa-nav-item.active {
  color: #4f46e5;
}

.pwa-nav-item.active .pwa-icon {
  transform: translateY(-2px);
  color: #4f46e5;
}

.pwa-nav-item.active .pwa-label {
  color: #4f46e5;
  font-weight: 700;
}

.pwa-nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  width: 20px;
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
}

/* Tombol Menu Tengah Menonjol (Pusat Aksi) */
.pwa-nav-item.center-action .pwa-center-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45);
  margin-top: -14px;
  margin-bottom: 2px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pwa-nav-item.center-action:active .pwa-center-btn {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* --------------------------------------------------------------------------
   2. PWA FLOATING INSTALL BANNER
   -------------------------------------------------------------------------- */
.pwa-install-banner {
  display: none;
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  left: 12px;
  right: 12px;
  max-width: 460px;
  margin: 0 auto;
  z-index: 1045;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.2);
  padding: 0.9rem 1.1rem;
  animation: pwaSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-install-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: contain;
  background: #f8fafc;
  padding: 3px;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.pwa-install-text {
  flex: 1;
  min-width: 0;
}

.pwa-install-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  margin-bottom: 2px;
}

.pwa-install-subtitle {
  font-size: 0.74rem;
  color: #64748b;
  line-height: 1.2;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pwa-btn-install {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff !important;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
  white-space: nowrap;
}

.pwa-btn-close {
  background: #f1f5f9;
  color: #64748b;
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   3. PWA STANDALONE MODE (Saat Aplikasi Dibuka dari Home Screen)
   -------------------------------------------------------------------------- */
@media (display-mode: standalone) {
  /* Hilangkan efek browser */
  body {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  /* Padding atas untuk notch iPhone / punch hole Android */
  .main-header.navbar {
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
  }

  /* Sembunyikan banner instal jika sudah terpasang */
  .pwa-install-banner {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   4. PWA DARK MODE COMPATIBILITY
   -------------------------------------------------------------------------- */
.dark-mode .pwa-bottom-bar {
  background: rgba(15, 23, 42, 0.94);
  border-top-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}

.dark-mode .pwa-nav-item {
  color: #94a3b8;
}

.dark-mode .pwa-nav-item:hover,
.dark-mode .pwa-nav-item.active {
  color: #818cf8;
}

.dark-mode .pwa-nav-item.active .pwa-icon,
.dark-mode .pwa-nav-item.active .pwa-label {
  color: #818cf8;
}

.dark-mode .pwa-install-banner {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.dark-mode .pwa-install-title {
  color: #f8fafc;
}

.dark-mode .pwa-install-subtitle {
  color: #94a3b8;
}

.dark-mode .pwa-install-icon {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.08);
}

.dark-mode .pwa-btn-close {
  background: #334155;
  color: #cbd5e1;
}

/* --------------------------------------------------------------------------
   5. MOBILE OPTIMIZATIONS FOR TABLES & CARDS
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  .content-header h4 {
    font-size: 1.15rem !important;
  }

  .stat-card-2 {
    padding: 1.1rem 1.2rem;
  }

  .stat-card-2 .stat-value {
    font-size: 1.75rem;
  }

  .hero-banner-2 {
    padding: 1.5rem 1.25rem;
    border-radius: 14px;
  }

  .hero-title {
    font-size: 1.35rem;
  }

  .card-premium-header {
    padding: 1rem 1.25rem;
  }

  .card-premium-body {
    padding: 1.1rem 1.25rem;
  }
}
