/**
 * Listing Layout - Responsive content + gallery positioning
 * Mobile: stacked (gallery below)
 * Desktop: side-by-side (gallery on right) using CSS Grid
 */
.listing-layout {
    display: block;
}

.listing-layout__content {
    width: 100%;
}

.listing-layout__gallery {
    width: 100%;
    margin-top: 1rem;
}

/* Desktop: CSS Grid for side-by-side layout */
@media (min-width: 992px) {
    /* Single listing: content + gallery */
    .listing-layout--single {
        display: grid !important;
        grid-template-columns: 58% 40% !important;
        gap: 2% !important;
        align-items: start;
    }

    .listing-layout--single .listing-layout__content {
        grid-column: 1 !important;
    }

    .listing-layout--single .listing-layout__gallery {
        grid-column: 2 !important;
        grid-row: 1 !important;
        margin-top: 0;
        background: #f8f9fa;
        padding: 1rem;
        border-radius: 8px;
        border: 1px solid #e9ecef;
    }

    /* Adjust gallery grid for sidebar width */
    .listing-layout--single .pa-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    /* List view: content + ads sidebar */
    .listing-layout:not(.listing-layout--single) {
        display: grid !important;
        grid-template-columns: 1fr 300px !important;
        gap: 20px !important;
        align-items: start;
    }

    .listing-layout:not(.listing-layout--single) .listing-layout__content {
        grid-column: 1 !important;
    }

    .listing-layout:not(.listing-layout--single) .listing-layout__sidebar {
        grid-column: 2 !important;
        grid-row: 1 !important;
        position: sticky;
        top: 70px;
        align-self: start; /* Required for sticky to work in grid */
    }
}

/* 1200px+: balance content and gallery */
@media (min-width: 1200px) {
    .listing-layout--single {
        grid-template-columns: 55% 43% !important;
    }
}

/**
 * PA Gallery - Modern Responsive Gallery
 * Used for preview mode and new listings
 */

.pa-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 0;
    margin: 0;
}

.pa-gallery__item {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f0f0f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* Fallback for browsers without aspect-ratio support */
    padding-bottom: 75%; /* 4:3 ratio */
    height: 0;
}

/* Modern browsers with aspect-ratio support */
@supports (aspect-ratio: 4 / 3) {
    .pa-gallery__item {
        aspect-ratio: 4 / 3;
        padding-bottom: 0;
        height: auto;
    }
}

.pa-gallery__item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pa-gallery__item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .pa-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .pa-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .pa-gallery__item {
        border-radius: 4px;
    }
}

/* Tier-based gallery sizing hints */
/* VIP: 6 images - 3 columns on desktop */
/* Premium: 12 images - 4 columns on desktop */
@media (min-width: 992px) {
    .pa-gallery {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Show only first 6 images, hide rest (click overlay opens lightbox with all) */
.pa-gallery__item:nth-child(n+7) {
    display: none;
}

/* Loading state placeholder */
.pa-gallery__item img[src=""] {
    visibility: hidden;
}

/* "More photos" overlay item */
.pa-gallery__item--more {
    position: relative;
    cursor: pointer;
}

.pa-gallery__item--more::before {
    content: attr(data-more-text);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    z-index: 1;
    border-radius: 8px;
}

/* Lightbox trigger indicator */
.pa-gallery__item::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E");
    background-size: 14px;
    background-repeat: no-repeat;
    background-position: center;
}

.pa-gallery__item:hover::after {
    opacity: 1;
}

/**
 * Listing Section Container
 * Wraps tabs/accordion and other content sections
 */

.listing-section {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

.listing-section__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    align-items: center;
}

.listing-section__title i {
    color: #6c757d;
}

/**
 * Listing Tabs/Accordion Component
 * Mobile: Accordion layout
 * Desktop (>=768px): Horizontal tabs layout
 */

.listing-tabs {
    margin: 1rem 0 0 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

/* Tab Navigation - Hidden on mobile, visible on desktop */
.listing-tabs__nav {
    display: none !important;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 0;
    margin: 0;
    list-style: none;
}

.listing-tabs__nav .nav-item {
    margin: 0;
}

.listing-tabs__nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: transparent;
    color: #495057;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.listing-tabs__nav .nav-link:hover {
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.05);
}

