/* ========== BASE & TELEGRAM THEME ========== */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1a1a2e);
  --hint: var(--tg-theme-hint-color, #999999);
  --link: var(--tg-theme-link-color, #6c5ce7);
  --btn: var(--tg-theme-button-color, #6c5ce7);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f5f5f7);
  --card-bg: #ffffff;
  --shadow: 0 2px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--secondary-bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 24px;
}

/* ========== HEADER ========== */
.header {
  background: var(--bg);
  padding: 16px 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
}

.cart-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: background 0.2s;
}

.cart-btn:active {
  background: var(--secondary-bg);
}

.cart-count {
  position: absolute;
  top: 4px;
  right: 2px;
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cart-count.bump {
  transform: scale(1.3);
}

.cart-count[data-count="0"] {
  transform: scale(0);
}

/* ========== CATEGORIES ========== */
.categories-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.categories {
  flex: 1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 0 14px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  min-width: 0;
}

.categories.dragging { cursor: grabbing; }

.categories::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  padding: 8px 18px;
  border-radius: 24px;
  border: none;
  background: var(--secondary-bg);
  color: var(--hint);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}

.cat-btn.active {
  background: var(--btn);
  color: var(--btn-text);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.cat-btn:active {
  transform: scale(0.95);
}

/* ========== FILTER TOGGLE BUTTON ========== */
.filter-toggle-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--secondary-bg);
  color: var(--hint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
}

.filter-toggle-btn.active {
  background: var(--btn);
  color: var(--btn-text);
}

.filter-toggle-btn:active {
  transform: scale(0.92);
}

.filter-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #e74c3c;
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 16px;
  text-align: center;
}

/* ========== FILTERS PANEL ========== */
.filters-panel {
  max-height: 0;
  overflow: hidden;
  background: var(--bg);
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.filters-panel.open {
  max-height: 400px;
}

.filters-inner {
  padding: 12px 16px 16px;
}

.filter-group {
  margin-bottom: 14px;
}

.filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 8px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(0,0,0,0.1);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--btn);
  color: var(--btn-text);
  border-color: var(--btn);
}

.filter-chip:active {
  transform: scale(0.94);
}

.filter-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-price-input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.filter-price-input:focus {
  outline: none;
  border-color: var(--btn);
}

.filter-price-input::-webkit-inner-spin-button,
.filter-price-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.filter-price-sep {
  color: var(--hint);
  font-size: 16px;
  flex-shrink: 0;
}

.filter-price-currency {
  color: var(--hint);
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

.filter-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.filter-reset-btn {
  flex: 1;
  padding: 10px;
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  background: var(--bg);
  color: var(--hint);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-reset-btn:active {
  background: var(--secondary-bg);
}

.filter-apply-btn {
  flex: 2;
  padding: 10px;
  border: none;
  border-radius: 12px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-apply-btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

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

.product-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
  animation: fadeInUp 0.4s ease both;
}

.product-card:active {
  transform: scale(0.97);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.product-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
  background: var(--secondary-bg);
}

.product-info {
  padding: 12px;
}

.product-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.product-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.product-old-price {
  font-size: 12px;
  color: var(--hint);
  text-decoration: line-through;
  margin-left: 6px;
}

.product-add-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.product-add-btn:active {
  transform: scale(0.85);
}

/* Load More Button */
.load-more-btn {
  display: inline-block;
  padding: 12px 32px;
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.load-more-btn:active {
  transform: scale(0.96);
  opacity: 0.8;
}

.product-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
}

.product-img-wrap {
  position: relative;
  overflow: hidden;
}

/* ========== FAVORITES ========== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.fav-header-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: background 0.2s;
}
.fav-header-btn:active {
  background: var(--secondary-bg);
}

.fav-count {
  position: absolute;
  top: 4px;
  right: 2px;
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fav-count[data-count="0"] {
  transform: scale(0);
}

.fav-heart {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.85);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--hint);
  transition: transform 0.2s, color 0.2s;
  z-index: 2;
  backdrop-filter: blur(4px);
}
.fav-heart:active {
  transform: scale(0.85);
}
.fav-heart.active {
  color: #e74c3c;
}
.fav-heart.active svg {
  fill: #e74c3c;
}

/* Favorites Drawer */
.fav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.fav-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.fav-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(380px, 90vw);
  background: var(--bg);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.fav-drawer.open {
  transform: translateX(0);
}

.fav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.fav-header h2 {
  font-size: 20px;
  font-weight: 700;
}
.fav-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--hint);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.fav-items {
  flex: 1;
  padding: 8px 0;
}

.fav-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.fav-item:active {
  background: var(--secondary-bg);
}

.fav-item-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--secondary-bg);
  flex-shrink: 0;
}

