/* =============================================
   Скидон дня — Mini App Styles
   ============================================= */

:root {
  --tg-bg: var(--tg-theme-bg-color, #ffffff);
  --tg-text: var(--tg-theme-text-color, #1a1a2e);
  --tg-hint: var(--tg-theme-hint-color, #999);
  --tg-link: var(--tg-theme-link-color, #2563eb);
  --tg-button: var(--tg-theme-button-color, #2563eb);
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #f5f5f5);

  --ali-color: #FF6600;
  --ozon-color: #005BFF;
  --wb-color: #CB11AB;

  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--tg-bg);
  color: var(--tg-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ===== Header ===== */
.app-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: white;
  padding: 16px 20px 14px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.2);
}

.header-logo {
  font-size: 28px;
  margin-bottom: 2px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.header-subtitle {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

/* ===== Tabs ===== */
.tabs-nav {
  display: flex;
  background: var(--tg-secondary-bg);
  padding: 8px 12px;
  gap: 8px;
  position: sticky;
  top: 82px;
  z-index: 99;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--tg-hint);
  cursor: pointer;
  transition: var(--transition);
  font-size: 11px;
  font-weight: 500;
}

.tab-btn.active {
  background: var(--tg-bg);
  color: var(--tg-text);
  box-shadow: var(--shadow);
}

.tab-btn[data-marketplace="aliexpress"].active { color: var(--ali-color); }
.tab-btn[data-marketplace="ozon"].active { color: var(--ozon-color); }
.tab-btn[data-marketplace="wildberries"].active { color: var(--wb-color); }

.tab-emoji { font-size: 20px; }
.tab-name { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }

/* ===== Content Area ===== */
.content-area {
  flex: 1;
  padding: 12px;
  padding-bottom: 80px;
}

/* ===== Loading ===== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--tg-secondary-bg);
  border-top-color: var(--tg-button);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--tg-hint);
  font-size: 14px;
}

/* ===== Error / Empty States ===== */
.error-container,
.empty-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  gap: 12px;
  text-align: center;
}

.error-emoji, .empty-emoji {
  font-size: 48px;
}

.error-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--tg-text);
}

.empty-text {
  font-size: 16px;
  font-weight: 600;
}

.empty-subtext {
  font-size: 13px;
  color: var(--tg-hint);
}

.retry-btn {
  margin-top: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--tg-button);
  color: var(--tg-button-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.hidden { display: none !important; }

/* ===== Products Grid ===== */
.products-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 340px) {
  .products-grid { grid-template-columns: 1fr; }
}

/* ===== Product Card ===== */
.product-card {
  background: var(--tg-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid rgba(0,0,0,0.04);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.product-card:active {
  transform: scale(0.97);
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.product-image-wrap {
  position: relative;
  width: 100%;
  padding-top: 75%;
  background: var(--tg-secondary-bg);
  overflow: hidden;
}

.product-image {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity 0.3s;
}

.product-image.loading { opacity: 0; }

.no-image {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  opacity: 0.4;
}

.discount-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ff3b30;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  line-height: 1.4;
}

.product-info {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.product-title {
  font-size: 12px;
  line-height: 1.4;
  font-weight: 500;
  color: var(--tg-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-prices {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
}

.price-new {
  font-size: 15px;
  font-weight: 700;
  color: var(--tg-text);
}

.price-old {
  font-size: 11px;
  color: var(--tg-hint);
  text-decoration: line-through;
}

.buy-btn {
  margin-top: auto;
  display: block;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity var(--transition);
  color: white;
}

.buy-btn:active { opacity: 0.8; }

.aliexpress .buy-btn { background: var(--ali-color); }
.ozon .buy-btn { background: var(--ozon-color); }
.wildberries .buy-btn { background: var(--wb-color); }

/* ===== Channel Banner ===== */
.channel-banner {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  z-index: 200;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.15);
}

.channel-banner-text {
  font-size: 13px;
  opacity: 0.9;
}

.channel-btn {
  background: #2563eb;
  color: white;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition);
}

.channel-btn:active { background: #1d4ed8; }

/* ===== Marketplace Colors ===== */
.marketplace-aliexpress .tab-btn.active { border-bottom: 2px solid var(--ali-color); }
.marketplace-ozon .tab-btn.active { border-bottom: 2px solid var(--ozon-color); }
.marketplace-wildberries .tab-btn.active { border-bottom: 2px solid var(--wb-color); }
