/* ==========================================================================
   KASFLOW - RETRO ARCADE 8-BIT DESIGN SYSTEM
   Modern, Cheerful, Gamified UI with 5 Themes & Centered Bottom FAB
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Press+Start+2P&family=Silkscreen:wght@400;700&display=swap');

:root {
  /* Common Pixel Tokens */
  --font-pixel: 'Press Start 2P', monospace;
  --font-arcade: 'Silkscreen', cursive;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  
  --radius-pixel: 0px;
  --pixel-size: 4px;

  /* 1. Default Theme: Cyberpunk Night Arcade (Neon Cyan & Pink) */
  --bg-app: #0d0b18;
  --bg-card: #17142b;
  --bg-card-hover: #1f1b3a;
  --bg-input: #100d22;
  --border-pixel: #3b3469;
  --border-dark: #05040d;
  
  --color-primary: #00f0ff;
  --color-primary-glow: rgba(0, 240, 255, 0.4);
  --color-accent: #ff2a85;
  --color-accent-glow: rgba(255, 42, 133, 0.4);
  --color-yellow: #ffd000;
  --color-yellow-glow: rgba(255, 208, 0, 0.4);
  --color-green: #39ff14;
  --color-green-glow: rgba(57, 255, 20, 0.4);
  --color-red: #ff3344;
  --color-orange: #ff7700;
  
  --text-main: #f5f3ff;
  --text-muted: #9b94c7;
  --text-dark: #121020;

  --shadow-pixel: 
    0 -3px 0 0 var(--border-dark),
    0 4px 0 0 var(--border-dark),
    -3px 0 0 0 var(--border-dark),
    4px 0 0 0 var(--border-dark),
    0 6px 0 0 rgba(0, 0, 0, 0.6);

  --shadow-btn: 
    inset -3px -3px 0px 0px rgba(0,0,0,0.5),
    inset 3px 3px 0px 0px rgba(255,255,255,0.3),
    0 4px 0 0 #000;
}

/* 2. Theme: Famicom Classic (Warm Parchment & Crimson Red) */
[data-theme="famicom"] {
  --bg-app: #f4efe4;
  --bg-card: #ffffff;
  --bg-card-hover: #faf6ed;
  --bg-input: #eee7d8;
  --border-pixel: #4a3e3d;
  --border-dark: #1f1919;
  
  --color-primary: #007799;
  --color-primary-glow: rgba(0, 119, 153, 0.25);
  --color-accent: #d90429;
  --color-accent-glow: rgba(217, 4, 41, 0.25);
  --color-yellow: #d48b00;
  --color-yellow-glow: rgba(212, 139, 0, 0.25);
  --color-green: #2b9348;
  --color-green-glow: rgba(43, 147, 72, 0.25);
  --color-red: #d90429;
  --color-orange: #e85d04;
  
  --text-main: #201b1b;
  --text-muted: #6e6565;
  --text-dark: #ffffff;

  --shadow-pixel: 
    0 -3px 0 0 var(--border-dark),
    0 4px 0 0 var(--border-dark),
    -3px 0 0 0 var(--border-dark),
    4px 0 0 0 var(--border-dark),
    0 6px 0 0 rgba(0, 0, 0, 0.25);
}

/* 3. Theme: Game Boy 90s Matrix (Monochrome LCD Green) */
[data-theme="gameboy"] {
  --bg-app: #8bac0f;
  --bg-card: #9bbc0f;
  --bg-card-hover: #a5c716;
  --bg-input: #8bac0f;
  --border-pixel: #306230;
  --border-dark: #0f380f;
  
  --color-primary: #0f380f;
  --color-primary-glow: rgba(15, 56, 15, 0.4);
  --color-accent: #306230;
  --color-accent-glow: rgba(48, 98, 48, 0.4);
  --color-yellow: #306230;
  --color-yellow-glow: rgba(48, 98, 48, 0.4);
  --color-green: #0f380f;
  --color-green-glow: rgba(15, 56, 15, 0.4);
  --color-red: #0f380f;
  --color-orange: #306230;
  
  --text-main: #0f380f;
  --text-muted: #306230;
  --text-dark: #9bbc0f;

  --shadow-pixel: 
    0 -3px 0 0 var(--border-dark),
    0 4px 0 0 var(--border-dark),
    -3px 0 0 0 var(--border-dark),
    4px 0 0 0 var(--border-dark),
    0 5px 0 0 rgba(15, 56, 15, 0.4);
}

