:root {
  --bg-primary: #0F0F0F;
  --bg-secondary: #1A1A2E;
  --bg-card: #16213E;
  --bg-card-hover: #1A2744;
  --bg-input: #0F3460;
  --accent: #6C5CE7;
  --accent-hover: #5A4BD1;
  --accent-light: rgba(108,92,231,0.15);
  --accent-glow: rgba(108,92,231,0.3);
  --text-primary: #FFFFFF;
  --text-secondary: #A0A0B8;
  --text-muted: #6B6B80;
  --success: #00B894;
  --warning: #FDCB6E;
  --danger: #E17055;
  --border: rgba(255,255,255,0.06);
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-height: 68px;
  --topbar-height: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-top: var(--topbar-height);
  padding-bottom: var(--nav-height);
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }

/* ===== TOP BAR ===== */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: rgba(15,15,15,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.top-bar-left { display: flex; align-items: center; gap: 10px; }
.store-logo {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  border-radius: 10px; font-size: 18px;
}
.store-info h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.store-tagline { font-size: 11px; color: var(--text-secondary); }

.top-bar-right { display: flex; align-items: center; gap: 6px; }

.tg-user-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  flex-shrink: 0; margin-left: 4px;
}
.tg-user-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: none;
}
.tg-user-avatar img[src] { display: block; }
.tg-user-avatar img[src] + span { display: none; }
#tgUserInitial {
  font-size: 14px; font-weight: 700; color: #fff;
}

.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  border: none; background: transparent;
  color: var(--text-primary); font-size: 18px;
  border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }

.lang-btn { font-size: 20px; }
.lang-flag { font-size: 20px; line-height: 1; }

.badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--accent);
  color: white; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.badge:empty, .badge[data-count="0"] { display: none; }

/* ===== LANGUAGE DROPDOWN ===== */
.lang-dropdown {
  position: fixed; top: 54px; right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 200;
  display: none;
  min-width: 160px;
  overflow: hidden;
}
.lang-dropdown.show { display: block; }
.lang-option {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 14px;
  transition: background 0.15s;
}
.lang-option:hover { background: rgba(255,255,255,0.06); }
.lang-option.active { background: var(--accent-light); color: var(--accent); }

/* ===== SEARCH ===== */
.search-container { padding: 12px 16px 4px; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 0 14px;
  transition: border-color 0.2s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box i { color: var(--text-muted); font-size: 14px; }
.search-box input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 14px;
  padding: 12px 0; font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ===== CATEGORIES ===== */
.categories-scroll {
  display: flex; gap: 8px;
  overflow-x: auto; padding: 12px 16px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.categories-scroll::-webkit-scrollbar { display: none; }

.cat-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.cat-chip:hover { background: var(--bg-card); }
.cat-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 4px;
}
.section-header h2 { font-size: 18px; font-weight: 700; }
.product-count { font-size: 13px; color: var(--text-muted); }

/* ===== PRODUCTS GRID ===== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 8px 16px 16px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(108,92,231,0.15);
  border-color: rgba(108,92,231,0.3);
}
.product-card:active { transform: scale(0.98); }

.product-image {
  width: 100%; aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-secondary);
}

.product-wishlist {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  border: none; border-radius: 50%;
  color: var(--text-secondary);
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  z-index: 2;
}
.product-wishlist.active { color: #E84393; }
.product-wishlist:hover { background: rgba(0,0,0,0.7); }

.product-body { padding: 10px 12px 12px; }
.product-category {
  font-size: 10px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 600; margin-bottom: 4px;
}
.product-title {
  font-size: 13px; font-weight: 600;
  line-height: 1.3; margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-price {
  font-size: 16px; font-weight: 800;
  color: var(--accent);
}
.product-price-old {
  font-size: 12px; color: var(--text-muted);
  text-decoration: line-through; margin-left: 6px;
}

.product-add-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.product-add-btn:hover { background: var(--accent-hover); }
.product-add-btn.added {
  background: var(--success);
}

/* ===== PRODUCT DETAIL ===== */
.product-detail-container {
  padding-bottom: 20px;
}
.product-detail-image {
  width: 100%; aspect-ratio: 1;
  object-fit: cover; border-radius: 0 0 var(--radius) var(--radius);
}
.product-detail-body { padding: 16px; }
.product-detail-category {
  font-size: 12px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.8px;
  font-weight: 600; margin-bottom: 6px;
}
.product-detail-title {
  font-size: 22px; font-weight: 800;
  line-height: 1.25; margin-bottom: 8px;
}
.product-detail-price {
  font-size: 28px; font-weight: 800;
  color: var(--accent); margin-bottom: 16px;
}
.product-detail-desc {
  font-size: 14px; line-height: 1.7;
  color: var(--text-secondary); margin-bottom: 20px;
}

.product-detail-meta {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}
.meta-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-secondary);
}
.meta-item i {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 8px; font-size: 12px;
}

