/* ===== Telegram Theme Variables ===== */
:root {
  /* Telegram theme colors - will be overwritten by Telegram */
  --tg-theme-bg-color: #1a1a2e;
  --tg-theme-text-color: #ffffff;
  --tg-theme-hint-color: #8e8e93;
  --tg-theme-link-color: #64b5f6;
  --tg-theme-button-color: #5288c1;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-secondary-bg-color: #16213e;
  
  /* Custom colors */
  --accent: #00d26a;
  --accent-light: #00ff88;
  --danger: #ff4757;
  --warning: #ffa502;
  --purple: #a855f7;
  --pink: #ec4899;
  
  /* Spacing */
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);
  
  /* Radius */
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* ===== Reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--tg-theme-hint-color);
  border-radius: 4px;
}

/* ===== Header ===== */
.tg-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-area-top));
  background: linear-gradient(180deg, var(--tg-theme-bg-color) 0%, transparent 100%);
  backdrop-filter: blur(10px);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
}

.user-status {
  font-size: 11px;
  color: var(--accent);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-crown {
  font-size: 24px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.logo-text {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Tab Navigation ===== */
.tab-nav {
  display: flex;
  justify-content: space-around;
  padding: 8px 12px;
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-lg);
  margin: 0 12px 12px;
  position: sticky;
  top: 64px;
  z-index: 90;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: transparent;
  border: none;
  color: var(--tg-theme-hint-color);
  font-size: 10px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.tab-btn.active {
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color);
}

.tab-icon {
  font-size: 20px;
}

.cart-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 20px);
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s ease;
}

.cart-badge.show {
  opacity: 1;
  transform: scale(1);
}

/* ===== Main Content ===== */
.main-content {
  padding: 0 12px;
  padding-bottom: calc(80px + var(--safe-area-bottom));
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Promo Banner ===== */
.promo-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.promo-emoji {
  font-size: 28px;
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.promo-text {
  display: flex;
  flex-direction: column;
}

.promo-text strong {
  font-size: 14px;
  font-weight: 700;
}

.promo-text small {
  font-size: 11px;
  opacity: 0.9;
}

/* ===== VIP Banner ===== */
.vip-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #ffd700, #ff8c00, #ff6347);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.vip-emoji {
  font-size: 20px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.vip-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.vip-text strong {
  font-size: 13px;
  font-weight: 800;
  color: #1a1a2e;
  text-shadow: 0 1px 2px rgba(255,255,255,0.3);
}

.vip-text small {
  font-size: 10px;
  color: #1a1a2e;
  opacity: 0.85;
}

/* ===== Search ===== */
.search-container {
  position: relative;
  margin-bottom: 16px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
}

.search-input {
  width: 100%;
  padding: 14px 14px 14px 44px;
  background: var(--tg-theme-secondary-bg-color);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--tg-theme-text-color);
  font-size: 15px;
  outline: none;
  transition: box-shadow 0.2s ease;
}

.search-input:focus {
  box-shadow: 0 0 0 2px var(--tg-theme-button-color);
}

.search-input::placeholder {
  color: var(--tg-theme-hint-color);
}

/* ===== Categories ===== */
.categories-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 16px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.categories-scroll::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex-shrink: 0;
  padding: 10px 16px;
  background: var(--tg-theme-secondary-bg-color);
  border: none;
  border-radius: 20px;
  color: var(--tg-theme-text-color);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-chip.active {
  background: linear-gradient(135deg, var(--tg-theme-button-color), var(--purple));
  color: white;
}

/* ===== Products Grid ===== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.product-card {
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.product-card:active {
  transform: scale(0.98);
}

/* Product Media (images/videos) */
.product-media {
  position: relative;
  width: 100%;
  height: 120px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
}

.product-media img,
.product-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-media .media-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  opacity: 0.8;
  pointer-events: none;
}

.product-card:hover .media-overlay {
  opacity: 0;
}

.product-card.has-media .product-header {
  padding: 12px;
}

.product-card.has-media .product-emoji {
  display: none;
}

.product-header {
  padding: 16px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
}

.product-emoji {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.product-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.product-desc {
  font-size: 10px;
  color: var(--tg-theme-hint-color);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-footer {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.product-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.product-price small {
  font-size: 10px;
  color: var(--tg-theme-hint-color);
  font-weight: 400;
}

.add-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--tg-theme-button-color);
  border: none;
  color: white;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-btn:active {
  transform: scale(0.9);
  background: var(--accent);
}

/* ===== Cart ===== */
.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cart-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.clear-cart-btn {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
}

.cart-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-lg);
}

