/* ==========================================================================
   Modern Ad Card Component
   A clean, professional card design for classified ads
   ========================================================================== */

/* CSS Custom Properties for easy theming */
:root {
    --ad-card-radius: 12px;
    --ad-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --ad-card-shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.12);
    --ad-card-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --ad-card-image-height: 200px;
    --ad-card-bg: #ffffff;
    --ad-card-border: #f0f0f0;
    --ad-card-text: #1a1a2e;
    --ad-card-text-muted: #6b7280;
    --ad-card-primary: #5e72e4;
    --ad-card-success: #10b981;
    --ad-card-warning: #f59e0b;
    --ad-card-danger: #ef4444;
}

/* Base Card Styles */
.ad-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--ad-card-bg);
    border-radius: var(--ad-card-radius);
    box-shadow: var(--ad-card-shadow);
    overflow: hidden;
    transition: var(--ad-card-transition);
    height: 100%;
}

.ad-card:hover {
    box-shadow: var(--ad-card-shadow-hover);
    transform: translateY(-4px);
}

/* Promoted Card Accent */
.ad-card--promoted {
    border: 2px solid transparent;
    background:
        linear-gradient(var(--ad-card-bg), var(--ad-card-bg)) padding-box,
        linear-gradient(135deg, #667eea 0%, #764ba2 100%) border-box;
}

/* Image Wrapper */
.ad-card__image-wrapper {
    position: relative;
    width: 100%;
    height: var(--ad-card-image-height);
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
}

.ad-card__image-link {
    display: block;
    width: 100%;
    height: 100%;
}

.ad-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.ad-card:hover .ad-card__image {
    transform: scale(1.05);
}

/* No Image Placeholder */
.ad-card__no-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #9ca3af;
    gap: 8px;
}

.ad-card__no-image i {
    font-size: 32px;
    opacity: 0.5;
}

.ad-card__no-image span {
    font-size: 12px;
    font-weight: 500;
}

/* Badges */
.ad-card__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    color: white;
    z-index: 2;
}

