/* ============================================================
   UNIFIED PRODUCT CARD SYSTEM - CozaStore Theme
   - Tek bir ürün kartı sistemi tüm sayfalarda kullanılacak
   - Mobil ve desktop görünümde tutarlı tasarım
   - Ana sayfa, kategori detay, arama sonuçları için ortak stil
   ============================================================ */

/* CSS Variables - Design System */
:root {
  --primary-color: #2874f0;
  --primary-hover: #1a5fcc;
  --secondary-color: #fb641b;
  --secondary-hover: #e55a17;
  --success-color: #388e3c;
  --warning-color: #ff9f00;
  --danger-color: #ff6161;
  --text-primary: #212121;
  --text-secondary: #878787;
  --text-muted: #b0b0b0;
  --border-color: #e0e0e0;
  --border-light: #f0f0f0;
  --background-primary: #ffffff;
  --background-secondary: #f8f9fa;
  --background-tertiary: #f1f3f4;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 12px 20px rgba(0, 0, 0, 0.15);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Instagram tarzı görsel oranı */
  --product-card-image-ratio: 4 / 3;
}

/* ============================================================
   UNIFIED PRODUCT CARD - Ana Kart Sistemi
   ============================================================ */

.modern-product-card {
  background: var(--background-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  height: auto; /* Esnek yükseklik - sabit yükseklik kaldırıldı */
  min-height: 320px; /* Minimum yükseklik - içerik için */

  box-sizing: border-box; /* Box-sizing eklendi */
}

.modern-product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary-color);
}

/* Product Image Container - Improved for better visibility */
.modern-product-card .product-image-container {
  position: relative !important;
  width: 100% !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  /* Sabit oran yerine daha yüksek max-height kullan - resimler kesilmez */
  max-height: 400px !important;
  min-height: 250px !important;
  background: #ffffff !important;
  padding: 0 !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

.modern-product-card .product-image {
  width: 100% !important;
  height: 100% !important;
  max-height: 400px !important;
  object-fit: contain !important; /* Görselin tamamı görünür, kırpılmaz */
  object-position: center !important;
  transition: var(--transition) !important;
  display: block !important;
}

.modern-product-card:hover .product-image {
  transform: scale(1.02); /* Hafif zoom efekti */
}

/* Product Overlay - Quick Actions */
.product-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
}

.overlay-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  z-index: 11;
  pointer-events: auto;
}

.overlay-actions button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.98);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  opacity: 1;
  pointer-events: auto;
  min-width: 32px;
  min-height: 32px;
}

.overlay-actions button:hover {
  background: var(--primary-color);
  color: var(--background-primary);
  border-color: var(--primary-color);
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.overlay-actions button:active {
  transform: scale(0.95);
}

.overlay-actions button i {
  font-size: 0.9rem;
  line-height: 1;
}

/* Discount Badge */
.discount-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--danger-color);
  color: var(--background-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  z-index: 2;
  box-shadow: var(--shadow-sm);
  width: auto;
  max-width: 50px;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  display: inline-block;
  overflow: hidden;
}

/* Product Info Section - Esnek Yükseklik */
.product-info {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: visible;
  position: relative;
  z-index: 5;
  min-height: 140px; /* Minimum yükseklik - buton için yer */
  box-sizing: border-box;
}

/* Product Name */
.product-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  min-height: auto; /* Sabit yükseklik kaldırıldı */
  display: block; /* -webkit-box yerine block kullanıldı */
  overflow: visible; /* Overflow kaldırıldı */
  text-overflow: initial; /* Text-overflow kaldırıldı */
  padding-right: 0.5rem; /* Sağ tarafa padding eklendi */
  box-sizing: border-box;
}

.product-name a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

.product-name a:hover {
  color: var(--primary-color);
}

