/**
 * Advertisement Styles
 */

/* Ad Container */
.ad-container {
    margin: 1rem 0;
    display: block;
    text-align: center;
    overflow: hidden;
    box-sizing: border-box;
}

/* Zone-constrained containers */
.ad-container[data-zone-width][data-zone-height] {
    width: var(--zone-width);
    height: var(--zone-height);
    max-width: var(--zone-width);
    max-height: var(--zone-height);
    margin-left: auto;
    margin-right: auto;
}

.ad-container img,
.ad-container video {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Ad Link */
.ad-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

.ad-link:hover {
    opacity: 0.9;
}

/* Ad Image */
.ad-image {
    width: 100%;
    height: auto;
    border-radius: 4px;
    object-fit: contain;
}

/* Zone-constrained images */
.ad-container[style*="width"] .ad-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Ad Video */
.ad-video {
    width: 100%;
    max-width: 100%;
    height: auto;
}

/* Ad Content */
.ad-content {
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 4px;
}

.ad-title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark, #333);
}

.ad-description {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-light, #666);
}

/* Related Listing Ads (for attraction detail pages) */
.related-listing-ads {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.listing-ad-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.listing-ad-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.listing-ad-card a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.listing-ad-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.listing-ad-content {
    padding: 1rem;
}

.listing-ad-title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark, #333);
}

.listing-ad-description {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-light, #666);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   RESPONSIVE STYLES - MOBILE FRIENDLY
   ============================================ */

/* Tablet Styles (max-width: 1024px) */
@media (max-width: 1024px) {
    .ad-container {
        margin: 0.75rem 0;
    }
    
    /* Scale down large banners proportionally */
    .ad-section[style*="max-width: 728px"] {
        padding: 1rem 0;
    }
    
    .ad-section[style*="max-width: 728px"] [data-zone] {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Ensure sidebar ads don't overflow */
    .sidebar-card [data-zone] {
        max-width: 100% !important;
        width: 100% !important;
    }
}

/* Mobile/Tablet Styles (max-width: 768px) */
@media (max-width: 768px) {
    .ad-container {
        margin: 0.5rem 0;
    }
    
    /* Ad Section adjustments */
    .ad-section {
        padding: 0.75rem 0 !important;
    }
    
    /* Scale down large banners for mobile */
    .ad-section [data-zone] {
        max-width: 100% !important;
        width: 100% !important;
        min-height: auto !important;
    }
    
    /* 728x90 banners scale to mobile width */
    .ad-section[style*="max-width: 728px"] {
        max-width: 100% !important;
        padding: 0.75rem 1rem !important;
    }
    
    .ad-section[style*="max-width: 728px"] [data-zone] {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 50px !important;
        aspect-ratio: 728 / 90;
    }
    
    /* 300x250 sidebar ads scale down */
    .ad-section[style*="max-width: 300px"] {
        max-width: 100% !important;
        padding: 0.75rem 1rem !important;
    }
    
    .ad-section[style*="max-width: 300px"] [data-zone],
    .sidebar-card [data-zone] {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 150px !important;
        aspect-ratio: 300 / 250;
    }
    
    /* Ad images scale properly */
    .ad-container img,
    .ad-container video {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
    }
    
    /* Ad content text adjustments */
    .ad-content {
        padding: 0.75rem;
    }
    
    .ad-title {
        font-size: 0.9rem;
    }
    
    .ad-description {
        font-size: 0.8rem;
    }
    
    /* Listing ad cards */
    .listing-ad-image {
        height: 120px;
    }
    
    .listing-ad-content {
        padding: 0.75rem;
    }
    
    .listing-ad-title {
        font-size: 0.9rem;
    }
    
    .listing-ad-description {
        font-size: 0.8rem;
    }
    
    /* Sidebar adjustments */
    .sidebar-card {
        margin-bottom: 1rem;
    }
}

/* Small Mobile Styles (max-width: 480px) */
@media (max-width: 480px) {
    .ad-container {
        margin: 0.5rem 0;
    }
    
    /* Ad Section padding */
    .ad-section {
        padding: 0.5rem 0 !important;
    }
    
    .ad-section[style*="padding"] {
        padding: 0.5rem 0.5rem !important;
    }
    
    /* Compact banner ads */
    .ad-section[style*="max-width: 728px"] [data-zone] {
        min-height: 40px !important;
    }
    
    /* Compact sidebar ads */
    .ad-section[style*="max-width: 300px"] [data-zone],
    .sidebar-card [data-zone] {
        min-height: 120px !important;
    }
    
    /* Ad content adjustments */
    .ad-content {
        padding: 0.5rem;
    }
    
    .ad-title {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }
    
    .ad-description {
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    /* Listing ad cards */
    .listing-ad-image {
        height: 100px;
    }
    
    .listing-ad-content {
        padding: 0.5rem;
    }
    
    .listing-ad-title {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }
    
    .listing-ad-description {
        font-size: 0.75rem;
        -webkit-line-clamp: 2;
    }
}

/* Ensure containers don't overflow on mobile */
@media (max-width: 768px) {
    /* Override any fixed widths */
    [data-zone][style*="width"] {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Container max-width adjustments */
    .container[style*="max-width: 728px"] {
        max-width: 100% !important;
        padding: 0 1rem;
    }
    
    .container[style*="max-width: 300px"] {
        max-width: 100% !important;
        padding: 0 1rem;
    }
    
    /* Ensure proper spacing */
    .ad-section + .ad-section {
        margin-top: 0;
    }
}

/* Hide ads when container is hidden */
[data-zone][style*="display: none"] {
    display: none !important;
}

/* Ad Section - Container for ad zones */
.ad-section {
    padding: 1rem 0;
    margin: 0;
}

/* Empty ad zones should not take up space */
[data-zone]:empty {
    display: none !important;
}

/* Hide parent section when ad zone is empty */
.ad-section:has([data-zone]:empty) {
    display: none !important;
}

/* Hide sidebar card when ad zone is empty */
.sidebar-card:has([data-zone]:empty) {
    display: none !important;
}

/* Ad section with no content should be hidden */
.ad-section:not(:has(.ad-container)) {
    display: none !important;
}

