/* --- CSS Variables & Theming --- */
:root {
  --bg-primary: #0B1220;
  --bg-secondary: #131B2D;
  --bg-tertiary: #1E273A;
  --accent-gold: #D4AF37;
  --accent-gold-glow: rgba(212, 175, 55, 0.2);
  --accent-blue: #00A3FF;
  --accent-green: #22C55E;
  --accent-red: #EF4444;
  --text-primary: #FFFFFF;
  --text-secondary: #94A3B8;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
  --transition-fast: 0.2s ease;
  --header-height: 60px;
  --bottom-nav-height: 65px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

.hidden { display: none !important; }
h1, h2, h3 { font-weight: 600; }

#app-root {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--bottom-nav-height) + 10px);
  min-height: 100vh;
}

.container { width: 100%; max-width: 600px; margin: 0 auto; padding: 16px; }

/* --- Header --- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 16px; z-index: 100;
}

.logo-container { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 64px; height: 64px; border-radius: 10px; }
.brand-name { font-weight: 600; font-size: 1.1rem; letter-spacing: 0.5px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* --- Cart Badge --- */
.cart-badge {
  background: var(--accent-gold);
  color: var(--bg-primary);
  font-size: 0.65rem; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-primary);
  display: flex; justify-content: space-around;
  border-top: 1px solid var(--border-light);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--text-secondary); text-decoration: none;
  font-size: 0.75rem; width: 100%; transition: var(--transition-fast); cursor: pointer;
}
.nav-item svg { width: 20px; height: 20px; }
.nav-item.active { color: var(--accent-gold); }
.nav-item.active svg { stroke: var(--accent-gold); filter: drop-shadow(0 0 4px var(--accent-gold-glow)); }

/* --- Buttons --- */
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: 0.9rem; color: var(--text-secondary); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #b89326 100%);
  color: var(--bg-primary); font-weight: 600;
  padding: 10px 20px; border-radius: 10px;
  transition: all var(--transition-fast);
}
.btn-primary:active { transform: scale(0.96); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border-light);
  padding: 8px 16px; border-radius: 10px;
  transition: all var(--transition-fast);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  padding: 8px 16px;
  border-radius: 10px;
  transition: all var(--transition-fast);
  font-weight: 500;
}
.btn-outline:hover {
  background: var(--accent-gold);
  color: var(--bg-primary);
}

.icon-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-secondary); border: 1px solid var(--border-light);
  color: var(--text-primary); padding: 6px 12px; border-radius: 20px;
  font-size: 0.85rem; transition: all var(--transition-fast);
}
.icon-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold); }
.icon-btn svg { flex-shrink: 0; }

/* --- Cards --- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 20px; margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.card-glow {
  background: linear-gradient(135deg, rgba(212,175,55,0.08) 0%, var(--bg-secondary) 40%);
  border: 1px solid rgba(212,175,55,0.15);
}

/* --- Wallet Balance --- */
.wallet-balance {
  font-size: 1.3rem; font-weight: 800;
  background: linear-gradient(135deg, #fff 30%, var(--accent-gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-top: 4px;
}

.balance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.balance-card {
  background: var(--bg-secondary); border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md); padding: 16px;
}
.balance-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.balance-value { font-size: 1.3rem; font-weight: 600; margin-top: 4px; }

/* --- Product Cards --- */
.product-card {
  background: var(--bg-secondary); border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg); padding: 16px; margin-bottom: 12px;
  display: flex; gap: 14px; transition: all var(--transition-fast);
}
.product-card:active { transform: scale(0.99); }

