/* =============================================================================
   LISTING CARD COMPONENTS (Shared across all pages)
   Files using this: index.php, listings.php, listing-detail.php
   ============================================================================= */

/* SF Pro Display Font Stack */
.listing-card,
.listing-title,
.listing-price,
.listing-badge {
    font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

/* =========================
   1. GRID LAYOUT
   ========================= */
/* =========================
   1. GRID LAYOUT
   ========================= */
.listings-grid {
    display: grid;
    /* Force 4 columns on desktop with minmax to prevent blowing out */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    /* Reduced gap for compact look */
    margin-top: 24px;
    position: relative;
    width: 100%;
}

@media (max-width: 1024px) {
    .listings-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .listings-grid {
        /* Force 2 columns on mobile */
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    /* Ensure cards can shrink to fit */
    .listing-card {
        min-width: 0 !important;
        width: 100% !important;
    }
}

/* =========================
   2. CARD CONTAINER (COMPACT)
   ========================= */
.listing-card {
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    /* Smaller radius */
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    /* Lighter shadow */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
    transform: translateZ(0);
}

/* ... Dark mode ... */
[data-theme="dark"] .listing-card {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.listing-card:hover {
    transform: translateY(-4px);
    /* Less movement */
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color, #2563eb);
}

/* ... */

/* =========================
   3. IMAGE AREA
   ========================= */
.listing-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f1f5f9;
}

/* ... */

.listing-image img {
    /* ... */
}

/* Badges - Compact */
.listing-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    /* Compact padding */
    border-radius: 100px;
    font-size: 10px;
    /* Smaller font */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: #2563eb;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ... */

/* =========================
   4. CONTENT BODY (COMPACT)
   ========================= */
.listing-body {
    padding: 12px;
    /* Reduced from 20px */
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Title - Smaller */
.listing-title {
    font-size: 14px;
    /* Reduced from 16px */
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px;
    color: var(--text-primary, #1e293b);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 36px;
    /* Adjusted fixed height */
    transition: color 0.2s;
}

/* ... */

/* Location - Smaller */
.listing-location {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    /* Reduced from 13px */
    color: var(--text-secondary, #64748b);
    margin-bottom: 10px;
    font-weight: 500;
}

/* ... */

/* Details Grid - Compact */
.listing-details {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
}

.listing-detail {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    /* Reduced from 12px */
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    background: var(--bg-secondary, #f1f5f9);
    padding: 4px 8px;
    /* Compact padding */
    border-radius: 6px;
}

/* ... */

.listing-detail i {
    color: var(--primary-color, #2563eb);
    font-size: 10px;
}

/* =========================
   5. FOOTER
   ========================= */
.listing-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Price - Compact but bold */
.listing-price {
    font-size: 16px;
    /* Reduced from 22px */
    font-weight: 800;
    color: var(--primary-color, #2563eb);
    letter-spacing: -0.3px;
    font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .listing-price {
    color: #60a5fa;
    /* Lighter blue for dark mode contrast */
}

/* Agent */
.agent-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    object-fit: cover;
}

[data-theme="dark"] .agent-avatar {
    border-color: rgba(255, 255, 255, 0.1);
}

/* =========================
   6. PHOTO CAROUSEL (Gallery)
   ========================= */
.photo-carousel {
    position: relative;
    height: 240px;
    overflow: hidden;
    background: var(--bg-secondary, #f1f5f9);
    cursor: grab;
}

[data-theme="dark"] .photo-carousel {
    background: #0f172a;
}

.photo-carousel.is-grabbing {
    cursor: grabbing;
}

.carousel-images {
    display: flex;
    height: 100%;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.carousel-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    flex-shrink: 0;
    user-select: none;
    pointer-events: none;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 2;
    opacity: 0;
    visibility: hidden;
}

.photo-carousel:hover .carousel-btn {
    opacity: 1;
    visibility: visible;
}

.carousel-btn:hover {
    background: var(--primary-color, #2563eb);
    transform: translateY(-50%) scale(1.15);
}

.carousel-btn-prev {
    left: 12px;
}

.carousel-btn-next {
    right: 12px;
}

.carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 2;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* =========================
   7. MOBILE RESPONSIIVENESS REFINEMENTS
   ========================= */
@media (max-width: 768px) {
    /* Container/Grid adjustments were made above */

    /* Image area - Make it shorter to save vertical space */
    .listing-image,
    .photo-carousel {
        height: 160px !important;
        /* Force a shorter height */
        aspect-ratio: auto !important;
        /* Override square ratio */
    }

    /* Badges - Smaller */
    .listing-badge {
        font-size: 9px;
        padding: 4px 10px;
        top: 10px;
        left: 10px;
    }

    /* Body - tighter padding */
    .listing-body {
        padding: 10px;
    }

    /* Price - Compact */
    .listing-price {
        font-size: 16px;
        margin-bottom: 4px;
    }

    /* Title - Smaller, 2 lines max */
    .listing-title {
        font-size: 13px;
        line-height: 1.3;
        margin-bottom: 6px;
        height: 34px;
        /* Fixed height for 2 lines */
    }

    /* Location - Very compact */
    .listing-location {
        font-size: 11px;
        margin-bottom: 8px;
        gap: 4px;
    }

    /* Details (Icons) - Smaller */
    .listing-details {
        margin-bottom: 8px;
        padding-bottom: 8px;
        gap: 4px;
    }

    .listing-detail {
        font-size: 10px;
        padding: 4px 6px;
    }

    .listing-detail i {
        font-size: 10px;
    }

    /* Footer - Agent to Bottom Right */
    .listing-footer {
        padding-top: 0;
        margin-top: auto;
        border-top: none;
        /* Remove separator line to save space */
        position: relative;
    }

    /* Hide Date/Views on mobile if needed to save space, or make them tiny */
    .listing-footer>div:last-child {
        /* This targets the date/views container on the right usually.
           But we want Agent on Right.
           The HTML structure is: 
           .listing-footer > .listing-agent (Left)
           .listing-footer > div (Date/Views) (Right)
           
           We need to swap them visually or absolutely position the agent.
        */
        font-size: 9px !important;
        display: none;
        /* Hide date on mobile to clean up */
    }

    /* Position Agent to Bottom Right */
    .listing-agent {
        position: absolute;
        bottom: 0;
        right: 0;
        z-index: 5;
    }

    .agent-avatar {
        width: 24px;
        height: 24px;
        border-width: 1px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }

    .listing-agent span {
        display: none;
        /* Hide agent name on mobile, show only photo */
    }
}