/* 4. Theme: Vaporwave Sunset (Synthwave Violet & Warm Gold) */
[data-theme="vaporwave"] {
  --bg-app: #18092e;
  --bg-card: #251246;
  --bg-card-hover: #32195e;
  --bg-input: #120524;
  --border-pixel: #592e8a;
  --border-dark: #090214;
  
  --color-primary: #00f2fe;
  --color-primary-glow: rgba(0, 242, 254, 0.4);
  --color-accent: #ff007f;
  --color-accent-glow: rgba(255, 0, 127, 0.4);
  --color-yellow: #ffb703;
  --color-yellow-glow: rgba(255, 183, 3, 0.4);
  --color-green: #06d6a0;
  --color-green-glow: rgba(6, 214, 160, 0.4);
  --color-red: #ef233c;
  --color-orange: #fb8500;
  
  --text-main: #fce7f3;
  --text-muted: #c084fc;
  --text-dark: #18092e;

  --shadow-pixel: 
    0 -3px 0 0 var(--border-dark),
    0 4px 0 0 var(--border-dark),
    -3px 0 0 0 var(--border-dark),
    4px 0 0 0 var(--border-dark),
    0 6px 0 0 rgba(0, 0, 0, 0.7);
}

/* 5. Theme: Matrix Terminal (Pure OLED Black & Phosphor Green) */
[data-theme="matrix"] {
  --bg-app: #030a04;
  --bg-card: #061408;
  --bg-card-hover: #0c240f;
  --bg-input: #020803;
  --border-pixel: #134e19;
  --border-dark: #010401;
  
  --color-primary: #00ff66;
  --color-primary-glow: rgba(0, 255, 102, 0.5);
  --color-accent: #22c55e;
  --color-accent-glow: rgba(34, 197, 94, 0.4);
  --color-yellow: #84cc16;
  --color-yellow-glow: rgba(132, 204, 22, 0.4);
  --color-green: #00ff66;
  --color-green-glow: rgba(0, 255, 102, 0.5);
  --color-red: #ef4444;
  --color-orange: #f97316;
  
  --text-main: #dcfce7;
  --text-muted: #4ade80;
  --text-dark: #030a04;

  --shadow-pixel: 
    0 -3px 0 0 var(--border-dark),
    0 4px 0 0 var(--border-dark),
    -3px 0 0 0 var(--border-dark),
    4px 0 0 0 var(--border-dark),
    0 6px 0 0 rgba(0, 0, 0, 0.9);
}

/* Legacy theme attributes fallback */
[data-theme="night"] {
  /* maps to cyberpunk */
}
[data-theme="day"] {
  /* maps to famicom */
  --bg-app: #f4efe4;
  --bg-card: #ffffff;
  --bg-card-hover: #faf6ed;
  --bg-input: #eee7d8;
  --border-pixel: #4a3e3d;
  --border-dark: #1f1919;
  --color-primary: #007799;
  --color-primary-glow: rgba(0, 119, 153, 0.25);
  --color-accent: #d90429;
  --color-accent-glow: rgba(217, 4, 41, 0.25);
  --color-yellow: #d48b00;
  --color-yellow-glow: rgba(212, 139, 0, 0.25);
  --color-green: #2b9348;
  --color-green-glow: rgba(43, 147, 72, 0.25);
  --color-red: #d90429;
  --color-orange: #e85d04;
  --text-main: #201b1b;
  --text-muted: #6e6565;
  --text-dark: #ffffff;
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
  padding-bottom: 96px; /* Space for bottom nav */
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* CRT Scanline Effect (Toggleable) */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  opacity: 0.45;
}

body.no-crt .crt-overlay {
  display: none;
}

