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

:root {
  --bg-body: #f4f5f8;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-soft: rgba(99, 102, 241, 0.2);
  --border-strong: rgba(99, 102, 241, 0.35);
  --primary-gradient: linear-gradient(135deg, #8b5cf6, #3b82f6);
  --secondary-gradient: linear-gradient(135deg, #ec4899, #8b5cf6);
  --shadow-card: 0 8px 28px rgba(99, 102, 241, 0.14);
  --nav-bg: rgba(255, 255, 255, 0.88);
  --bottom-nav-bg: rgba(255, 255, 255, 0.9);
  --chip-bg: #fff;
  --chip-border: var(--border-strong);
  --badge-bg: rgba(99, 102, 241, 0.92);
}

body.dark-theme {
  --bg-body: #08090c;
  --bg-surface: #0f111a;
  --bg-card: rgba(15, 17, 26, 0.7);
  --bg-input: #151824;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-soft: rgba(139, 92, 246, 0.15);
  --border-strong: rgba(139, 92, 246, 0.3);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.5);
  --nav-bg: rgba(8, 9, 12, 0.85);
  --bottom-nav-bg: rgba(15, 17, 26, 0.92);
  --chip-bg: #151824;
  --chip-border: rgba(139, 92, 246, 0.3);
  --badge-bg: rgba(99, 102, 241, 0.9);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
  padding-bottom: 90px;
  width: 100%;
}

@media (min-width: 480px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
  }
}

/* Floating Animated Gradients & Grid Overlay */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: -2;
  pointer-events: none;
  background: 
    radial-gradient(ellipse at 25% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 85%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 45% 50%, rgba(236, 72, 153, 0.05) 0%, transparent 60%);
  animation: bgFloat 20s infinite alternate ease-in-out;
}

body.dark-theme::before {
  background: 
    radial-gradient(ellipse at 25% 10%, rgba(139, 92, 246, 0.15) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 85%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 45% 50%, rgba(236, 72, 153, 0.10) 0%, transparent 60%);
}

body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(139, 92, 246, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 92, 246, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

@keyframes bgFloat {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

/* Status Bar Spacer */
.status-spacer {
  height: env(safe-area-inset-top, 24px);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  z-index: 100;
}

@media (min-width: 480px) {
  .status-spacer {
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
  }
}

/* Top Navbar */
.navbar {
  position: fixed;
  top: env(safe-area-inset-top, 24px);
  left: 0;
  width: 100%;
  height: 64px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-soft);
  transition: all 0.3s ease;
}

@media (min-width: 480px) {
  .navbar {
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
  animation: iconPulse 3s infinite;
}
@keyframes iconPulse {
  0% { box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
  50% { box-shadow: 0 4px 20px rgba(139, 92, 246, 0.6); }
  100% { box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.1;
}
.brand-text span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wallet-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 6px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.2s;
}
.wallet-chip:active { transform: scale(0.95); }
.wallet-chip i {
  color: #8b5cf6;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.3s;
}

/* Main Content Area */
.main-content {
  padding-top: calc(88px + env(safe-area-inset-top, 24px));
  padding-bottom: 24px;
}

/* Brand Strip & Stats */
.brand-strip {
  padding: 0 20px;
  margin-bottom: 24px;
}
.welcome-msg {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sub-msg {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.4;
}
.stats-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.stats-row::-webkit-scrollbar { display: none; }
.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  padding: 12px 16px;
  border-radius: 16px;
  min-width: 120px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-card);
}
.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
}
.stat-icon.s-1 { background: var(--primary-gradient); }
.stat-icon.s-2 { background: var(--secondary-gradient); }
.stat-icon.s-3 { background: linear-gradient(135deg, #10b981, #059669); }
.stat-text {
  display: flex;
  flex-direction: column;
}
.stat-text strong { font-size: 14px; color: var(--text-primary); }
.stat-text span { font-size: 11px; color: var(--text-muted); }

/* Search & Filter */
.search-wrap {
  padding: 0 20px;
  margin-bottom: 20px;
  position: sticky;
  top: calc(88px + env(safe-area-inset-top, 24px));
  z-index: 90;
}
.search-box {
  position: relative;
  width: 100%;
}
.search-box i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
}
.search-box input {
  width: 100%;
  padding: 16px 16px 16px 44px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.05);
  outline: none;
  transition: all 0.3s;
}
.search-box input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.15);
}

