/* ================================================================
   RESPONSIVE SYSTEM — TilbeHome Pro v2
   ================================================================
   Breakpoints (Bootstrap 5 + e-commerce standard):
   XSmall:  < 576px       Küçük telefon (iPhone SE, eski Android)
   Small:   >= 576px      Büyük telefon (iPhone 14/15, Galaxy)
   Medium:  >= 768px      Tablet (iPad Mini, iPad, Galaxy Tab)
   Large:   >= 992px      Küçük laptop (13" MacBook)
   XLarge:  >= 1200px     Laptop (15", standart masaüstü)
   XXLarge: >= 1400px     Büyük masaüstü (24"+)
   ================================================================ */

/* ══════════════════════════════════════════════
   BÖLÜM 3: CONTAINER SİSTEMİ
   ══════════════════════════════════════════════ */

/* ── Ana Container ── */
.th2-container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--th-container-padding);
  padding-right: var(--th-container-padding);
}

@media (min-width: 576px) {
  .th2-container { max-width: 540px; }
}
@media (min-width: 768px) {
  .th2-container { max-width: 720px; padding-left: var(--th-space-6); padding-right: var(--th-space-6); }
}
@media (min-width: 992px) {
  .th2-container { max-width: 960px; }
}
@media (min-width: 1200px) {
  .th2-container { max-width: 1140px; padding-left: var(--th-space-8); padding-right: var(--th-space-8); }
}
@media (min-width: 1400px) {
  .th2-container { max-width: 1320px; }
}

/* ── Tam Genişlik Container ── */
.th2-container-fluid {
  width: 100%;
  padding-left: var(--th-container-padding);
  padding-right: var(--th-container-padding);
}

/* ── Dar Container (checkout, auth formları) ── */
.th2-container-narrow {
  width: 100%;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--th-container-padding);
  padding-right: var(--th-container-padding);
}

/* ── Geniş Container (anasayfa hero, banner) ── */
.th2-container-wide {
  width: 100%;
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--th-container-padding);
  padding-right: var(--th-container-padding);
}

/* ══════════════════════════════════════════════
   BÖLÜM 4: GRID SİSTEMİ
   ══════════════════════════════════════════════ */

/* ── Temel Grid ── */
.th2-grid {
  display: grid;
  gap: var(--th-space-4);
}

/* ── Sütun Varyantları ── */
.th2-grid--1 { grid-template-columns: 1fr; }
.th2-grid--2 { grid-template-columns: repeat(2, 1fr); }
.th2-grid--3 { grid-template-columns: repeat(3, 1fr); }
.th2-grid--4 { grid-template-columns: repeat(4, 1fr); }
.th2-grid--5 { grid-template-columns: repeat(5, 1fr); }
.th2-grid--6 { grid-template-columns: repeat(6, 1fr); }

/* ── Ürün Grid (kategori sayfası) ── */
.th2-grid--products {
  grid-template-columns: repeat(2, 1fr);
  gap: var(--th-space-3);
}

