/* Mouse Shop — Telegram Mini App Styles */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #999);
  --link: var(--tg-theme-link-color, #2ea5ff);
  --button: var(--tg-theme-button-color, #2ea5ff);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
  --header-bg: var(--tg-theme-header-bg-color, #ffffff);
  --section: #fff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--header-bg);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  text-align: center;
}
.icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  position: relative;
  padding: 4px 8px;
}
.cart-btn .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ff3b30;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Views */
.view { display: none; padding: 16px; }
.view.active { display: block; }

/* Categories */
.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}
.chip.active {
  background: var(--button);
  color: var(--button-text);
}

/* Product grid */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.product-card {
  background: var(--section);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}
.product-card:active { transform: scale(0.97); }
.product-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--secondary-bg);
}
.product-card .info {
  padding: 10px 12px;
}
.product-card .name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.product-card .price {
  font-size: 16px;
  font-weight: 700;
  color: var(--link);
}
.product-card .cat-tag {
  font-size: 11px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Loading & empty */
.loading, .empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--hint);
  font-size: 15px;
}

/* Product detail */
.detail {
  max-width: 500px;
  margin: 0 auto;
}
.detail img {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.detail h2 {
  font-size: 22px;
  margin-bottom: 8px;
}
.detail .price {
  font-size: 28px;
  font-weight: 800;
  color: var(--link);
  margin-bottom: 16px;
}
.detail .desc {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 16px;
}
.detail .stock {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 20px;
}
.detail .qty-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.qty-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--secondary-bg);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}
.qty-val {
  font-size: 18px;
  font-weight: 700;
  min-width: 30px;
  text-align: center;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--button);
  color: var(--button-text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.5; }
.btn-secondary {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--link);
  border-radius: var(--radius);
  background: transparent;
  color: var(--link);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* Cart */
.cart-list {
  margin-bottom: 16px;
}
.cart-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.cart-item img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
}
.cart-item .ci-info {
  flex: 1;
}
.cart-item .ci-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.cart-item .ci-price {
  font-size: 14px;
  color: var(--link);
  font-weight: 700;
}
.cart-item .ci-qty {
  font-size: 13px;
  color: var(--hint);
}
.cart-item .ci-remove {
  background: none;
  border: none;
  font-size: 20px;
  color: #ff3b30;
  cursor: pointer;
  padding: 0 4px;
}
.cart-footer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 16px 0;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.cart-total {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}
.checkout-form {
  margin-bottom: 16px;
}
.input {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 8px;
  background: var(--bg);
  color: var(--text);
}
.input:focus {
  outline: none;
  border-color: var(--link);
}

/* Confirmation */
.confirm {
  text-align: center;
  padding: 60px 20px;
}
.confirm-icon {
  font-size: 64px;
  margin-bottom: 16px;
}
.confirm h2 {
  font-size: 24px;
  margin-bottom: 8px;
}
.confirm p {
  font-size: 15px;
  color: var(--hint);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Dark theme adjustments */
@media (prefers-color-scheme: dark) {
  :root {
    --section: #1c1c1d;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
}