/**
 * Standard Listing Card Component
 * 
 * Unified styling for item cards across:
 * - listings.html (browse all listings)
 * - viewUserInfo.html (user's public profile listings)
 * - userItemsListed.html (owner's dashboard listings)
 * 
 * This ensures consistent image display, card appearance, and hover effects.
 */

/* Base Card Styles */
.item-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  border: 1px solid #e9ecef;
  overflow: hidden;
  transition: all 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.item-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  border-color: #43D1AF;
}

/* Image Container */
.item-image {
  width: 100%;
  height: 250px;
  background: linear-gradient(135deg, #fdfdfd, #f6faf9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  font-size: 3rem;
  position: relative;
  overflow: hidden;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.item-card:hover .item-image img {
  transform: scale(1.05);
}

/* Placeholder icon when no image */
.item-image i.bi-image {
  font-size: 3rem;
  color: #adb5bd;
  opacity: 0.5;
}

/* Content Container */
.item-content {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

/* Title */
.item-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2BA084;
  margin-bottom: 0.75rem;
  line-height: 1.3;
  
  /* Handle longer titles gracefully (up to 60 chars) */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;  /* Show up to 2 lines */
  line-clamp: 2;          /* Standard property */
  -webkit-box-orient: vertical;
  min-height: 3.1rem;     /* Reserve space for 2 lines (1.2rem * 1.3 line-height * 2 lines) */
  word-wrap: break-word;
  word-break: break-word;
}

.item-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
}

.item-title a:hover {
  color: #43D1AF;
}

/* Card Title (for listings.html which uses Bootstrap's card-title class) */
.card-title {
  /* Handle longer titles gracefully (up to 60 chars) */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;  /* Show up to 2 lines */
  line-clamp: 2;          /* Standard property */
  -webkit-box-orient: vertical;
  min-height: 3.1rem;     /* Reserve space for 2 lines */
  word-wrap: break-word;
  word-break: break-word;
}

/* Metadata Row (Price, Rating, Status) */
.item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e9ecef;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.item-price {
  font-size: 1.1rem;
  font-weight: 600;
  color: #28a745;
}

.item-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: #6c757d;
}

.item-rating i.bi-star-fill {
  color: #ffc107;
}

/* Location */
.item-location {
  color: #6c757d;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
}

.item-location i {
  margin-right: 0.25rem;
}

/* Summary/Description */
.item-summary {
  color: #6c757d;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  flex-grow: 1;
}

/* Status Badge (for userItemsListed) */
.item-status {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.status-active {
  background: #d4edda;
  color: #155724;
}

.status-inactive {
  background: #f8d7da;
  color: #721c24;
}

/* Actions Container */
.item-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
  flex-wrap: wrap;
}

/* Price Badge (for listings page) */
.price-badge {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-weight: 600;
  position: absolute;
  top: 1rem;
  right: 1rem;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
  z-index: 10;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .item-image {
    height: 200px;
  }
  
  .item-title {
    font-size: 1.1rem;
    line-clamp: 2;          /* Still 2 lines on tablets */
    -webkit-line-clamp: 2;
    min-height: 2.9rem;     /* Adjust for smaller font */
  }
  
  .card-title {
    font-size: 1.1rem;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    min-height: 2.9rem;
  }
  
  .item-content {
    padding: 1.25rem;
  }
  
  .item-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 576px) {
  .item-image {
    height: 180px;
  }
  
  .item-title {
    font-size: 1rem;
    line-clamp: 3;          /* Allow 3 lines on very small screens */
    -webkit-line-clamp: 3;
    min-height: 3.9rem;     /* Reserve space for 3 lines */
  }
  
  .card-title {
    font-size: 1rem;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    min-height: 3.9rem;
  }
  
  .item-actions {
    flex-direction: column;
  }
  
  .item-actions .btn {
    width: 100%;
  }
}
