/**
 * Content Bridge Ads - Frontend Styles
 */

/* Ad Wrapper */
.cb-ad-wrapper {
    position: relative;
    margin: 20px 0;
    text-align: center;
    clear: both;
}

/* Ad Label */
.cb-ad-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-bottom: 5px;
}

/* Banner Ads */
.cb-ad-link {
    display: inline-block;
    text-decoration: none;
}

.cb-ad-image {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Text Ads */
.cb-ad-text {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
}

.cb-ad-text-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

.cb-ad-text-description {
    margin: 0 0 15px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
}

.cb-ad-text-cta {
    display: inline-block;
    padding: 10px 24px;
    background: #2271b1;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.cb-ad-text-cta:hover {
    background: #135e96;
    color: #fff;
}

/* AdSense Container */
.cb-ad-type-adsense {
    min-height: 90px;
}

.cb-ad-type-adsense .adsbygoogle {
    display: block;
}

/* Sticky Ad (Sidebar) */
.cb-ad-sticky {
    position: sticky;
    top: 20px;
}

/* Device Visibility */
.cb-ad-mobile-only {
    display: none;
}

.cb-ad-desktop-only {
    display: block;
}

@media screen and (max-width: 768px) {
    .cb-ad-mobile-only {
        display: block;
    }

    .cb-ad-desktop-only {
        display: none;
    }
}

/* Placement-specific styles */
.cb-ad-placement-header-leaderboard {
    margin: 10px auto;
}

.cb-ad-placement-sidebar-top,
.cb-ad-placement-sidebar-sticky {
    margin: 0 0 20px 0;
}

.cb-ad-placement-content-after-p2,
.cb-ad-placement-content-middle,
.cb-ad-placement-content-before-end {
    margin: 30px auto;
    padding: 15px 0;
}

.cb-ad-placement-footer-banner {
    margin: 20px auto;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.cb-ad-placement-archive-in-feed {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Loading state */
.cb-ad-wrapper[data-loading="true"] {
    opacity: 0.5;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .cb-ad-wrapper {
        margin: 15px 0;
    }

    .cb-ad-text {
        padding: 15px;
    }

    .cb-ad-text-title {
        font-size: 16px;
    }

    .cb-ad-text-description {
        font-size: 13px;
    }

    .cb-ad-text-cta {
        padding: 8px 20px;
        font-size: 13px;
    }
}

/* Print - hide ads */
@media print {
    .cb-ad-wrapper {
        display: none !important;
    }
}

/* Animation for impression tracking */
@keyframes cb-ad-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cb-ad-wrapper {
    animation: cb-ad-appear 0.3s ease-out;
}

/* ============================================
   Feed Ads (Product Ads from Central API)
   ============================================ */

.cb-feed-ad-wrapper {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.cb-feed-ad-wrapper:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Feed Ad - Product Type */
.cb-feed-ad-product {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    padding: 15px;
}

.cb-feed-ad-product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 4px;
    margin-bottom: 12px;
    background: #f8f9fa;
}

.cb-feed-ad-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cb-feed-ad-product-info {
    flex: 1;
}

.cb-feed-ad-product-name {
    margin: 0 0 8px 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cb-feed-ad-product-desc {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cb-feed-ad-price {
    display: block;
    font-size: 16px;
    margin-top: auto;
}

.cb-feed-ad-price del {
    color: #999;
    font-size: 13px;
    margin-right: 8px;
}

.cb-feed-ad-price strong {
    color: #d32f2f;
}

.cb-feed-ad-stock {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    margin-top: 8px;
}

.cb-feed-ad-stock-out {
    background: #ffebee;
    color: #c62828;
}

/* Feed Ad - Banner Type */
.cb-feed-ad-banner {
    display: block;
}

.cb-feed-ad-banner-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Feed Ads Collection (Grid/Slider) */
.cb-feed-ads-collection {
    margin: 20px 0;
}

.cb-feed-ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.cb-feed-ads-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cb-feed-ads-slider {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
}

.cb-feed-ads-slider .cb-feed-ads-item {
    flex: 0 0 250px;
    scroll-snap-align: start;
}

.cb-feed-ads-item {
    min-width: 0;
}

/* Horizontal product card variant */
.cb-feed-ad-type-product.cb-feed-ad-horizontal .cb-feed-ad-product {
    flex-direction: row;
    align-items: flex-start;
}

.cb-feed-ad-type-product.cb-feed-ad-horizontal .cb-feed-ad-product-image {
    width: 120px;
    flex-shrink: 0;
    margin-right: 15px;
    margin-bottom: 0;
}

/* Responsive Feed Ads */
@media screen and (max-width: 768px) {
    .cb-feed-ads-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .cb-feed-ad-product {
        padding: 10px;
    }

    .cb-feed-ad-product-name {
        font-size: 13px;
    }

    .cb-feed-ad-product-desc {
        display: none;
    }

    .cb-feed-ad-price {
        font-size: 14px;
    }

    .cb-feed-ads-slider .cb-feed-ads-item {
        flex: 0 0 180px;
    }
}

@media screen and (max-width: 480px) {
    .cb-feed-ads-grid {
        grid-template-columns: 1fr;
    }

    .cb-feed-ad-type-product.cb-feed-ad-horizontal .cb-feed-ad-product {
        flex-direction: column;
    }

    .cb-feed-ad-type-product.cb-feed-ad-horizontal .cb-feed-ad-product-image {
        width: 100%;
        margin-right: 0;
        margin-bottom: 12px;
    }
}