.fav-item-info {
  flex: 1;
  min-width: 0;
}

.fav-item-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-item-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}
.fav-item-price s {
  color: var(--hint);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}

.fav-item-remove {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--hint);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
  transition: color 0.2s, background 0.2s;
}
.fav-item-remove:active {
  background: var(--secondary-bg);
  color: #e74c3c;
}

.fav-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--hint);
}
.fav-empty.show {
  display: flex;
}

/* Modal Favorite Button */
.modal-fav-btn {
  position: absolute;
  top: 12px;
  right: 52px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  color: var(--hint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 11;
  transition: transform 0.2s, color 0.2s;
  backdrop-filter: blur(4px);
}
.modal-fav-btn:active {
  transform: scale(0.85);
}
.modal-fav-btn.active {
  color: #e74c3c;
}
.modal-fav-btn.active svg {
  fill: #e74c3c;
}
.modal-fav-btn svg {
  fill: none;
}

/* ========== CART DRAWER ========== */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.cart-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.cart-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(380px, 90vw);
  background: var(--bg);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  border-radius: 20px 0 0 20px;
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.cart-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.cart-close {
  background: var(--secondary-bg);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.cart-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  animation: fadeInUp 0.3s ease;
}

.cart-item-img {
  width: 72px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--secondary-bg);
}

.cart-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cart-item-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.cart-item-size {
  font-size: 12px;
  color: var(--hint);
}

.cart-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-item-price {
  font-size: 15px;
  font-weight: 700;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--secondary-bg);
  border-radius: 10px;
  padding: 4px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: var(--bg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.qty-val {
  font-size: 14px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.cart-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(0,0,0,0.06);
  background: var(--bg);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.order-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

.order-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.cart-empty {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--hint);
  font-size: 15px;
}

.cart-empty.show {
  display: flex;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  z-index: 301;
  border-radius: 24px 24px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal.open { transform: translateY(0); }

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-img {
  width: 100%;
  height: 360px;
  overflow: hidden;
  background: var(--secondary-bg);
  position: relative;
}

/* ========== CARD CAROUSEL ========== */
.card-carousel {
  position: relative;
  overflow: hidden;
}

.card-carousel-track {
  display: flex;
  transition: transform 0.3s ease;
  will-change: transform;
}

.card-carousel-track .product-img {
  flex-shrink: 0;
  width: 100%;
}

.card-carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 2;
}

.card-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: background 0.2s, transform 0.2s;
}

.card-dot.active {
  background: #fff;
  transform: scale(1.3);
}

/* ========== MODAL CAROUSEL ========== */
.modal-carousel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.modal-carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.35s ease;
  will-change: transform;
}

.modal-carousel-slide {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: var(--secondary-bg);
}

.modal-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  color: #333;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: opacity 0.2s;
  line-height: 1;
}

.modal-carousel-btn.prev { left: 10px; }
.modal-carousel-btn.next { right: 10px; }
.modal-carousel-btn:active { opacity: 0.7; }

.modal-carousel-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 5;
}

.modal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: background 0.2s, transform 0.2s;
}

.modal-dot.active {
  background: #fff;
  transform: scale(1.25);
}

.modal-body {
  padding: 20px;
}

.modal-body h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-price {
  font-size: 24px;
  font-weight: 700;
  color: var(--btn);
  margin-bottom: 12px;
}

.modal-desc {
  font-size: 14px;
  color: var(--hint);
  line-height: 1.6;
  margin-bottom: 16px;
}

.modal-sizes {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.size-btn {
  min-width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(0,0,0,0.08);
  background: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  color: var(--text);
  padding: 0 12px;
}

.size-btn.active {
  border-color: var(--btn);
  background: var(--btn);
  color: var(--btn-text);
}

.modal-bottom {
  display: flex;
  gap: 12px;
  align-items: center;
}

.qty-picker {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--secondary-bg);
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
}

