/* =============================================================================
   UNIFIED PROPERTY CARDS - Responsive Grid Layout
   Card-based layout for properties page on both desktop and mobile
   ============================================================================= */

/* =============================================================================
   CONTAINER AND GRID LAYOUT
   ============================================================================= */

.property-cards-view {
    display: block;
    padding: 0;
}

/* Sort Bar */
.sort-bar {
    background: var(--hh-color-base-white);
    padding: 12px 16px;
    border-bottom: 1px solid var(--hh-color-borders-default);
    position: sticky;
    top: 56px; /* Below navbar */
    z-index: 10;
}

.sort-select {
    min-width: 200px;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--hh-color-borders-default);
    border-radius: var(--hh-radius-sm);
    background: var(--hh-color-base-white);
    color: var(--hh-color-text-primary);
    cursor: pointer;
}

.sort-select:focus {
    outline: none;
    border-color: var(--hh-color-brand-primary);
}

/* Cards Grid Container */
.property-cards-container {
    display: grid;
    gap: 1px;
    background: var(--hh-color-borders-subtle);
}

/* Desktop: 3 columns */
@media (min-width: 1200px) {
    .property-cards-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet: 2 columns */
@media (min-width: 769px) and (max-width: 1199px) {
    .property-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: 1 column (list view) */
@media (max-width: 768px) {
    .property-cards-container {
        grid-template-columns: 1fr;
    }

    .sort-bar {
        top: 56px; /* Below mobile toolbar */
    }
}

/* =============================================================================
   PROPERTY CARD
   ============================================================================= */

.property-card {
    background: var(--hh-color-base-white);
    padding: 16px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.property-card:hover {
    background: var(--hh-color-base-offWhite);
}

.property-card:active {
    background: var(--hh-color-base-cloud);
}

/* Card Layout - Horizontal on mobile, can be adapted */
.card-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* Card Image Container */
.card-image-container {
    flex-shrink: 0;
    width: 120px;
    height: 100px;
    border-radius: var(--hh-radius-md);
    overflow: hidden;
    background: var(--hh-color-base-cloud);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hh-color-base-cloud);
    color: var(--hh-color-text-muted);
}

.card-image-placeholder i {
    font-size: 36px;
    opacity: 0.5;
}

/* Card Content */
.card-content {
    flex: 1;
    min-width: 0; /* Allow text truncation */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100px;
}

/* Card Header Section */
.card-header {
    margin-bottom: 8px;
}

.card-address {
    font-size: 15px;
    font-weight: 600;
    color: var(--hh-color-text-primary);
    line-height: 1.3;
    margin-bottom: 2px;
    /* Truncate long addresses */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-location {
    font-size: 13px;
    color: var(--hh-color-text-secondary);
    margin-bottom: 4px;
}

.card-specs {
    font-size: 12px;
    color: var(--hh-color-text-tertiary);
}

/* Card Metrics Row */
.card-metrics-row {
    display: flex;
    justify-content: flex-start;
    gap: 20px;
    padding-top: 8px;
    border-top: 1px solid var(--hh-color-borders-subtle);
}

.card-metric {
    text-align: left;
    min-width: 0;
}

.metric-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--hh-color-text-muted);
    margin-bottom: 2px;
    font-weight: 500;
}

.metric-value {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--hh-color-text-primary);
}

.metric-value.positive {
    color: #28a745;
}

.metric-value.negative {
    color: #dc3545;
}

.metric-value.neutral {
    color: var(--hh-color-text-primary);
}

.metric-value.placeholder {
    color: var(--hh-color-text-muted);
    font-weight: 400;
}

/* =============================================================================
   LOADING STATE
   ============================================================================= */

.cards-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 16px;
    color: var(--hh-color-text-secondary);
    gap: 16px;
    background: var(--hh-color-base-white);
}

.cards-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--hh-color-borders-default);
    border-top-color: var(--hh-color-brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

.cards-empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    background: var(--hh-color-base-white);
    color: var(--hh-color-text-secondary);
}

.cards-empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.cards-empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--hh-color-text-primary);
}

.cards-empty-state p {
    font-size: 14px;
    margin-bottom: 24px;
}

/* =============================================================================
   ERROR STATE
   ============================================================================= */

.cards-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    background: var(--hh-color-base-white);
    color: var(--hh-color-text-secondary);
}

.cards-error p {
    margin: 16px 0;
    font-size: 14px;
}

/* =============================================================================
   LOAD MORE
   ============================================================================= */

.load-more-container {
    display: none;
    padding: 24px 16px;
    text-align: center;
    background: var(--hh-color-base-white);
}

.load-more-container button {
    min-width: 200px;
    padding: 12px 32px;
    font-size: 14px;
    font-weight: 600;
}

/* =============================================================================
   MOBILE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {
    .property-card {
        padding: 12px 16px;
    }

    .card-layout {
        gap: 12px;
    }

    .card-image-container {
        width: 90px;
        height: 90px;
    }

    .card-content {
        min-height: 90px;
    }

    .card-address {
        font-size: 14px;
    }

    .card-location {
        font-size: 12px;
    }

    .card-specs {
        font-size: 11px;
    }

    .card-metrics-row {
        gap: 16px;
        padding-top: 6px;
    }

    .metric-label {
        font-size: 9px;
    }

    .metric-value {
        font-size: 13px;
    }

    /* Full width load more button on mobile */
    .load-more-container button {
        width: 100%;
        max-width: 300px;
    }
}

/* =============================================================================
   DESKTOP ENHANCEMENTS
   ============================================================================= */

@media (min-width: 769px) {
    .card-image-container {
        width: 140px;
        height: 110px;
    }

    .card-content {
        min-height: 110px;
    }

    .card-metrics-row {
        gap: 24px;
    }
}

/* Hide old DataTables elements when using card view */
.property-cards-view ~ .desktop-table-view,
.property-cards-view ~ #loadingSkeleton,
body.cards-view .dataTables_wrapper,
body.cards-view .dataTables_info,
body.cards-view .dataTables_paginate {
    display: none !important;
}