/* Pixel Box Containers */
.pixel-box {
  background: var(--bg-card);
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-pixel);
  position: relative;
  padding: 16px;
  margin-bottom: 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pixel-box-primary {
  border-color: var(--color-primary);
  box-shadow: 
    0 -3px 0 0 var(--border-dark),
    0 4px 0 0 var(--border-dark),
    -3px 0 0 0 var(--border-dark),
    4px 0 0 0 var(--border-dark),
    0 0 12px var(--color-primary-glow);
}

.pixel-box-accent {
  border-color: var(--color-accent);
  box-shadow: 
    0 -3px 0 0 var(--border-dark),
    0 4px 0 0 var(--border-dark),
    -3px 0 0 0 var(--border-dark),
    4px 0 0 0 var(--border-dark),
    0 0 12px var(--color-accent-glow);
}

/* Retro Buttons */
.pixel-btn {
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.4;
  padding: 10px 16px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  text-transform: uppercase;
  user-select: none;
  transition: all 0.08s ease;
}

.pixel-btn:hover {
  filter: brightness(1.12);
}

.pixel-btn:active {
  transform: translateY(3px);
  box-shadow: 
    inset 2px 2px 0px 0px rgba(0,0,0,0.6),
    0 1px 0 0 #000;
}

.pixel-btn-cyan {
  background: var(--color-primary);
  color: #060511;
  font-weight: bold;
}

.pixel-btn-pink {
  background: var(--color-accent);
  color: #ffffff;
  font-weight: bold;
}

.pixel-btn-yellow {
  background: var(--color-yellow);
  color: #1a1600;
  font-weight: bold;
}

.pixel-btn-green {
  background: var(--color-green);
  color: #051a05;
  font-weight: bold;
}

.pixel-btn-red {
  background: var(--color-red);
  color: #ffffff;
  font-weight: bold;
}

.pixel-btn-sm {
  font-size: 9px;
  padding: 6px 10px;
  border-width: 2px;
}

/* App Header */
.arcade-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-app);
  border-bottom: 3px solid var(--border-dark);
  padding: 10px 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-coin {
  width: 26px;
  height: 26px;
  animation: spinCoin 3s infinite steps(4);
}

@keyframes spinCoin {
  0% { transform: scaleX(1); }
  25% { transform: scaleX(0.2); }
  50% { transform: scaleX(1); }
  75% { transform: scaleX(0.2); }
  100% { transform: scaleX(1); }
}

.brand-title {
  font-family: var(--font-pixel);
  font-size: 16px;
  letter-spacing: -0.5px;
  color: var(--color-primary);
  text-shadow: 2px 2px 0px #000;
}

.brand-tag {
  font-family: var(--font-arcade);
  font-size: 11px;
  color: var(--color-yellow);
  background: rgba(255, 208, 0, 0.15);
  padding: 2px 6px;
  border: 1px dashed var(--color-yellow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-toggle-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 14px;
}

/* Language Toggle Badge in Header */
.lang-badge-btn {
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 2px 0 #000;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: bold;
}

.lang-badge-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Gamification Top Bar */
.arcade-statusbar {
  max-width: 900px;
  margin: 8px auto 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  padding: 6px 12px;
  border: 2px solid var(--border-dark);
}

.user-level-badge {
  font-family: var(--font-pixel);
  font-size: 9px;
  background: var(--color-accent);
  color: #fff;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}

.xp-bar-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.xp-bar-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-arcade);
  font-size: 11px;
  color: var(--text-muted);
}

.pixel-progress-track {
  width: 100%;
  height: 10px;
  background: #000;
  border: 2px solid var(--border-dark);
  position: relative;
  overflow: hidden;
}

.pixel-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-green));
  transition: width 0.4s ease;
  position: relative;
}

.streak-counter {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--color-yellow);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  background: rgba(255, 208, 0, 0.12);
  padding: 4px 8px;
  border: 1px solid rgba(255, 208, 0, 0.3);
}

/* Floating Panic SOS Button */
.floating-panic-btn {
  position: fixed;
  bottom: 84px;
  right: 16px;
  z-index: 1005;
  background: var(--color-red);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 10px 14px;
  border: 3px solid #000;
  box-shadow: 
    0 0 15px rgba(255, 51, 68, 0.7),
    0 4px 0 #000;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  animation: panicPulse 1.2s infinite alternate ease-in-out;
}

