/* Custom styling and animation enhancements for Hangouts */

:root {
  --mpesa-green: #00a859;
  --mpesa-dark: #007a3d;
  --chama-primary: #0f766e;
  --chama-dark: #0f172a;
}

/* Smooth transitions */
* {
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* Glassmorphism accents */
.glass-panel {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.dark-glass {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Phone STK Push Mockup Screen */
.phone-modal-frame {
  max-width: 360px;
  /* Keep the mock-up inside short/landscape screens instead of overstretching
     past the viewport (small phones such as the Redmi A15). */
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 2.25rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 8px #1e293b;
  position: relative;
}

@media (max-width: 360px) {
  .phone-modal-frame {
    border-radius: 1.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 5px #1e293b;
  }
  .phone-notch {
    width: 110px;
    height: 18px;
  }
}

.phone-notch {
  width: 140px;
  height: 22px;
  background-color: #1e293b;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  margin: 0 auto;
  flex-shrink: 0;
}

/* Pulsing badge */
.pulse-indicator {
  position: relative;
}
.pulse-indicator::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 2px white;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* Hide scrollbars but allow scrolling */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Animation helpers */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Print specific styles for Chama Statement */
@media print {
  @page {
    margin: 0;
  }

  body {
    background: white !important;
    color: black !important;
  }

  body * {
    visibility: hidden !important;
  }

  #statement-print-area {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 auto auto 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 12mm !important;
  }

  #statement-print-area * {
    visibility: visible !important;
  }

  .card, table {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
}


/* ================= DROPDOWN SELECT & OPTION VISIBILITY FIX ================= */
/* Force all native select dropdown options to render with high contrast dark text on white background */
select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 8px 12px !important;
}

select option:checked {
  background-color: #0d9488 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
}

select.bg-transparent option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}
/* ───────────── Loading animations ───────────── */
@keyframes hg-spin { to { transform: rotate(360deg); } }
@keyframes hg-shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes hg-bar { 0% { left: -40%; width: 40%; } 60% { left: 40%; width: 60%; } 100% { left: 100%; width: 10%; } }
@keyframes hg-pulse-ring { 0% { transform: scale(.85); opacity: .7; } 100% { transform: scale(1.5); opacity: 0; } }

.hg-spinner {
  display: inline-block; width: 1em; height: 1em; border-radius: 9999px;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: hg-spin .7s linear infinite; flex-shrink: 0;
}
.hg-spinner-lg { width: 44px; height: 44px; border-width: 4px; color: #0d9488; }

/* Button in a busy state: keeps its size, shows a spinner, ignores clicks */
.btn-loading { position: relative; pointer-events: none; opacity: .85; cursor: progress; }
.btn-loading .hg-spinner { margin-right: .5rem; }

/* Full-screen loader (page load / payment processing) */
#app-loader {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem; text-align: center; padding: 1.5rem;
  background: rgba(248, 250, 252, .94); backdrop-filter: blur(6px);
  transition: opacity .25s ease; 
}
#app-loader.is-payment { background: rgba(15, 23, 42, .78); color: #fff; }
#app-loader.is-hidden { opacity: 0; pointer-events: none; }
#app-loader .loader-ring { position: relative; width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; }
#app-loader .loader-ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 9999px; background: #14b8a6;
  animation: hg-pulse-ring 1.4s ease-out infinite;
}
#app-loader .loader-text { font-size: .85rem; font-weight: 700; color: #0f172a; }
#app-loader .loader-sub { font-size: .72rem; color: #64748b; margin-top: -.5rem; }
#app-loader.is-payment .loader-text { color: #fff; }
#app-loader.is-payment .loader-sub { color: #cbd5e1; }

/* Thin top progress bar for background data syncs */
#top-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 110; overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none; }
#top-progress.active { opacity: 1; }
#top-progress::after { content: ''; position: absolute; top: 0; height: 100%; background: linear-gradient(90deg, #14b8a6, #10b981); border-radius: 9999px; animation: hg-bar 1.1s ease-in-out infinite; }

/* Pull-to-refresh: the badge drops in as the screen is dragged down from the very top */
#pull-refresh { position: fixed; top: 0; left: 0; right: 0; height: 0; z-index: 105; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; pointer-events: none; }
#pull-refresh.settle { transition: height .2s ease; }
#pull-refresh .pr-badge { width: 38px; height: 38px; margin-bottom: 8px; border-radius: 9999px; background: #fff; box-shadow: 0 6px 18px rgba(15,23,42,.18); color: #0f766e; display: flex; align-items: center; justify-content: center; transform: scale(.6); opacity: 0; transition: opacity .15s ease, transform .15s ease; }
#pull-refresh.visible .pr-badge { opacity: 1; transform: scale(1); }
#pull-refresh.armed .pr-badge { background: #0f766e; color: #fff; }
#pull-refresh .pr-badge svg { width: 18px; height: 18px; }
#pull-refresh.refreshing .pr-badge svg { animation: hg-spin .8s linear infinite; }

/* Skeleton placeholders */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 37%, #e2e8f0 63%);
  background-size: 800px 100%; animation: hg-shimmer 1.3s linear infinite; border-radius: .5rem;
}
.skeleton-row td { padding: .9rem 1rem; }
.skeleton-row .skeleton { height: .8rem; }