.qty-btn {
  width: 44px;
  height: 48px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

.qty-btn:active { background: rgba(128,128,128,0.15); }

.qty-value {
  min-width: 28px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font);
}

.modal-add {
  flex: 1;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.2s;
}

.modal-add:active { transform: scale(0.98); }

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  z-index: 500;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== RESPONSIVE ========== */
@media (min-width: 480px) {
  .products {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --card-bg: var(--bg);
  }
}

/* ========== CHECKOUT ========== */
.checkout-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 400;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.checkout-overlay.open {
  transform: translateX(0);
}

.checkout-screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.checkout-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.checkout-back {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}

.checkout-back:active {
  background: var(--secondary-bg);
}

.checkout-header h2 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

.checkout-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0,0,0,0.06);
  color: var(--hint);
  transition: all 0.3s;
}

.step.active {
  background: var(--btn);
  color: var(--btn-text);
}

.step.done {
  background: #00b894;
  color: white;
}

.step-line {
  width: 16px;
  height: 2px;
  background: rgba(0,0,0,0.08);
  border-radius: 1px;
}

.checkout-step {
  animation: fadeInUp 0.3s ease;
}

.checkout-step.hidden {
  display: none;
}

.step-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}

.checkout-field {
  margin-bottom: 16px;
}

.checkout-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 6px;
}

.checkout-field input,
.checkout-field textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  font-size: 16px;
  font-family: var(--font);
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.checkout-field input:focus,
.checkout-field textarea:focus {
  outline: none;
  border-color: var(--btn);
}

.checkout-field textarea {
  resize: none;
}

.checkout-field .field-error {
  color: #e74c3c;
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.checkout-field.error input,
.checkout-field.error textarea {
  border-color: #e74c3c;
}

.checkout-field.error .field-error {
  display: block;
}

/* ========== PHONE INPUT WITH COUNTRY ========== */
.phone-input-wrap {
  display: flex;
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card-bg);
  transition: border-color 0.2s;
}

.phone-input-wrap:focus-within {
  border-color: var(--btn);
}

.checkout-field.error .phone-input-wrap {
  border-color: #e74c3c;
}

.phone-country-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px 0 14px;
  background: var(--secondary-bg);
  border: none;
  border-right: 1.5px solid rgba(0,0,0,0.08);
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font);
  color: var(--text);
  transition: background 0.15s;
}

.phone-country-btn:active {
  background: rgba(0,0,0,0.08);
}

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

.phone-code {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.phone-country-btn svg {
  opacity: 0.4;
  flex-shrink: 0;
}

.phone-input-wrap input[type="tel"] {
  flex: 1;
  border: none;
  padding: 14px 14px;
  font-size: 16px;
  font-family: var(--font);
  background: transparent;
  color: var(--text);
  min-width: 0;
  -webkit-appearance: none;
}

.phone-input-wrap input[type="tel"]:focus {
  outline: none;
}

/* Country Picker Dropdown */
.country-picker {
  display: none;
  background: var(--card-bg);
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 14px;
  margin-top: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  flex-direction: column;
}

.country-picker.open {
  display: flex;
}

.country-search {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 14px;
  font-family: var(--font);
  background: var(--secondary-bg);
  color: var(--text);
  -webkit-appearance: none;
}

.country-search:focus {
  outline: none;
}

.country-search::placeholder {
  color: var(--hint);
}

.country-list {
  overflow-y: auto;
  max-height: 200px;
  -webkit-overflow-scrolling: touch;
}

.country-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.country-item:active,
.country-item.active {
  background: rgba(108, 92, 231, 0.08);
}

.country-item-flag {
  font-size: 20px;
  flex-shrink: 0;
}

.country-item-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.country-item-code {
  font-size: 13px;
  color: var(--hint);
  font-weight: 600;
}

.checkout-next-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  margin-top: 8px;
}

.checkout-next-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.checkout-next-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Delivery options */
.delivery-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.delivery-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
}

.delivery-option.active {
  border-color: var(--btn);
  background: rgba(108, 92, 231, 0.05);
}

.delivery-option input {
  display: none;
}

.delivery-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.delivery-label {
  font-size: 15px;
  font-weight: 600;
}

.delivery-hint {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
}

/* Confirm step */
.confirm-section {
  margin-bottom: 16px;
}

.confirm-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--hint);
  margin-bottom: 8px;
}