.detail-actions {
  display: flex; gap: 10px;
}
.detail-add-btn {
  flex: 1;
  padding: 14px;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.detail-add-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.detail-add-btn.added { background: var(--success); }

.detail-wish-btn {
  width: 50px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 18px; cursor: pointer;
  transition: all 0.2s;
}
.detail-wish-btn.active {
  color: #E84393;
  border-color: #E84393;
  background: rgba(232,67,147,0.1);
}

/* ===== CART ===== */
.cart-item {
  display: flex; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.cart-item-image {
  width: 64px; height: 64px;
  border-radius: 10px; object-fit: cover;
  background: var(--bg-secondary);
}
.cart-item-info { flex: 1; }
.cart-item-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.cart-item-price { font-size: 15px; font-weight: 700; color: var(--accent); }
.cart-item-qty {
  display: flex; align-items: center; gap: 10px;
  margin-top: 6px;
}
.qty-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 8px; font-size: 14px;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  font-weight: 600;
}
.qty-btn:hover { background: var(--accent); border-color: var(--accent); }
.qty-value { font-size: 14px; font-weight: 600; min-width: 20px; text-align: center; }
.cart-item-remove {
  background: none; border: none;
  color: var(--danger); font-size: 16px;
  cursor: pointer; padding: 8px;
}

/* ===== PROMO ===== */
.promo-section { padding: 16px; }
.promo-input-group {
  display: flex; gap: 8px;
}
.promo-input-group input {
  flex: 1; padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px; font-family: inherit;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.promo-input-group input:focus { border-color: var(--accent); }
.promo-apply-btn {
  padding: 12px 18px;
  background: var(--accent);
  color: white; border: none;
  border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer;
  font-family: inherit; font-size: 13px;
  transition: background 0.2s;
}
.promo-apply-btn:hover { background: var(--accent-hover); }
.promo-result {
  margin-top: 8px; font-size: 13px;
  padding: 0 4px;
}
.promo-result.success { color: var(--success); }
.promo-result.error { color: var(--danger); }

/* ===== CART SUMMARY ===== */
.cart-summary {
  padding: 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.summary-row {
  display: flex; justify-content: space-between;
  padding: 8px 0; font-size: 14px;
  color: var(--text-secondary);
}
.total-row {
  font-size: 18px; font-weight: 800;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  padding-top: 12px; margin-top: 4px;
}
.discount-amount { color: var(--success); }

.checkout-btn {
  width: 100%; padding: 15px;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  color: white; border: none;
  border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700;
  cursor: pointer; margin-top: 16px;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.2s;
}
.checkout-btn:hover { opacity: 0.92; transform: translateY(-1px); }

/* ===== CHECKOUT ===== */
.checkout-section {
  padding: 16px;
  margin-bottom: 12px;
}
.checkout-section h3 {
  font-size: 16px; font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}
.checkout-total {
  display: flex; justify-content: space-between;
  font-size: 18px; font-weight: 800;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  color: var(--accent);
}

.checkout-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  font-size: 14px;
}
.checkout-item-title { flex: 1; }
.checkout-item-price { font-weight: 600; color: var(--accent); }
.checkout-item-qty { color: var(--text-muted); font-size: 12px; }

/* Payment methods */
.payment-methods {
  display: flex; flex-direction: column; gap: 10px;
}
.payment-method {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.payment-method:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}
.payment-method.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}
.payment-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 20px;
}
.crypto-icon { background: linear-gradient(135deg,#F7931A,#E2761B); color: white; }
.ton-icon { background: linear-gradient(135deg,#0098EA,#00D4FF); color: white; }
.stripe-icon { background: linear-gradient(135deg,#635BFF,#7A73FF); color: white; }
.tg-icon { background: linear-gradient(135deg,#229ED9,#2AABEE); color: white; }
.payment-info { flex: 1; }
.payment-info strong { display: block; font-size: 14px; margin-bottom: 2px; }
.payment-info span { font-size: 12px; color: var(--text-secondary); }
.payment-method > .fa-chevron-right { color: var(--text-muted); font-size: 12px; }

/* Payment Modal */
.payment-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 24px;
}
.payment-modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  max-width: 360px; width: 100%;
  border: 1px solid var(--border);
}
.payment-processing h3 { margin-top: 20px; font-size: 18px; }
.payment-processing p { color: var(--text-secondary); margin-top: 8px; font-size: 14px; }

.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.success-icon { font-size: 56px; color: var(--success); margin-bottom: 8px; }
.payment-success h3 { font-size: 20px; margin-bottom: 8px; }
.payment-success p { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }

.delivery-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 20px;
}
.delivery-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: 13px; color: var(--text-secondary);
}
.delivery-item i { color: var(--accent); width: 20px; text-align: center; }

/* ===== ORDERS ===== */
.order-card {
  margin: 8px 16px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.order-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 10px;
}
.order-id { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.order-status {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.order-status.pending { background: rgba(253,203,110,0.15); color: var(--warning); }
.order-status.paid { background: rgba(0,184,148,0.15); color: var(--success); }
.order-status.delivered { background: rgba(108,92,231,0.15); color: var(--accent); }
.order-status.failed { background: rgba(225,112,85,0.15); color: var(--danger); }

.order-items-list { margin-bottom: 10px; }
.order-item-row {
  display: flex; justify-content: space-between; flex-wrap: wrap;
  font-size: 13px; padding: 4px 0;
  color: var(--text-secondary);
}
.order-item-downloads {
  width: 100%; display: flex; gap: 8px; margin-top: 4px;
}
.download-btn {
  font-size: 11px; padding: 3px 10px; border-radius: 6px;
  background: var(--accent); color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  transition: opacity 0.2s;
}
.download-btn:hover { opacity: 0.8; }
.send-chat-btn { background: #27a7e7; }
.order-item-downloads { flex-wrap: wrap; }
.order-total {
  display: flex; justify-content: space-between;
  font-weight: 700; font-size: 15px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.order-date {
  font-size: 11px; color: var(--text-muted);
  margin-top: 6px;
}
.order-payment-method {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-muted);
  margin-top: 4px;
}

/* ===== VIEWS ===== */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.view-title {
  padding: 8px 16px 4px;
  font-size: 20px; font-weight: 800;
}
.view-title i { color: var(--accent); margin-right: 6px; }

.back-btn {
  background: none; border: none;
  color: var(--accent); font-size: 14px;
  padding: 12px 16px;
  cursor: pointer; font-family: inherit; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.back-btn:hover { opacity: 0.8; }

.empty-state {
  text-align: center; padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state p { font-size: 15px; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(15,15,15,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 10px; font-weight: 600;
  cursor: pointer;
  transition: color 0.2s;
  font-family: inherit;
}
.nav-item i { font-size: 20px; }
.nav-item.active { color: var(--accent); }
.nav-item:hover { color: var(--text-secondary); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 32px rgba(108,92,231,0.3);
  z-index: 300;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== RESPONSIVE ===== */
@media (min-width: 480px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  body { max-width: 480px; margin: 0 auto; box-shadow: -1px 0 0 var(--border), 1px 0 0 var(--border); }
  .top-bar, .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .lang-dropdown { right: calc(50% - 224px); }
  .toast { bottom: calc(var(--nav-height) + 24px); }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
}