@media (prefers-reduced-motion: reduce) {
  .hg-spinner, .skeleton, #top-progress::after, #app-loader .loader-ring::before { animation-duration: 2.5s; }
}

/* Three-dot loader */
.loader {
  width: 15px; aspect-ratio: 1; border-radius: 50%;
  --lc: #0f766e; --lc-dim: rgba(15,118,110,.14);
  animation: l5 1s infinite linear alternate;
}
#app-loader.is-payment .loader { --lc: #fff; --lc-dim: rgba(255,255,255,.2); }
@keyframes l5 {
  0%   { box-shadow: 20px 0 var(--lc), -20px 0 var(--lc-dim); background: var(--lc); }
  33%  { box-shadow: 20px 0 var(--lc), -20px 0 var(--lc-dim); background: var(--lc-dim); }
  66%  { box-shadow: 20px 0 var(--lc-dim), -20px 0 var(--lc); background: var(--lc-dim); }
  100% { box-shadow: 20px 0 var(--lc-dim), -20px 0 var(--lc); background: var(--lc); }
}

/* While the app is booting, hide the shell (navbar + screens) so the branded splash is the
   one and only thing painted. js/app.js removes .booting once start-up has finished. */
body.booting { overflow: hidden; }
body.booting #app-navbar,
body.booting main { display: none; }

/* Brand splash */
#brand-splash {
  position: fixed; inset: 0; z-index: 105; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  background: radial-gradient(circle at 50% 35%, #134e4a 0%, #0f172a 75%); color: #fff; transition: opacity .5s ease;
}
#brand-splash.hidden { display: none; }
#brand-splash.fade-out { opacity: 0; pointer-events: none; }
#brand-splash .splash-logo { width: 88px; height: 88px; filter: drop-shadow(0 12px 28px rgba(16,185,129,.45)); animation: splash-pop .7s cubic-bezier(.2,1.3,.4,1) both; }
.splash-word { display: flex; gap: .06em; font-size: 2.1rem; font-weight: 800; letter-spacing: .22em; padding-left: .22em; }
.splash-word span { opacity: 0; transform: translateY(10px); animation: splash-letter .45s ease forwards; }
.splash-tag { font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; color: #5eead4; opacity: 0; animation: splash-letter .6s ease 1.35s forwards; }
@keyframes splash-pop { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes splash-letter { to { opacity: 1; transform: none; } }

/* Secure entry feedback: restrained focus glow, PIN progress dots, and error shake. */
input[type="password"],
input.secure-entry {
  transition: box-shadow .22s ease, border-color .22s ease, transform .22s ease;
}
input[type="password"]:focus,
input.secure-entry:focus {
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, .13), 0 8px 18px rgba(15, 118, 110, .08);
}
@keyframes auth-input-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.012); }
  100% { transform: scale(1); }
}
.auth-input-pop { animation: auth-input-pop .18s ease-out; }
.pin-indicator {
  display: flex;
  justify-content: center;
  gap: .65rem;
  min-height: 9px;
  margin: -.2rem 0 .15rem;
}
.pin-indicator span {
  width: 7px;
  height: 7px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.pin-indicator span.filled {
  transform: scale(1.35);
  border-color: #0d9488;
  background: #14b8a6;
  box-shadow: 0 0 10px rgba(20, 184, 166, .4);
}
@keyframes auth-error-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
.auth-error:not(.hidden) { animation: auth-error-shake .32s ease both; }
.password-eye-toggle svg { transition: transform .2s ease, opacity .2s ease; }
.password-eye-toggle:active svg { transform: scale(.82) rotate(-12deg); }

/* Native APK bottom navigation; web/PWA keeps its existing top tabs. */
#native-bottom-nav { display: none; }
body.native-app { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
body.native-app #nav-tabs-bar { display: none !important; }
body.native-app::after {
  content: '';
  position: fixed;
  z-index: 44;
  right: 0;
  bottom: 0;
  left: 0;
  height: calc(82px + env(safe-area-inset-bottom));
  background: #9cc7e5;
}
body.native-app #native-bottom-nav {
  position: fixed;
  z-index: 45;
  left: max(9px, env(safe-area-inset-left));
  right: max(9px, env(safe-area-inset-right));
  bottom: max(4px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  min-height: 74px;
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 14px 14px 24px 24px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
  transform: translateY(16px);
  opacity: 0;
  animation: bottom-nav-in .38s cubic-bezier(.2,.8,.2,1) .08s forwards;
}
body.native-app #native-bottom-nav.hidden { display: none !important; }
.native-nav-item {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: 12px;
  padding: 5px 2px;
  color: #334155;
  background: transparent;
  font: inherit;
  cursor: pointer;
  transition: color .2s ease, transform .2s ease;
}
.native-nav-item svg { width: 20px; height: 20px; transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.native-nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 600; line-height: 1.1; }
.native-nav-item.active { color: #0f766e; }
.native-nav-item.active svg { transform: translateY(-1px) scale(1.08); }
@keyframes bottom-nav-in { to { transform: translateY(0); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .native-app #native-bottom-nav { animation-duration: .01ms; }
  .auth-error:not(.hidden) { animation: none; }
  .auth-input-pop { animation: none; }
  .pin-indicator span, .native-nav-item, .native-nav-item svg { transition-duration: .01ms; }
}
