/* ========== 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 {
  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;
}

.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);
}

/* ========== 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);
}

.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;
}

/* ========== 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;
  background-size: cover;
  background-position: center;
  background-color: var(--secondary-bg);
}

.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;
}

.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;
}
