/* List and Grid View Styling */

/* Base listing item styling */
.listing-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
}

/* ============================================
   LIST VIEW - Image on LEFT, Content on RIGHT
   ============================================ */

.list-view .listing-item {
    width: 100%;
}

.list-view .listing-item .listingCard {
    display: flex;
    flex-direction: row;
    height: 100%;
    width: 100%;
}

/* LIST VIEW: Row horizontal layout */
.list-view .listing-item .row {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
}

/* LIST VIEW: Image on left (33.33% width) */
.list-view .listing-item .col-xl-4 {
    flex: 0 0 33.333% !important;
    max-width: 33.333% !important;
    width: 33.333% !important;
    margin-right: auto;
}

/* LIST VIEW: Content on right (66.67% width) */
.list-view .listing-item .col-xl-8 {
    flex: 0 0 66.667% !important;
    max-width: 66.667% !important;
    width: 66.667% !important;
    margin-left: auto;
}

/* Adjustments for index.blade.php style cards in list view */
.list-view .listing-item .listing-middle-item {
    padding: 1.5rem 1.5rem !important;
}

.list-view .listing-item .listing-avatar {
    display: none;
    /* Hide avatar in list view to save space and avoid alignment issues */
}

.list-view .listing-item .listing-details {
    min-height: auto !important;
}

/* ============================================
   GRID VIEW - Image on TOP, Content on BOTTOM
   ============================================ */

.grid-view .listing-item {
    display: flex;
    width: 100%;
}

.grid-view .listing-item .listingCard {
    height: 100%;
    width: 100%;
    display: flex !important;
    flex-direction: column !important;
}

/* GRID VIEW: Row vertical layout - CRITICAL FIX */
.grid-view .listing-item .row {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* GRID VIEW: Image on top (full width) */
.grid-view .listing-item .col-xl-4 {
    flex: 0 0 auto !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    order: -1 !important;
}

/* GRID VIEW: Content below image (full width) */
.grid-view .listing-item .col-xl-8 {
    flex: 1 1 auto !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Desktop - List View (2 columns) */
@media (min-width: 1200px) {
    .list-view .row.align-items-stretch {
        display: flex;
        flex-wrap: wrap;
    }

    .list-view .listing-item[data-layout="list"] {
        flex: 0 0 calc(50% - 8px);
        max-width: calc(50% - 8px);
    }
}

/* Desktop - Grid View (3 columns) */
@media (min-width: 1200px) {
    .grid-view .row.align-items-stretch {
        display: flex;
        flex-wrap: wrap;
    }

    .grid-view .listing-item[data-layout="grid"] {
        flex: 0 0 calc(25% - 10px);
        max-width: calc(25% - 10px);
    }
}

/* Tablet adjustments */
@media (max-width: 1199.98px) and (min-width: 768px) {
    .list-view .listing-item {
        flex: 0 0 48%;
        max-width: 48%;
    }

    .grid-view .listing-item {
        flex: 0 0 48%;
        max-width: 48%;
    }

    .list-view .listing-item .row {
        flex-direction: row !important;
    }

    .list-view .listing-item .col-xl-4,
    .list-view .listing-item .col-xl-8 {
        width: 100% !important;
    }
}

/* Mobile - Full width */
@media (max-width: 767.98px) {
    .listing-item {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .list-view .listing-item .row,
    .grid-view .listing-item .row {
        flex-direction: column !important;
    }

    .list-view .listing-item .col-xl-4,
    .list-view .listing-item .col-xl-8,
    .grid-view .listing-item .col-xl-4,
    .grid-view .listing-item .col-xl-8 {
        width: 100% !important;
    }

    .list-view .listing-item .listThumb {
        margin-bottom: 1rem;
    }
}

/* Animation for view switching */
.listing-item.fade-out {
    opacity: 0;
    transform: translateY(10px);
}

.listing-item.fade-in {
    opacity: 1;
    transform: translateY(0);
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced button styling for view toggle */
.nav-link[data-view] {
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-link[data-view].active {
    background-color: var(--bs-primary, #007bff) !important;
    color: white !important;
}

.nav-link[data-view]:not(.active) {
    background-color: transparent;
    border-color: var(--bs-border-color, #dee2e6);
}

.nav-link[data-view]:hover:not(.active) {
    background-color: var(--bs-light, #f8f9fa);
}

/* Grid view specifics for the new style */
.grid-view .listing-item .listing-middle-item {
    padding-top: 2.6rem !important;
}

.grid-view .listing-item .listing-avatar {
    display: block !important;
}

/* Ensure cards take full height */
.listingCard {
    height: 100%;
}

.listingCard .listCaption {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Responsive container */
#listingsContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

#listingsContainer.list-view {
    gap: 1rem;
}

#listingsContainer.grid-view {
    gap: 0.8rem;
}

/* Remove Bootstrap default margins from columns in grid view */
.grid-view .col-xl-4,
.grid-view .col-xl-8 {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Ensure listThumb takes full width in grid view */
.grid-view .listThumb {
    width: 100%;
    height: auto;
}

/* Ensure listCaption alignment in grid view */
.grid-view .listCaption {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* CRITICAL: Grid view image column styling */
.grid-view .grid-image {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    order: -1 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* CRITICAL: Grid view content column styling */
.grid-view .grid-content {
    flex: 1 1 auto !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* LIST VIEW: Preserve image and content layout */
.list-view .grid-image {
    flex: 0 0 33.333% !important;
    max-width: 33.333% !important;
    width: 33.333% !important;
    order: 0 !important;
}

.list-view .grid-content {
    flex: 0 0 66.667% !important;
    max-width: 66.667% !important;
    width: 66.667% !important;
    order: 1 !important;
}

.list-view {
    display: flex;
    flex-wrap: wrap;
}

.grid-view {
    display: flex;
    flex-wrap: wrap;
}

/* Smooth transition when switching views */
.listing-item {
    transition: all 0.3s ease;
}