.ad-card__badge--top {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.ad-card__badge--premium {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

/* Wishlist Button */
.ad-card__wishlist {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--ad-card-transition);
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ad-card__wishlist:hover {
    transform: scale(1.1);
    background: white;
}

.ad-card__heart {
    width: 18px;
    height: 18px;
    color: #9ca3af;
    transition: var(--ad-card-transition);
}

.ad-card__wishlist.is-active .ad-card__heart,
.ad-card__wishlist:hover .ad-card__heart {
    color: #ef4444;
    fill: #ef4444;
}

/* Price Badge */
.ad-card__price {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    padding: 8px 14px;
    background: rgba(30, 41, 59, 0.92);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    z-index: 2;
}

.ad-card__price-main {
    font-size: 16px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}

.ad-card__price-secondary {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
}

.ad-card__price--free {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.ad-card__price--free span {
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.ad-card__price--negotiable {
    background: linear-gradient(135deg, var(--ad-card-primary) 0%, #4f46e5 100%);
}

.ad-card__price--negotiable span {
    font-size: 12px;
    font-weight: 600;
    color: white;
}

/* Photo Count */
.ad-card__photo-count {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: white;
    z-index: 2;
}

/* Content Area */
.ad-card__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

/* Meta Info (Location & Date) */
.ad-card__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--ad-card-text-muted);
}

.ad-card__location {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ad-card__location svg {
    flex-shrink: 0;
    color: var(--ad-card-primary);
}

.ad-card__date {
    margin-left: auto;
    white-space: nowrap;
}

/* Title */
.ad-card__title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ad-card-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ad-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.ad-card__title a:hover {
    color: var(--ad-card-primary);
}

/* Category Tag */
.ad-card__category {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 10px;
    margin-top: auto;
    font-size: 11px;
    font-weight: 500;
    color: var(--ad-card-primary);
    background: rgba(94, 114, 228, 0.1);
    border-radius: 20px;
}

/* Footer */
.ad-card__footer {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--ad-card-border);
    background: #fafbfc;
}

/* Seller Info */
.ad-card__seller {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--ad-card-text);
    transition: color 0.2s ease;
}

.ad-card__seller:hover {
    color: var(--ad-card-primary);
}

.ad-card__seller-avatar {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: var(--ad-card-primary);
}

.ad-card__seller--business .ad-card__seller-avatar {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #059669;
}

.ad-card__seller-name {
    font-size: 13px;
    font-weight: 500;
}

.ad-card__verified {
    flex-shrink: 0;
}

/* ==========================================================================
   Carousel/Grid Integration
   ========================================================================== */

/* For Owl Carousel */
.owl-carousel .ad-card {
    margin: 4px;
    height: calc(100% - 8px);
}

/* Home carousel specific adjustments */
.home-carousel-items .ad-card {
    --ad-card-image-height: 180px;
}

/* Featured ads section */
.home-carousel-items .item.feature-ad .ad-card {
    --ad-card-image-height: 200px;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .ad-card {
        --ad-card-image-height: 160px;
        --ad-card-radius: 10px;
    }

    .ad-card__content {
        padding: 12px;
    }

    .ad-card__title {
        font-size: 14px;
    }

    .ad-card__price {
        padding: 6px 10px;
    }

    .ad-card__price-main {
        font-size: 14px;
    }

    .ad-card__footer {
        padding: 10px 12px;
    }
}

@media (max-width: 576px) {
    .ad-card {
        --ad-card-image-height: 140px;
    }

    .ad-card__wishlist {
        width: 32px;
        height: 32px;
    }

    .ad-card__heart {
        width: 16px;
        height: 16px;
    }

    .ad-card__meta {
        font-size: 11px;
    }

    .ad-card__category {
        font-size: 10px;
    }
}

/* ==========================================================================
   Compact Variant (for sidebar or smaller spaces)
   ========================================================================== */

.ad-card--compact {
    --ad-card-image-height: 120px;
}

.ad-card--compact .ad-card__content {
    padding: 10px;
}

.ad-card--compact .ad-card__title {
    font-size: 13px;
    -webkit-line-clamp: 1;
}

.ad-card--compact .ad-card__meta {
    font-size: 11px;
    margin-bottom: 4px;
}

.ad-card--compact .ad-card__category {
    display: none;
}

.ad-card--compact .ad-card__footer {
    display: none;
}

/* ==========================================================================
   Featured Variant (larger, more prominent)
   ========================================================================== */

.ad-card--featured {
    --ad-card-image-height: 220px;
}

.ad-card--featured .ad-card__title {
    font-size: 17px;
}

.ad-card--featured .ad-card__price-main {
    font-size: 18px;
}

/* ==========================================================================
   Animation for new cards
   ========================================================================== */

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ad-card.animate-in {
    animation: cardFadeIn 0.4s ease forwards;
}

/* Stagger animation for multiple cards */
.ad-card.animate-in:nth-child(1) { animation-delay: 0.05s; }
.ad-card.animate-in:nth-child(2) { animation-delay: 0.1s; }
.ad-card.animate-in:nth-child(3) { animation-delay: 0.15s; }
.ad-card.animate-in:nth-child(4) { animation-delay: 0.2s; }
.ad-card.animate-in:nth-child(5) { animation-delay: 0.25s; }
.ad-card.animate-in:nth-child(6) { animation-delay: 0.3s; }
.ad-card.animate-in:nth-child(7) { animation-delay: 0.35s; }
.ad-card.animate-in:nth-child(8) { animation-delay: 0.4s; }

/* ==========================================================================
   Dark Mode Support (if needed in future)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .ad-card.dark-mode {
        --ad-card-bg: #1f2937;
        --ad-card-text: #f9fafb;
        --ad-card-text-muted: #9ca3af;
        --ad-card-border: #374151;
    }
}