.product-img {
  width: 90px; height: 90px; min-width: 90px;
  background: linear-gradient(135deg, var(--bg-tertiary), #263048);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
}
.product-img svg { color: var(--accent-gold); opacity: 0.6; }

.product-info { flex: 1; display: flex; flex-direction: column; }
.product-name { font-weight: 600; font-size: 1rem; margin-bottom: 2px; }
.product-desc { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.3; }
.product-price { font-weight: 700; color: var(--accent-gold); font-size: 1.1rem; }

.product-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.product-qty-input {
  width: 50px; padding: 6px; border-radius: 8px; 
  background: var(--bg-tertiary); border: 1px solid var(--border-light); 
  color: white; text-align: center; font-weight: 600;
  transition: border-color 0.2s;
}
.product-qty-input:focus { border-color: var(--accent-gold); outline: none; }


/* --- Quantity Selector --- */
.qty-selector {
  display: flex; align-items: center; gap: 0;
  background: var(--bg-tertiary); border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border-light);
}
.qty-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  color: var(--text-primary); font-size: 1rem; font-weight: 600;
  background: transparent; transition: background 0.15s;
}
.qty-btn:active { background: rgba(255,255,255,0.1); }
.qty-value {
  width: 32px; text-align: center; font-size: 0.9rem;
  font-weight: 600; color: var(--text-primary);
}

.add-cart-btn {
  background: linear-gradient(135deg, var(--accent-gold), #b89326);
  color: var(--bg-primary); font-weight: 600; font-size: 0.8rem;
  padding: 6px 14px; border-radius: 8px; white-space: nowrap;
}
.add-cart-btn.in-cart { background: var(--accent-green); color: #fff; }

/* --- Cart Items --- */
.cart-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border-light);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 500; font-size: 0.95rem; }
.cart-item-price { font-size: 0.8rem; color: var(--text-secondary); }
.cart-remove { color: var(--accent-red); font-size: 0.8rem; cursor: pointer; padding: 4px 8px; }

.cart-summary {
  background: linear-gradient(135deg, rgba(212,175,55,0.1), var(--bg-secondary));
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: var(--border-radius-lg); padding: 20px; margin-top: 16px;
}
.cart-total-row { display: flex; justify-content: space-between; padding: 6px 0; }
.cart-total-label { color: var(--text-secondary); }
.cart-total-value { font-weight: 600; }
.cart-grand-total { font-size: 1.2rem; color: var(--accent-gold); border-top: 1px solid var(--border-light); padding-top: 10px; margin-top: 6px; }

/* --- Transaction List --- */
.tx-list { list-style: none; }
.tx-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border-light);
}
.tx-item:last-child { border-bottom: none; }
.tx-icon {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.tx-icon.purchase { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.tx-icon.points { background: rgba(212,175,55,0.15); color: var(--accent-gold); }
.tx-icon.commission { background: rgba(34,197,94,0.15); color: var(--accent-green); }
.tx-icon.login { background: rgba(0,163,255,0.15); color: var(--accent-blue); }
.tx-icon.other { background: rgba(148,163,184,0.15); color: var(--text-secondary); }
.tx-info { flex: 1; }
.tx-type { font-weight: 500; font-size: 0.9rem; }
.tx-desc { font-size: 0.75rem; color: var(--text-secondary); }
.tx-amount { font-weight: 600; text-align: right; }
.tx-amount.positive { color: var(--accent-green); }
.tx-amount.negative { color: var(--accent-red); }
.tx-date { font-size: 0.65rem; color: var(--text-secondary); text-align: right; }

/* --- Section Headers --- */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; margin-top: 20px;
}
.section-title { font-size: 1rem; font-weight: 600; }
.section-link { font-size: 0.8rem; color: var(--accent-gold); cursor: pointer; }

/* --- Rank Badge --- */
.rank-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, rgba(212,175,55,0.2), rgba(212,175,55,0.05));
  border: 1px solid rgba(212,175,55,0.3);
  color: var(--accent-gold); padding: 4px 12px; border-radius: 20px;
  font-size: 0.8rem; font-weight: 600;
}

/* --- Progress Bar --- */
.progress-bar {
  width: 100%; height: 6px; background: var(--bg-tertiary);
  border-radius: 3px; margin-top: 8px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-gold), #f0d060);
  transition: width 0.5s ease;
}