.filter-row {
  display: flex;
  gap: 10px;
  padding: 0 20px;
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.3s;
}
.filter-chip.active {
  background: var(--primary-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding: 0 20px;
}
@media (min-width: 480px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

.card {
  background: var(--bg-card);
  border-radius: 24px;
  border: 1px solid var(--border-soft);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
}
.card:active { transform: scale(0.97); }

.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-surface);
}
.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-badge {
  position: absolute;
  top: 10px; right: 10px;
  background: var(--badge-bg);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-body {
  padding: 16px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-price {
  display: flex;
  flex-direction: column;
}
.price-new {
  font-size: 16px;
  font-weight: 800;
  color: #10b981; /* Green */
}
.price-old {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: line-through;
  font-weight: 500;
}
.card-btn {
  background: var(--primary-gradient);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
  transition: transform 0.2s;
}
.card-btn:active { transform: scale(0.9); }

/* Bottom Sheet Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
@media (min-width: 480px) {
  .modal-overlay {
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
  }
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.bottom-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-surface);
  border-radius: 32px 32px 0 0;
  padding: 24px 24px 90px 24px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  max-height: 85vh;
  overflow-y: auto;
  border-top: 1px solid var(--border-soft);
}
.modal-overlay.active .bottom-sheet {
  transform: translateY(0);
}
.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 4px;
  margin: 0 auto 20px;
}
.sheet-header {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}
.sheet-img {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow: var(--shadow-card);
}
.sheet-title-area {
  flex-grow: 1;
}
.sheet-title-area h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.sheet-badge {
  display: inline-block;
  background: var(--bg-input);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.sheet-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet-price {
  font-size: 22px;
  font-weight: 800;
  color: #10b981;
}
.sheet-price-old {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: line-through;
}
.sheet-content h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.sheet-content p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}
.sheet-actions {
  display: flex;
  gap: 12px;
}
.btn-primary {
  flex: 1;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  padding: 16px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
  cursor: pointer;
  text-decoration: none;
}
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 16px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }

/* Wallet Modal Tabs */
.wallet-tabs {
  display: flex;
  background: var(--bg-input);
  border-radius: 16px;
  padding: 4px;
  margin-bottom: 20px;
}
.wallet-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
}
.wallet-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.wallet-content {
  display: none;
}
.wallet-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from {opacity:0;} to {opacity:1;} }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.history-item:last-child { border-bottom: none; }
.history-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-primary);
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  height: 70px;
  background: var(--bottom-nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 90;
}

@media (min-width: 480px) {
  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
  }
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.3s;
}
.nav-item i {
  font-size: 22px;
  transition: transform 0.3s;
}
.nav-item.active {
  color: #8b5cf6;
}
.nav-item.active i {
  transform: translateY(-2px);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--bg-body);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 2000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Auth & Misc forms */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border-radius: 24px;
  padding: 30px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-soft);
}
.auth-title {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-primary);
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}
.form-control {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 15px;
  transition: all 0.3s;
}
.form-control:focus {
  border-color: #8b5cf6;
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.btn-block {
  width: 100%;
  margin-top: 8px;
}

/* Floating Guide Button */
.floating-guide-btn {
  position: fixed;
  right: 20px;
  bottom: 90px;
  background: var(--primary-gradient);
  color: #fff;
  padding: 12px 20px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
  z-index: 99;
  text-decoration: none;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@media (min-width: 480px) {
  .floating-guide-btn {
    right: calc(50% - 220px);
  }
}
.floating-guide-btn:hover {
  transform: translateY(-5px) scale(1.05);
}
.floating-guide-btn i {
  font-size: 16px;
}

/* Responsiveness adjustments for very narrow mobile screens */
@media (max-width: 360px) {
  .navbar {
    padding: 0 10px;
  }
  .brand {
    gap: 6px;
  }
  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  .brand-text h1 {
    font-size: 14px;
  }
  .brand-text span {
    font-size: 8px;
    letter-spacing: 0.5px;
  }
  .wallet-chip {
    padding: 4px 10px;
    font-size: 12px;
    gap: 4px;
  }
  .theme-toggle {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  .stats-row {
    gap: 8px;
  }
  .stat-box {
    padding: 8px 12px;
    min-width: 100px;
  }
  .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  .stat-text strong {
    font-size: 12px;
  }
  .stat-text span {
    font-size: 9px;
  }
}