/* Vendor Area - Satıcı olmasa da aynı alan korunur */
.modern-product-card .product-vendor {
  min-height: 1.2rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modern-product-card .vendor-link {
  color: #555;
  text-decoration: none;
  font-weight: 500;
}

.modern-product-card .vendor-link:hover {
  text-decoration: underline;
}

/* Product Rating */
.product-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

.stars {
  display: flex;
  gap: 0.2rem;
}

.stars i {
  font-size: 0.9rem;
  color: #f6b01e; /* Gold color explicitly */
}

.star-empty {
  color: #ddd !important; /* Lighter gray for empty */
}

.star-filled {
  color: #f6b01e !important; /* Gold for filled */
}

.review-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

/* Product Price */
.product-price {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}

.current-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

.old-price {
  font-size: 1rem;
  color: var(--text-muted);
  text-decoration: line-through;
  font-weight: 500;
}

.call-for-pricing {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Add to Cart Button */
.add-to-cart-btn {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--background-primary);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.875rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  margin-top: auto; /* Satır içeriği değişse de butonları alta hizala */
  min-height: 48px;
  box-sizing: border-box;
  position: relative;
  z-index: 10;
  overflow: visible;
}

.add-to-cart-btn:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.add-to-cart-btn:active {
  transform: translateY(0);
}

.add-to-cart-btn i {
  font-size: 1rem;
}

/* ============================================================
   RESPONSIVE DESIGN - Mobil ve Desktop Optimizasyonu
   ============================================================ */

/* Desktop View (768px+) */
@media (min-width: 768px) {
  .modern-product-card {
    /* Sabit yükseklik kaldırıldı - esnek yükseklik sistemi */
    min-height: auto;
    height: auto; /* Yükseklik otomatik */
  }

  .product-image-container {
    height: auto;
  }

  .product-info {
    padding: 1.75rem;
    gap: 1rem;
    box-sizing: border-box; /* Box-sizing eklendi */
  }

  .product-name {
    font-size: 1.15rem;
    min-height: auto; /* Sabit yükseklik kaldırıldı */
    display: block; /* -webkit-line-clamp kaldırıldı */
    overflow: visible; /* Overflow kaldırıldı */
    padding-right: 0.5rem; /* Sağ padding eklendi */
  }

  .current-price {
    font-size: 1.3rem;
  }

  .add-to-cart-btn {
    padding: 1rem 1.5rem;
    font-size: 1rem;
    min-height: 52px;
    margin-top: auto;
  }
}

/* Tablet View (576px - 767px) */
@media (max-width: 767px) and (min-width: 576px) {
  .modern-product-card {
    min-height: 400px;
    height: auto; /* Yükseklik otomatik */
  }

  .product-image-container {
    height: auto;
  }

  .product-info {
    padding: 1.25rem;
    gap: 0.75rem;
    box-sizing: border-box; /* Box-sizing eklendi */
  }

  .product-name {
    font-size: 1.05rem;
    min-height: auto; /* Sabit yükseklik kaldırıldı */
    display: block; /* -webkit-line-clamp kaldırıldı */
    overflow: visible; /* Overflow kaldırıldı */
    padding-right: 0.5rem; /* Sağ padding eklendi */
  }

  .current-price {
    font-size: 1.2rem;
  }

  .add-to-cart-btn {
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
    min-height: 46px;
    margin-top: auto;
  }
}

/* Mobile View (max-width: 575px) */
@media (max-width: 575px) {
  .modern-product-card {
    min-height: 380px;
    height: auto; /* Yükseklik otomatik */
  }

  .product-image-container {
    height: auto;
  }

  .product-info {
    padding: 1rem;
    gap: 0.5rem;
    box-sizing: border-box; /* Box-sizing eklendi */
  }

  .product-name {
    font-size: 1rem;
    min-height: 2.4rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    line-height: 1.3;
    padding-right: 0.5rem; /* Sağ padding eklendi */
  }

  .current-price {
    font-size: 1.15rem;
  }

  .old-price {
    font-size: 0.9rem;
  }

  .add-to-cart-btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-height: 44px;
    margin-top: auto;
  }

  .overlay-actions {
    top: 8px;
    right: 8px;
    gap: 0.4rem;
  }

  .overlay-actions button {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
  }

  .overlay-actions button i {
    font-size: 0.8rem;
  }
}

/* ============================================================
   GRID LAYOUT OPTIMIZATIONS
   ============================================================ */

/* Products Grid Container */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
}

/* Responsive Grid */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
  }
}

@media (max-width: 576px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
}

/* ============================================================
   LIST VIEW SUPPORT
   ============================================================ */

.list-view .modern-product-card {
  flex-direction: row;
  min-height: 200px;
  align-items: stretch;
}

.list-view .product-image-container {
  width: 200px;
  height: 200px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.list-view .product-info {
  flex: 1;
  padding: 1.5rem;
  justify-content: space-between;
}

.list-view .product-name {
  -webkit-line-clamp: 3;
  line-clamp: 3;
  min-height: auto;
}

.list-view .add-to-cart-btn {
  width: auto;
  min-width: 150px;
  margin-top: 0;
}

/* List View Mobile */
@media (max-width: 768px) {
  .list-view .modern-product-card {
    flex-direction: column;
    min-height: 350px;
  }

  .list-view .product-image-container {
    width: 100%;
    height: 180px;
  }

  .list-view .product-info {
    padding: 1rem;
  }

  .list-view .add-to-cart-btn {
    width: 100%;
    margin-top: 1rem;
  }
}

/* ============================================================
   LOADING STATES
   ============================================================ */

.modern-product-card.loading {
  opacity: 0.7;
  pointer-events: none;
}

.modern-product-card.loading .add-to-cart-btn {
  background: var(--text-muted);
  cursor: not-allowed;
}

.modern-product-card.loading .add-to-cart-btn::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid var(--background-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 0.5rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ============================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================ */

.modern-product-card:focus-within {
  outline: none;
  outline-offset: 0;
}

.add-to-cart-btn:focus {
  outline: 2px solid var(--background-primary);
  outline-offset: 2px;
}

.product-name a:focus {
  outline: none;
}

/* Screen Reader Support */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   DARK MODE SUPPORT (Future Enhancement)
   ============================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --background-primary: #1a1a1a;
    --background-secondary: #2a2a2a;
    --background-tertiary: #3a3a3a;
    --border-color: #404040;
    --border-light: #303030;
  }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
  .modern-product-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }

  .product-overlay,
  .add-to-cart-btn {
    display: none;
  }

  .product-info {
    padding: 0.5rem;
  }
}