/* --- Modal --- */
.modal-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-content {
  background: var(--bg-secondary); border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg); padding: 30px;
  width: 100%; max-width: 400px; position: relative;
}
.modal-content h2 { text-align: center; margin-bottom: 24px; }
.modal-content form { display: flex; flex-direction: column; gap: 12px; }
.modal-content input, .modal-content select {
  background: var(--bg-tertiary); border: 1px solid var(--border-light);
  border-radius: 8px; padding: 12px 16px; color: var(--text-primary); font-size: 1rem; width: 100%;
}
.modal-content input::placeholder { color: var(--text-secondary); }
.modal-content input:focus, .modal-content select:focus { outline: none; border-color: var(--accent-gold); }
.modal-close { position: absolute; top: 15px; right: 15px; font-size: 24px; color: var(--text-secondary); cursor: pointer; }

/* --- Toast --- */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--bg-tertiary); border: 1px solid var(--accent-gold);
  color: var(--text-primary); padding: 12px 24px; border-radius: 10px;
  font-size: 0.9rem; z-index: 300; opacity: 0; transition: all 0.3s ease;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state svg { color: var(--text-secondary); opacity: 0.4; margin-bottom: 16px; }
.empty-state p { color: var(--text-secondary); font-size: 0.95rem; }

/* --- Cart Float Bar --- */
.cart-float-bar {
  background: linear-gradient(135deg, var(--accent-gold), #b89326);
  color: var(--bg-primary); border-radius: 12px; padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; cursor: pointer; font-weight: 600;
  box-shadow: 0 4px 15px rgba(212,175,55,0.3);
  transition: transform 0.15s;
}
.cart-float-bar:active { transform: scale(0.98); }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }

@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(212,175,55,0.4); } 50% { box-shadow: 0 0 0 8px rgba(212,175,55,0); } }
.pulse { animation: pulse 2s infinite; }

/* --- Order Confirmation --- */
.order-success { text-align: center; padding: 20px; }
.order-success .checkmark {
  width: 64px; height: 64px; background: rgba(34,197,94,0.15);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 2rem;
}

/* --- View Title --- */
.view-title { font-size: 1.4rem; margin-bottom: 16px; font-weight: 600; }

/* --- Language Selector --- */
.lang-selector { display: flex; gap: 4px; margin-top: 4px; }
.lang-option { padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 0.75rem; font-weight: 600; background: var(--bg-tertiary); border: 1px solid var(--border-light); color: var(--text-secondary); transition: all 0.2s; }
.lang-option:hover { border-color: var(--accent-gold); color: var(--text-primary); }
.lang-option.active { background: var(--accent-gold); border-color: var(--accent-gold); color: var(--bg-primary); }
.lang-icon { font-size: 0.9rem; }

/* --- Tooltips --- */
.node-tooltip {
  position: fixed;
  background: rgba(11, 18, 32, 0.95);
  border: 1px solid var(--accent-gold);
  border-radius: 8px;
  padding: 12px;
  color: white;
  font-size: 0.8rem;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  min-width: 150px;
}

/* --- Shining Repurchase Promo Cards --- */
.shining-promo {
  border: 1px solid rgba(212, 175, 55, 0.2);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.08) 0%, rgba(19, 27, 45, 0.8) 100%);
  border-radius: var(--border-radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.shining-promo.eligible {
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, rgba(19, 27, 45, 0.9) 100%);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.12);
  animation: shine-border 4s infinite alternate;
}

.shining-promo:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(212, 175, 55, 0.15);
}

.shining-promo.eligible:hover {
  box-shadow: 0 8px 30px rgba(34, 197, 94, 0.25);
}

.shining-promo::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 45%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 55%
  );
  transform: rotate(45deg);
  transition: none;
  animation: none;
}

.shining-promo.eligible::before {
  animation: shine-sweep 3s infinite linear;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-green);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse-dot-anim 1.5s infinite;
}

@keyframes shine-border {
  0% { border-color: rgba(34, 197, 94, 0.3); }
  50% { border-color: rgba(212, 175, 55, 0.5); }
  100% { border-color: rgba(0, 163, 255, 0.6); }
}

@keyframes shine-sweep {
  0% { transform: translate(-30%, -30%) rotate(45deg); }
  100% { transform: translate(30%, 30%) rotate(45deg); }
}

@keyframes pulse-dot-anim {
  0% { transform: scale(0.8); opacity: 0.5; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.8); opacity: 0.5; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