@media (min-width: 576px) {
  .th2-grid--products { grid-template-columns: repeat(2, 1fr); gap: var(--th-space-4); }
}
@media (min-width: 768px) {
  .th2-grid--products { grid-template-columns: repeat(3, 1fr); }
  .th2-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .th2-grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
  .th2-grid--products { grid-template-columns: repeat(4, 1fr); }
  .th2-grid--4 { grid-template-columns: repeat(4, 1fr); }
  .th2-grid--5 { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1200px) {
  .th2-grid--products { grid-template-columns: repeat(5, 1fr); }
  .th2-grid--6 { grid-template-columns: repeat(6, 1fr); }
}

/* ── PDP Layout Grid ── */
.th2-grid--pdp {
  grid-template-columns: 1fr;
  gap: var(--th-space-4);
}
@media (min-width: 992px) {
  .th2-grid--pdp { grid-template-columns: 1fr 1fr; gap: var(--th-space-8); }
}
@media (min-width: 1200px) {
  .th2-grid--pdp { grid-template-columns: 55% 45%; }
}

/* ── Sidebar Layout Grid ── */
.th2-grid--sidebar {
  grid-template-columns: 1fr;
  gap: var(--th-space-4);
}
@media (min-width: 992px) {
  .th2-grid--sidebar { grid-template-columns: 260px 1fr; gap: var(--th-space-6); }
}

/* ── Flex Utilities ── */
.th2-flex { display: flex; }
.th2-flex-col { flex-direction: column; }
.th2-flex-row { flex-direction: row; }
.th2-flex-wrap { flex-wrap: wrap; }
.th2-flex-center { align-items: center; justify-content: center; }
.th2-flex-between { justify-content: space-between; }
.th2-flex-start { align-items: flex-start; }
.th2-flex-end { justify-content: flex-end; }
.th2-flex-1 { flex: 1; }
.th2-flex-shrink-0 { flex-shrink: 0; }

/* ── Gap Utilities ── */
.th2-gap-1 { gap: var(--th-space-1); }
.th2-gap-2 { gap: var(--th-space-2); }
.th2-gap-3 { gap: var(--th-space-3); }
.th2-gap-4 { gap: var(--th-space-4); }
.th2-gap-5 { gap: var(--th-space-5); }
.th2-gap-6 { gap: var(--th-space-6); }
.th2-gap-8 { gap: var(--th-space-8); }

/* ══════════════════════════════════════════════
   BÖLÜM 5: RESPONSIVE VISIBILITY
   ══════════════════════════════════════════════ */

/* ── XSmall: Küçük telefonda gizle/göster ── */
@media (max-width: 575px) {
  .th2-hide-xs { display: none !important; }
}
.th2-show-xs { display: none !important; }
@media (max-width: 575px) {
  .th2-show-xs { display: block !important; }
}

/* ── Mobile: Telefonda gizle/göster (< 768px) ── */
@media (max-width: 767px) {
  .th2-hide-mobile { display: none !important; }
}
.th2-show-mobile { display: none !important; }
@media (max-width: 767px) {
  .th2-show-mobile { display: block !important; }
}

/* ── Tablet: Sadece tablette gizle (768-991px) ── */
@media (min-width: 768px) and (max-width: 991px) {
  .th2-hide-tablet { display: none !important; }
}

/* ── Desktop: Masaüstünde gizle/göster (>= 992px) ── */
@media (min-width: 992px) {
  .th2-hide-desktop { display: none !important; }
}
.th2-show-desktop { display: none !important; }
@media (min-width: 992px) {
  .th2-show-desktop { display: block !important; }
}

/* ── Inline/Flex varyantları ── */
.th2-show-mobile-inline { display: none !important; }
@media (max-width: 767px) {
  .th2-show-mobile-inline { display: inline !important; }
}
.th2-show-mobile-flex { display: none !important; }
@media (max-width: 767px) {
  .th2-show-mobile-flex { display: flex !important; }
}
.th2-show-desktop-flex { display: none !important; }
@media (min-width: 992px) {
  .th2-show-desktop-flex { display: flex !important; }
}

/* ══════════════════════════════════════════════
   BÖLÜM 8: TOUCH TARGET
   ══════════════════════════════════════════════ */

/* Touch target minimum (WCAG 2.5.5 + Apple HIG) */
button,
[type="button"],
[type="submit"],
[type="reset"],
a.th2-btn,
.th2-card__fav,
.th2-card__overlay-btn {
  min-height: 44px;
  min-width: 44px;
}

/* Küçük butonlar için görünmez touch padding */
.th2-touch-target {
  position: relative;
}
.th2-touch-target::after {
  content: '';
  position: absolute;
  top: -8px;
  right: -8px;
  bottom: -8px;
  left: -8px;
}

/* ══════════════════════════════════════════════
   BÖLÜM 9: MOBİL SPACING
   ══════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Section arası boşluk */
  .th2-section { margin-bottom: var(--th-space-6); }

  /* Kart içi padding */
  .th2-card__body { padding: var(--th-space-2); }

  /* Grid gap */
  .th2-grid { gap: var(--th-space-2); }
  .th2-grid--products { gap: var(--th-space-2); }

  /* iOS zoom önleme (< 16px input'ta Safari otomatik zoom yapar) */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  /* Tablo yatay scroll */
  .th2-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ══════════════════════════════════════════════
   BÖLÜM 10: GÖRSEL ORAN (ASPECT RATIO)
   ══════════════════════════════════════════════ */

/* Ürün kartı görseli */
.th2-card__image {
  aspect-ratio: var(--th-aspect-square);
  overflow: hidden;
}
.th2-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Banner oranları */
.th2-banner { aspect-ratio: var(--th-aspect-banner); }
.th2-banner--hero { aspect-ratio: var(--th-aspect-hero); }
.th2-banner--wide { aspect-ratio: var(--th-aspect-wide); }

/* Mobilde banner oranı değişir */
@media (max-width: 767px) {
  .th2-banner { aspect-ratio: var(--th-aspect-landscape); }
  .th2-banner--hero { aspect-ratio: var(--th-aspect-landscape); }
}

/* ══════════════════════════════════════════════
   BÖLÜM 11: RESPONSIVE IMAGE UTILITIES
   ══════════════════════════════════════════════ */

/* Responsive görsel */
.th2-img-responsive {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Görsel fill (kart için) */
.th2-img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Görsel contain (logo, ikon için) */
.th2-img-contain {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Lazy load placeholder */
.th2-img-placeholder {
  background: var(--th-color-bg-skeleton);
  animation: th2-skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes th2-skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Skeleton shimmer */
.th2-skeleton {
  background: linear-gradient(
    90deg,
    var(--th-color-bg-skeleton) 25%,
    var(--th-color-bg-skeleton-shine) 50%,
    var(--th-color-bg-skeleton) 75%
  );
  background-size: 200% 100%;
  animation: th2-skeleton-shimmer 1.5s infinite;
  border-radius: var(--th-radius-md);
}

@keyframes th2-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════
   BÖLÜM 12: MOBİL NAVIGATION (BOTTOM BAR)
   ══════════════════════════════════════════════ */

/* Sticky Bottom Bar (mobil CTA) */
.th2-mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--th-z-sticky);
  background: var(--th-color-bg);
  border-top: 1px solid var(--th-color-border-light);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  padding: var(--th-space-2) var(--th-space-4);
  display: none;
}

@media (max-width: 767px) {
  .th2-mobile-bottom-bar {
    display: flex;
    align-items: center;
    gap: var(--th-space-3);
  }

  /* Bottom bar varsa sayfa altına padding ekle */
  body.has-bottom-bar { padding-bottom: 72px; }
}

/* PDP mobil sticky CTA */
.th2-pdp-sticky-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--th-z-sticky);
  background: var(--th-color-bg);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  padding: var(--th-space-3) var(--th-space-4);
  display: none;
}