.cart-item-emoji {
  font-size: 32px;
}

.cart-item-info {
  flex: 1;
}

.cart-item-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.cart-item-qty {
  font-size: 12px;
  color: var(--tg-theme-hint-color);
}

.cart-item-price {
  font-weight: 700;
  color: var(--accent);
}

.cart-item-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.cart-summary {
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  color: var(--tg-theme-hint-color);
}

.summary-row.total {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 8px;
  padding-top: 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--tg-theme-text-color);
}

.free-shipping {
  color: var(--accent);
  font-weight: 600;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}

.empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-state small {
  font-size: 13px;
  color: var(--tg-theme-hint-color);
}

/* ===== Support ===== */
.support-container {
  padding-top: 8px;
}

.support-header {
  text-align: center;
  margin-bottom: 24px;
}

.support-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.support-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.support-header p {
  color: var(--tg-theme-hint-color);
}

.support-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.support-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--tg-theme-secondary-bg-color);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--tg-theme-text-color);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.support-btn:active {
  transform: scale(0.98);
  background: var(--tg-theme-button-color);
}

.support-btn .btn-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
}

.support-btn .btn-info {
  flex: 1;
}

.support-btn .btn-title {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.support-btn .btn-desc {
  font-size: 12px;
  color: var(--tg-theme-hint-color);
}

.support-btn .btn-arrow {
  font-size: 18px;
  color: var(--tg-theme-hint-color);
}

.info-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(88, 140, 193, 0.2), rgba(168, 85, 247, 0.2));
  border-radius: var(--radius-lg);
}

.info-icon {
  font-size: 24px;
}

.info-text strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.info-text p {
  font-size: 12px;
  color: var(--tg-theme-hint-color);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
}

.modal.active {
  display: block;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--tg-theme-bg-color);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 85vh;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--tg-theme-hint-color);
  border-radius: 2px;
  margin: 12px auto;
  opacity: 0.5;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--tg-theme-secondary-bg-color);
  border: none;
  color: var(--tg-theme-text-color);
  font-size: 16px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  max-height: calc(85vh - 100px);
  overflow-y: auto;
}

/* Modal Media */
.modal-media {
  width: 100%;
  max-height: 250px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  background: rgba(0,0,0,0.3);
}

.modal-media img,
.modal-media video {
  width: 100%;
  height: 100%;
  max-height: 250px;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

/* Modal Product Detail */
.modal-product-header {
  text-align: center;
  margin-bottom: 20px;
}

.modal-media + .modal-product-header .modal-product-emoji {
  display: none;
}

.modal-product-emoji {
  font-size: 64px;
  display: block;
  margin-bottom: 12px;
}

.modal-product-name {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-product-desc {
  font-size: 14px;
  color: var(--tg-theme-hint-color);
  line-height: 1.5;
}

.modal-prices {
  margin-bottom: 20px;
}

.modal-prices h4 {
  font-size: 14px;
  color: var(--tg-theme-hint-color);
  margin-bottom: 12px;
}

.price-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.price-option.selected {
  border-color: var(--tg-theme-button-color);
  background: rgba(82, 136, 193, 0.2);
}

.price-qty {
  font-weight: 600;
}

.price-value {
  font-weight: 700;
  color: var(--accent);
  font-size: 16px;
}

.modal-add-btn {
  width: 100%;
  padding: 16px;
  background: var(--tg-theme-button-color);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--tg-theme-button-text-color);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-add-btn:active {
  transform: scale(0.98);
  background: var(--accent);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 300;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-icon {
  font-size: 20px;
}

.toast-message {
  font-weight: 500;
  font-size: 14px;
}

/* ===== Telegram Button Spacer ===== */
.tg-button-spacer {
  height: 60px;
}

/* ===== Orders ===== */
.orders-header {
  margin-bottom: 16px;
}

.orders-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.order-card {
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.order-id {
  font-weight: 700;
  font-size: 14px;
}

.order-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.order-status.pending {
  background: rgba(255, 165, 2, 0.2);
  color: var(--warning);
}

.order-status.completed {
  background: rgba(0, 210, 106, 0.2);
  color: var(--accent);
}

.order-items {
  font-size: 13px;
  color: var(--tg-theme-hint-color);
  margin-bottom: 8px;
}

.order-total {
  font-weight: 700;
  color: var(--accent);
}

/* ===== Quantity Selector ===== */
.qty-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin: 16px 0;
}

.qty-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--tg-theme-secondary-bg-color);
  border: none;
  color: var(--tg-theme-text-color);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:active {
  background: var(--tg-theme-button-color);
}

.qty-value {
  font-size: 24px;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}