.confirm-items {
  background: var(--card-bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.confirm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.confirm-item + .confirm-item {
  border-top: 1px solid rgba(0,0,0,0.04);
}

.confirm-item-img {
  width: 48px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--secondary-bg);
  flex-shrink: 0;
}

.confirm-item-info {
  flex: 1;
  min-width: 0;
}

.confirm-item-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.confirm-item-detail {
  font-size: 12px;
  color: var(--hint);
}

.confirm-item-price {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.confirm-info {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: var(--shadow);
}

.confirm-total {
  display: flex;
  justify-content: space-between;
  font-size: 20px;
  font-weight: 700;
  padding: 16px 0;
  border-top: 2px solid rgba(0,0,0,0.06);
  margin-top: 8px;
}

.confirm-btn {
  background: #00b894;
  font-size: 17px;
  padding: 18px;
}

/* Success */
.success-screen {
  text-align: center;
  padding: 40px 0;
}

.success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #00b894;
  color: white;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.success-screen h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.success-order-id {
  font-size: 15px;
  color: var(--btn);
  font-weight: 600;
  margin-bottom: 12px;
}

.success-text {
  font-size: 14px;
  color: var(--hint);
  line-height: 1.6;
  margin-bottom: 28px;
}

/* ========== ORDER TABLE (product card) ========== */
.modal-code {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 4px;
}

.order-table-wrap {
  margin: 16px 0 8px;
}

.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.order-table thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  text-align: center;
  padding: 8px 4px;
  border-bottom: 1.5px solid var(--tg-theme-hint-color, #ccc);
}

.order-table thead th:first-child {
  text-align: left;
}

.order-table tbody td {
  padding: 8px 4px;
  text-align: center;
  border-bottom: 1px solid rgba(128,128,128,0.15);
  vertical-align: middle;
}

.order-table tbody td.ot-size {
  text-align: left;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
}

.order-table tbody td.ot-price {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
}

.ot-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ot-arrow {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--tg-theme-link-color, #2481cc);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.ot-arrow:active {
  background: rgba(36, 129, 204, 0.12);
}

.ot-value {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

.ot-color-val {
  min-width: 60px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tg-theme-link-color, #2481cc);
}

.order-table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px 4px;
  font-size: 14px;
}

.order-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-summary-label {
  font-size: 12px;
  color: var(--hint);
  font-style: italic;
}

.order-summary-value {
  font-size: 18px;
  font-weight: 700;
}

.order-summary-total {
  color: var(--tg-theme-link-color, #2481cc);
}

/* ========== ORDERS DRAWER ========== */
.orders-header-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  border-radius: 10px;
  transition: background 0.2s;
}
.orders-header-btn:active {
  background: var(--secondary-bg);
}

.orders-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.orders-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.orders-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(420px, 94vw);
  background: var(--bg);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  border-radius: 20px 0 0 20px;
  overflow: hidden;
}
.orders-drawer.open {
  transform: translateX(0);
}

.orders-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.orders-header h2 {
  font-size: 20px;
  font-weight: 700;
}
.orders-close {
  background: var(--secondary-bg);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orders-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
}

.orders-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 60px 20px;
  color: var(--hint);
  font-size: 15px;
  flex: 1;
}
.orders-empty.show {
  display: flex;
}

.order-card {
  background: var(--secondary-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.order-card-id {
  font-weight: 700;
  font-size: 15px;
}
.order-card-date {
  font-size: 12px;
  color: var(--hint);
}

.order-card-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 10px;
}
.order-card-status.new { background: #e3f2fd; color: #1565c0; }
.order-card-status.confirmed { background: #fff3e0; color: #e65100; }
.order-card-status.shipped { background: #e8f5e9; color: #2e7d32; }
.order-card-status.completed { background: #e8f5e9; color: #1b5e20; }
.order-card-status.cancelled { background: #fce4ec; color: #b71c1c; }

.order-card-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.order-card-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.order-card-item-img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(0,0,0,0.04);
}
.order-card-item-info {
  flex: 1;
  min-width: 0;
}
.order-card-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.order-card-item-detail {
  font-size: 11px;
  color: var(--hint);
}

.order-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.order-card-total {
  font-weight: 700;
  font-size: 15px;
}
.order-repeat-btn {
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.order-repeat-btn:active {
  opacity: 0.7;
}
