/**
 * KejaHub Modern Listing Cards & UI Enhancements
 * Responsive, mobile-optimized card design
 */

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --card-hover-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== MODERN LISTING CARDS ===== */

.listing-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition-smooth);
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

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

/* Image Container with gradient overlay */
.listing-card-image {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.listing-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.listing-card:hover .listing-card-image img {
    transform: scale(1.1);
}

/* Image overlay with gradient */
.listing-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    padding: 16px;
}

.listing-card:hover .listing-card-overlay {
    opacity: 1;
}

/* Favorite button */
.favorite-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
}

.favorite-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.98) 100%);
    transform: scale(1.15);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 4px 8px rgba(0, 0, 0, 0.12);
    border-color: rgba(255, 255, 255, 0.6);
}

.favorite-btn.favorite-active {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF5252 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4), 0 2px 6px rgba(255, 107, 107, 0.2);
}

.favorite-btn.favorite-active:hover {
    transform: scale(1.2);
    box-shadow: 0 8px 28px rgba(255, 107, 107, 0.5), 0 4px 10px rgba(255, 107, 107, 0.3);
}

@media (max-width: 768px) {
    .favorite-btn {
        width: 42px;
        height: 42px;
        font-size: 18px;
        top: 10px;
        right: 10px;
    }

    .favorite-btn:hover {
        transform: scale(1.12);
    }

    .favorite-btn.favorite-active:hover {
        transform: scale(1.12);
    }
}

@media (max-width: 576px) {
    .favorite-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        top: 8px;
        right: 8px;
    }

    .favorite-btn:hover {
        transform: scale(1.1);
    }

    .favorite-btn.favorite-active:hover {
        transform: scale(1.1);
    }
}

/* Badge container */
.listing-card-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.listing-badge {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.listing-badge.badge-featured {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.listing-badge.badge-verified {
    background: #4CAF50;
    color: white;
}

.listing-badge.badge-new {
    background: #FF9800;
    color: white;
}

/* Card Content */
.listing-card-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.listing-card-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.listing-card-location {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.listing-card-location i {
    color: #667eea;
}

/* Features grid */
.listing-card-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 12px 0;
    padding: 12px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
}

.feature-item i {
    color: #667eea;
    font-size: 14px;
    width: 18px;
}

/* Price section */
.listing-card-price {
    margin: 12px 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.price-amount {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

.price-period {
    font-size: 14px;
    color: #999;
}

.price-old {
    font-size: 14px;
    color: #ccc;
    text-decoration: line-through;
}

/* Footer with CTA */
.listing-card-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.listing-card-footer .btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.listing-card-footer .btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: white;
}

.listing-card-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.listing-card-footer .btn-outline-secondary {
    border-color: #ddd;
    color: #667eea;
}

.listing-card-footer .btn-outline-secondary:hover {
    background: #f5f7fa;
    border-color: #667eea;
}

/* Listings page masonry card readability tweaks */
.listing-pin-card .property-title {
    font-size: 1.05rem;
    line-height: 1.35;
    letter-spacing: 0.1px;
    min-height: 2.85rem;
}

.listing-pin-card .property-subtitle {
    font-size: 0.84rem;
    color: #5b6575;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.listing-pin-card .property-location-text {
    color: #3f4a5a;
    font-size: 0.9rem;
    font-weight: 500;
}

.listing-pin-card .card-body {
    padding: 1.15rem 1.05rem 1rem !important;
}

.listing-pin-card .feature-chip {
    min-width: 84px;
    padding: 0.3rem 0.45rem;
    border-radius: 10px;
    background: #f7f9fc;
}

.listing-pin-card .property-features {
    gap: 0.5rem;
}

.listing-pin-card .btn {
    min-height: 42px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

@media (max-width: 768px) {
    .listing-pin-card .card-body {
        padding: 0.95rem 0.9rem 0.9rem !important;
    }

    .listing-pin-card .property-title {
        font-size: 0.98rem;
        min-height: 2.55rem;
    }

    .listing-pin-card .feature-chip {
        min-width: 74px;
        padding: 0.25rem 0.35rem;
    }
}

/* ===== LAZY LOADING OPTIMIZATION ===== */

.listing-card-image img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .listing-card-image {
        height: 180px;
    }

    .listing-card-title {
        font-size: 16px;
    }

    .listing-card-content {
        padding: 16px;
    }

    .listing-card-features {
        grid-template-columns: 1fr;
        gap: 8px;
        margin: 8px 0;
    }

    .price-amount {
        font-size: 20px;
    }

    .favorite-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* ===== TOUCH-FRIENDLY BUTTONS ===== */

.listing-card-footer .btn {
    min-height: 44px; /* Touch-friendly size */
}

/* ===== GRID LAYOUT ===== */

.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 24px 0;
}

@media (max-width: 1200px) {
    .listings-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .listings-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .listings-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* ===== SKELETON LOADING ===== */

.listing-card.skeleton {
    pointer-events: none;
}

.listing-card.skeleton .listing-card-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.listing-card.skeleton .listing-card-title,
.listing-card.skeleton .listing-card-location,
.listing-card.skeleton .price-amount {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    color: transparent;
}

/* ===== EMPTY STATE ===== */

.listings-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.listings-empty i {
    font-size: 64px;
    color: #ddd;
    margin-bottom: 20px;
}

.listings-empty h3 {
    color: #666;
    margin-bottom: 10px;
}

/* ===== MOBILE PERFORMANCE ===== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .listing-card,
    .listing-card-image img,
    .favorite-btn {
        transition: none !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .listing-card {
        background: #2a2a2a;
        color: #f0f0f0;
    }

    .listing-card-title {
        color: #f0f0f0;
    }

    .listing-card-location {
        color: #aaa;
    }

    .feature-item {
        color: #ccc;
    }

    .listing-card-features {
        border-color: #444;
    }

    .listing-card-footer {
        border-color: #444;
    }
}

/* ===== ANIMATION ENHANCEMENTS ===== */

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

.listing-card {
    animation: slideInUp 0.5s ease forwards;
}

.listing-card:nth-child(2) { animation-delay: 0.1s; }
.listing-card:nth-child(3) { animation-delay: 0.2s; }
.listing-card:nth-child(4) { animation-delay: 0.3s; }
.listing-card:nth-child(5) { animation-delay: 0.4s; }
.listing-card:nth-child(6) { animation-delay: 0.5s; }