@media (max-width: 767px) {
  .th2-pdp-sticky-cta {
    display: flex;
    align-items: center;
    gap: var(--th-space-3);
  }
}

/* ══════════════════════════════════════════════
   BÖLÜM 13: SAFE AREA (NOTCH/ISLAND DESTEĞİ)
   ══════════════════════════════════════════════ */

@supports (padding: env(safe-area-inset-top)) {
  .tilbehead19-header {
    padding-top: env(safe-area-inset-top);
  }

  .th2-mobile-bottom-bar,
  .th2-pdp-sticky-cta {
    padding-bottom: calc(var(--th-space-2) + env(safe-area-inset-bottom));
  }
}

/* ══════════════════════════════════════════════
   BÖLÜM 14: PRINT STYLES
   ══════════════════════════════════════════════ */

@media print {
  /* Header/footer/overlay gizle */
  .tilbehead19-header,
  .tf2-footer,
  .th2-mobile-bottom-bar,
  .th2-pdp-sticky-cta,
  .overlay { display: none !important; }

  /* Arka plan renklerini kapat */
  body {
    background: #fff !important;
    color: #000 !important;
  }

  /* Linkleri göster */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Sayfa kırılması */
  .th2-card { break-inside: avoid; }
}

/* ══════════════════════════════════════════════
   BÖLÜM 15: KULLANICI TERCİHLERİ (PREFERS)
   ══════════════════════════════════════════════ */

/* Karanlık tema tercihi (gelecek için hazırlık) */
@media (prefers-color-scheme: dark) {
  /* Dark mode token override'ları buraya gelecek */
}

/* Hareket azaltma (epilepsi, vestibular disorder) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Yüksek kontrast tercihi */
@media (prefers-contrast: high) {
  :root {
    --th-color-text: #000000;
    --th-color-bg: #ffffff;
    --th-color-border: #000000;
  }
}

/* Düşük veri kullanımı tercihi */
@media (prefers-reduced-data: reduce) {
  img[loading="lazy"] { content-visibility: auto; }
  .th2-banner video { display: none; }
}