@keyframes panicPulse {
  0% { transform: scale(1); box-shadow: 0 0 8px rgba(255, 51, 68, 0.6), 0 4px 0 #000; }
  100% { transform: scale(1.06); box-shadow: 0 0 22px rgba(255, 51, 68, 0.95), 0 5px 0 #000; }
}

/* ==========================================================================
   BOTTOM NAVIGATION - PERFECTLY CENTERED FAB (+)
   ========================================================================== */
.arcade-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-app);
  border-top: 3px solid var(--border-dark);
  z-index: 1000;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.nav-container {
  display: flex;
  width: 100%;
  max-width: 900px;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  position: relative;
}

/* Grouping Left and Right for symmetric balance */
.nav-group-left, .nav-group-right {
  display: flex;
  flex: 1;
  justify-content: space-around;
  align-items: center;
}

/* Perfectly Centered FAB Container */
.nav-fab-wrap {
  position: relative;
  top: -16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1002;
  margin: 0 8px;
}

.nav-fab {
  width: 52px;
  height: 52px;
  border-radius: 0;
  background: var(--color-primary);
  color: #070614;
  border: 3px solid #000;
  box-shadow: 
    0 4px 0 #000, 
    0 0 16px var(--color-primary-glow),
    inset 2px 2px 0 rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.nav-fab:hover {
  transform: scale(1.06);
  filter: brightness(1.15);
}

.nav-fab:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #000;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.1s ease;
  position: relative;
  text-decoration: none;
  min-width: 48px;
}

.nav-btn .nav-icon {
  font-size: 18px;
  line-height: 1;
}

.nav-btn .nav-label {
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: -0.3px;
}

.nav-btn.active {
  color: var(--color-primary);
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 3px;
  background: var(--color-primary);
  box-shadow: 0 0 8px var(--color-primary);
}

/* Main Content Area */
.app-main {
  max-width: 900px;
  margin: 16px auto;
  padding: 0 16px;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: arcadeFadeIn 0.2s ease-out;
}

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

/* Typography & Utilities */
.pixel-title {
  font-family: var(--font-pixel);
  font-size: 13px;
  color: var(--color-primary);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pixel-subtitle {
  font-family: var(--font-arcade);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.text-gold { color: var(--color-yellow); }
.text-pink { color: var(--color-accent); }
.text-cyan { color: var(--color-primary); }
.text-green { color: var(--color-green); }
.text-red { color: var(--color-red); }

/* Toast Notifications */
#xp-toast-container {
  position: fixed;
  top: 75px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.xp-toast {
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 2px solid var(--color-yellow);
  box-shadow: 0 0 10px rgba(255, 208, 0, 0.4), 0 3px 0 #000;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideInToast 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.xp-toast .xp-plus {
  color: var(--color-yellow);
  font-weight: bold;
}

.xp-toast .xp-reason {
  color: var(--text-main);
}

.xp-toast.fade-out {
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.35s ease;
}

@keyframes slideInToast {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Modals */
.arcade-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 4, 11, 0.82);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.arcade-modal-backdrop.active {
  display: flex;
}

.arcade-modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 4px solid var(--border-dark);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.8), 0 8px 0 #000;
  padding: 20px;
  position: relative;
  animation: modalPop 0.18s ease-out;
}

@keyframes modalPop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px dashed var(--border-pixel);
}

.modal-close-btn {
  background: var(--color-red);
  color: #fff;
  border: 2px solid #000;
  font-family: var(--font-pixel);
  font-size: 11px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.pixel-input, .pixel-select, .pixel-textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 2px solid var(--border-pixel);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.pixel-input:focus, .pixel-select:focus, .pixel-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 8px var(--color-primary-glow);
}

.pixel-input-number, .currency-input {
  font-family: var(--font-pixel);
  font-size: 13px;
  letter-spacing: 0.5px;
}

/* Responsive Breakpoints */
@media (min-width: 768px) {
  .floating-panic-btn {
    bottom: 24px;
    right: 32px;
  }
  
  .nav-btn .nav-label {
    font-size: 9px;
  }
}
