/* Font imported via HTML head with preconnect & display=swap */

:root {
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --bg-input: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-soft: rgba(226, 232, 240, 0.9);
  --border-strong: rgba(99, 102, 241, 0.25);
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --secondary-gradient: linear-gradient(135deg, #ec4899 0%, #d946ef 50%, #8b5cf6 100%);
  --cyan-gradient: linear-gradient(135deg, #0284c7 0%, #0ea5e9 50%, #38bdf8 100%);
  --emerald-gradient: linear-gradient(135deg, #059669 0%, #10b981 50%, #34d399 100%);
  --shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 0 1px 1px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 20px 35px -10px rgba(99, 102, 241, 0.15), 0 0 1px 1px rgba(99, 102, 241, 0.2);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --bottom-nav-bg: rgba(255, 255, 255, 0.9);
  --chip-bg: #ffffff;
  --chip-border: rgba(226, 232, 240, 0.9);
  --badge-bg: rgba(99, 102, 241, 0.92);
  --danger: #ef4444;
  --success: #10b981;
}

body.dark-theme {
  --bg-body: #07090e;
  --bg-surface: #0e121d;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 33, 52, 0.85);
  --bg-input: #131929;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-soft: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(99, 102, 241, 0.35);
  --shadow-card: 0 12px 30px -5px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.06);
  --shadow-hover: 0 20px 40px -10px rgba(0, 0, 0, 0.7), 0 0 25px rgba(99, 102, 241, 0.2);
  --nav-bg: rgba(9, 12, 19, 0.82);
  --bottom-nav-bg: rgba(11, 15, 24, 0.88);
  --chip-bg: #131929;
  --chip-border: rgba(255, 255, 255, 0.1);
  --badge-bg: rgba(99, 102, 241, 0.9);
  --danger: #ef4444;
  --success: #10b981;
}

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

html {
  scroll-behavior: smooth;
}

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: 95px;
  width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@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 60px rgba(0, 0, 0, 0.7), 0 0 25px rgba(99, 102, 241, 0.12);
  }
}

/* Floating High-Tech Animated Ambient Gradients */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: -2;
  pointer-events: none;
  background: 
    radial-gradient(ellipse at 20% 12%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(56, 189, 248, 0.10) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 45%, rgba(168, 85, 247, 0.08) 0%, transparent 55%);
  animation: bgFloat 18s infinite alternate ease-in-out;
}

body.dark-theme::before {
  background: 
    radial-gradient(ellipse at 20% 12%, rgba(99, 102, 241, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(56, 189, 248, 0.14) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 45%, rgba(168, 85, 247, 0.12) 0%, transparent 55%);
}

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

@keyframes bgFloat {
  0% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.06) translateY(-10px); }
  100% { transform: scale(1.12) translateY(5px); }
}

/* Status Bar Spacer */
.status-spacer {
  height: env(safe-area-inset-top, 24px);
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  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, 0px);
  left: 0;
  width: 100%;
  height: 64px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  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;
  text-decoration: none;
}
.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--primary-gradient);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.4);
  position: relative;
  transition: transform 0.25s ease;
}
.brand-icon::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 15px;
  background: var(--primary-gradient);
  opacity: 0.35;
  filter: blur(6px);
  z-index: -1;
}
.brand:hover .brand-icon {
  transform: scale(1.05) rotate(3deg);
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-text h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 40%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}
body.light-theme .brand-text h1 {
  background: linear-gradient(135deg, #0f172a 40%, #475569 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-text span {
  font-size: 10px;
  color: #38bdf8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wallet-chip {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  color: #a5b4fc;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.15);
  cursor: pointer;
  transition: all 0.25s ease;
  text-decoration: none;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
}

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

/* 2-Column Template Grid with 1:1 PERFECT SQUARE RATIO matching Screenshot */
.card-grid, .tmpl-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 10px;
  padding: 0 14px 20px;
}
@media (min-width: 480px) {
  .card-grid, .tmpl-grid-2col {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

.card, .tmpl-card {
  background: var(--cyber-card-bg, #121324);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}
.card:hover, .tmpl-card:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}
.card:active, .tmpl-card:active {
  transform: scale(0.975);
}

.card-img-wrap, .tmpl-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1 !important; /* EXACT SQUARE RATIO */
  height: auto !important;
  border-radius: 13px;
  overflow: hidden;
  background: #060712;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-img-wrap img, .tmpl-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: transform 0.35s ease;
  border-radius: 13px;
}
.card:hover .card-img-wrap img, .tmpl-card:hover .tmpl-img-wrap img {
  transform: scale(1.05);
}

.card-body, .tmpl-body {
  padding: 6px 3px 2px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-title, .tmpl-title {
  font-family: var(--chakra-font, 'Chakra Petch', sans-serif);
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
  margin-bottom: 2px;
}

.card-desc {
  display: none; /* Hide long desc on 2-col cards for clean screenshot look */
}

.card-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-price, .tmpl-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  margin-bottom: 4px;
}

.price-new, .tmpl-new-price {
  font-family: var(--chakra-font, 'Chakra Petch', sans-serif);
  font-size: 15px;
  font-weight: 800;
  color: #fbbf24;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.card-btn, .btn-tmpl-build {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #ffffff;
  font-family: var(--chakra-font, 'Chakra Petch', sans-serif);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: 10px;
  border: none;
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: filter 0.2s, transform 0.15s;
}

/* Bottom Navigation - Pixel Perfect */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background: rgba(8, 11, 22, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 999;
}
@media (min-width: 480px) {
  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #64748b;
  text-decoration: none;
  font-family: var(--chakra-font, 'Outfit', -apple-system, sans-serif);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 8px;
  transition: all 0.2s ease;
  position: relative;
  height: 100%;
}
.nav-item i {
  font-size: 19px;
  transition: transform 0.2s ease, filter 0.2s ease, color 0.2s ease;
}
.nav-item.active {
  color: #38bdf8;
  font-weight: 700;
}
.nav-item.active i {
  transform: translateY(-1px);
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.75));
}


/* EXTRA STYLES FOR OTHER PAGES (WALLET, CHECKOUT) SO THEY DONT BREAK */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.wallet-card { 
    background: linear-gradient(135deg, #6366f1, #8b5cf6); 
    padding: 30px; 
    border-radius: 15px; 
    text-align: center; 
    color: white; 
    margin-bottom: 20px; 
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3); 
}
.wallet-card h2 { font-size: 36px; margin: 10px 0; font-weight: 800; }

.form-group { margin-bottom: 15px; }
.form-control { 
    width: 100%; 
    padding: 12px; 
    border-radius: 8px; 
    border: 1px solid var(--border-soft); 
    background: var(--bg-input); 
    color: var(--text-primary); 
}
.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    display: inline-block;
    text-align: center;
}
.alert-success { background: rgba(16, 185, 129, 0.1); color: #10b981; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid rgba(16, 185, 129, 0.3); }
.alert-error { background: rgba(239, 68, 68, 0.1); color: #ef4444; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid rgba(239, 68, 68, 0.3); }