.listing-tabs__nav .nav-link.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
    background: #fff;
}

.listing-tabs__nav .nav-link i {
    font-size: 1rem;
}

/* Accordion Content */
.listing-tabs__content {
    border: none;
}

.listing-tabs__content .accordion-item {
    border: none;
    border-bottom: 1px solid #e9ecef;
}

.listing-tabs__content .accordion-item:last-child {
    border-bottom: none;
}

.listing-tabs__content .accordion-header {
    margin: 0;
}

.listing-tabs__content .accordion-button {
    font-weight: 500;
    padding: 1rem 1.25rem;
    background: #f8f9fa;
    box-shadow: none;
}

.listing-tabs__content .accordion-button:not(.collapsed) {
    color: #0d6efd;
    background: #e7f1ff;
}

.listing-tabs__content .accordion-button:focus {
    box-shadow: none;
    border-color: transparent;
}

.listing-tabs__content .accordion-body {
    padding: 1.25rem;
    line-height: 1.6;
}

/* Mobile: Accordion behavior - Bootstrap controls collapse */
@media (max-width: 767.98px) {
    .listing-tabs__content .accordion-body {
        /* Always visible when parent accordion-collapse is expanded */
        display: block !important;
    }
}

/* Placeholder styling */
.listing-tabs__placeholder {
    color: #6c757d;
}

.listing-tabs__placeholder h5 {
    color: #495057;
    margin-bottom: 0.75rem;
}

.listing-tabs__placeholder p:last-child,
.listing-tabs__placeholder ul:last-child {
    margin-bottom: 0;
}

.listing-tabs__placeholder ul {
    padding-left: 1.25rem;
}

.listing-tabs__placeholder li {
    margin-bottom: 0.5rem;
}

/* VIP Premium (tier 2) - slightly different accent */
.listing-tabs[data-tier="2"] .listing-tabs__nav .nav-link.active {
    color: #dc3545;
    border-bottom-color: #dc3545;
}

.listing-tabs[data-tier="2"] .accordion-button:not(.collapsed) {
    color: #dc3545;
    background: #fdeaec;
}

/* Desktop: Transform accordion to tabs */
@media (min-width: 768px) {
    .listing-tabs__nav {
        display: flex !important;
        width: 100%;
    }

    .listing-tabs__nav .nav-item {
        flex: 1;
    }

    .listing-tabs__nav .nav-link {
        width: 100%;
        justify-content: center;
    }
}

/* Desktop tabs (768px+): icon above text, hide accordion */
@media (min-width: 768px) {
    .listing-tabs__nav .nav-link {
        padding: 0.75rem 0.5rem;
        flex-direction: column;
        gap: 0.25rem;
        font-size: 0.75rem;
    }

    .listing-tabs__nav .nav-link i {
        font-size: 1.1rem;
    }

    /* Hide accordion headers on desktop */
    .listing-tabs__content .accordion-header {
        display: none !important;
    }

    /* Show all accordion-collapse wrappers on desktop (tabs control visibility) */
    .listing-tabs__content .accordion-collapse {
        display: block !important;
        height: auto !important;
    }

    /* Hide all tab panes by default */
    .listing-tabs__content .accordion-body {
        display: none;
    }

    /* Show only the active tab pane */
    .listing-tabs__content .accordion-body.active {
        display: block;
    }

    /* Remove accordion styling */
    .listing-tabs__content .accordion-item {
        border: none;
    }

    .listing-tabs__content {
        padding: 0;
    }

    /* Tab content area */
    .listing-tabs__content .accordion-body {
        padding: 1.5rem;
    }
}
