/**
 * Ad Placement Styles CSS
 * 
 * Responsive CSS for all 7 ad placement styles
 */

/* Common Ad Styles */
.niriv-ad {
    position: relative;
    margin: 20px 0;
    padding: 15px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 2px 4px 0 rgba(0,0,0,0.04) !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Infinite feed ads inherit styling from feed box, so remove all default styling */
.niriv-ad-infinite-feed {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    outline: none !important;
}

.niriv-ad .ad-label {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.5px;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 10;
}

/* Override ad-label position for horizontal list ads */
.niriv-ad.niriv-ad-article-bottom .ad-label,
.niriv-ad.niriv-ad-cafe-article-bottom .ad-label {
    position: absolute !important;
    top: 8px !important;
    right: 24px !important;
    z-index: 11 !important;
}

.niriv-ad .ad-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.4;
}

.niriv-ad .ad-description {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.6;
}

.niriv-ad .ad-cta-button,
.niriv-ad .ad-cta-link {
    display: inline-block;
    padding: 10px 20px;
    background: #3b82f6;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s;
}

.niriv-ad .ad-cta-button:hover,
.niriv-ad .ad-cta-link:hover {
    background: #2563eb;
    color: #ffffff;
}

/* Common image styles for all ad types */
.niriv-ad .ad-image-container {
    margin-bottom: 12px;
    border-radius: 8px;
    overflow: hidden;
}

.niriv-ad .ad-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    max-height: none;
}
.niriv-ad.niriv-ad-search-sidebar .ad-image,
.niriv-ad.niriv-ad-post-sidebar .ad-image,
.niriv-ad.niriv-ad-cafe-sidebar .ad-image {
    max-height: 350px;
    object-fit: cover;
}


/* 1. Infinite Feed Style - Styled like post boxes */
.niriv-ad-infinite-feed {
    margin: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    padding-bottom: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    display: block;
    width: 100%;
    text-decoration: none;
    color: inherit;
}

/* Make the entire ad clickable with hover effect */
.niriv-ad-infinite-feed:hover {
    opacity: 0.95;
}

/* Remove any background, border, and shadow from inner elements - card box already has background */
.niriv-ad-infinite-feed .author-header,
.niriv-ad-infinite-feed .feed-content,
.niriv-ad-infinite-feed .feed-title,
.niriv-ad-infinite-feed .feed-excerpt,
.niriv-ad-infinite-feed .feed-image,
.niriv-ad-infinite-feed > div {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Ad description - bigger font, black color, normal weight */
.niriv-ad-infinite-feed .feed-excerpt {
    font-size: 15px !important;
    color: #000000 !important;
    font-weight: 400 !important;
    line-height: 1.5 !important;
}

/* Ensure image touches edges and has no bottom margin */
.niriv-ad-infinite-feed .feed-image {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    width: 100% !important;
}

/* Ensure image container touches both left and right edges */
.niriv-ad-infinite-feed > div:last-child {
    margin-left: -16px !important;
    margin-right: -16px !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    width: calc(100% + 32px) !important;
    overflow: hidden !important;
}

/* Ensure button has no bottom margin and touches bottom edge */
.niriv-ad-infinite-feed > div:last-child[style*="background: #3b82f6"],
.niriv-ad-infinite-feed > div[style*="background: #3b82f6"] {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    padding-bottom: 12px !important;
    padding-top: 12px !important;
    position: relative !important;
    bottom: 0 !important;
}

/* Ad box matches post box structure - uses feed-box-content for styling */
/* Ensure image touches bottom (no reactions bar) */
.feed-box[data-widget="infinite-feed-ad"] .feed-box-content .feed-image {
    margin-bottom: 0 !important;
    border-bottom-left-radius: 16px !important;
    border-bottom-right-radius: 16px !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

/* Ensure rounded-xl class maintains full border radius */
.feed-box[data-widget="infinite-feed-ad"].rounded-xl {
    border-radius: 12px !important;
}

/* Maintain border radius even with images */
.feed-box[data-widget="infinite-feed-ad"]:has(.feed-image) {
    border-radius: 12px !important;
}

/* Ensure no shadow appears after the image */
.feed-box[data-widget="infinite-feed-ad"] .feed-box-content:has(.feed-image) {
    border-radius: 12px !important;
    box-shadow: none !important;
}

/* Remove any pseudo-elements that might create shadows */
.feed-box[data-widget="infinite-feed-ad"] .feed-box-content::after,
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed::after,
.feed-box[data-widget="infinite-feed-ad"] .feed-image::after,
.feed-box[data-widget="infinite-feed-ad"] .feed-image::before,
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed > div::after,
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed > div::before {
    display: none !important;
    content: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

/* Remove any extra shadow or styling at the bottom */
.feed-box[data-widget="infinite-feed-ad"]::after {
    display: none !important;
    content: none !important;
}

.feed-box[data-widget="infinite-feed-ad"] .feed-box-content {
    margin: 0 !important;
    padding: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
    height: 100% !important;
    min-height: 100% !important;
    background: transparent !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: none !important;
    border-bottom: none !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
}

/* Remove any white space or shadow below the image - ensure last child has no spacing */
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed > div:last-child {
    margin: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    padding-bottom: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
    line-height: 0 !important;
    height: auto !important;
    min-height: 0 !important;
}

/* Make the ad link fill the container and use flexbox */
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    flex: 1 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
}

/* Remove any button styling - button has been removed */
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed > div[style*="background: #3b82f6"] {
    display: none !important;
}

/* Ensure image has rounded bottom corners to match container */
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed .feed-image {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-bottom-left-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
    margin: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    padding-bottom: 0 !important;
    display: block !important;
    vertical-align: bottom !important;
    line-height: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
    border: none !important;
    outline: none !important;
}

/* Remove any white space below image container - comprehensive rules */
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed > div:has(.feed-image),
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed > div[style*="calc(100% + 32px)"] {
    margin: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    padding-bottom: 0 !important;
    line-height: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    height: auto !important;
    min-height: 0 !important;
}

/* Remove border-radius and shadow from image container div specifically */
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed > div[style*="calc(100% + 32px)"] {
    border-radius: 0 !important;
    box-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
}

/* Ensure image has rounded bottom corners to match container */
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed .feed-image,
.feed-box[data-widget="infinite-feed-ad"] .niriv-ad-infinite-feed img {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-bottom-left-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
    box-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
}


/* Remove all top/bottom margin/padding from feed-content inside ad, keep only horizontal padding */
.feed-box[data-widget="infinite-feed-ad"] .feed-content {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
}

/* Ensure no bottom spacing on the ad link element and all children */
.niriv-ad-infinite-feed {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Remove borders, shadows, and bottom margins from all nested elements */
.niriv-ad-infinite-feed * {
    margin-bottom: 0 !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Exception: Keep button padding but no margin */
.niriv-ad-infinite-feed > div:last-child[style*="background: #3b82f6"] {
    margin-bottom: 0 !important;
}

/* Exception: Keep the ad badge background (the circular "Ad" icon) but remove borders/shadows */
.niriv-ad-infinite-feed .author-header div[style*="background-color: #f3f4f6"],
.niriv-ad-infinite-feed .author-header > div > div > div[style*="background-color"] {
    background-color: #f3f4f6 !important;
    border: none !important;
    box-shadow: none !important;
}

/* 2. Single Article Bottom - Horizontal List Style */
.niriv-ad.niriv-ad-article-bottom {
    max-width: 100% !important;
    margin: 30px 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    position: relative !important;
}

.niriv-ad.niriv-ad-article-bottom .ad-wrapper-horizontal.ad-link-wrapper {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 16px !important;
    padding: 16px !important;
    margin: 0 !important;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    text-decoration: none !important;
    color: inherit !important;
    transition: all 0.2s ease !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.niriv-ad.niriv-ad-article-bottom .ad-wrapper-horizontal.ad-link-wrapper:hover {
    box-shadow: 0 2px 4px 0 rgba(0,0,0,0.04) !important;
    border-color: #d1d5db !important;
}

.niriv-ad.niriv-ad-article-bottom .ad-image-left {
    flex-shrink: 0 !important;
    width: 120px !important;
    height: 90px !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    background: #f3f4f6 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.niriv-ad.niriv-ad-article-bottom .ad-image-left .ad-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}

.niriv-ad.niriv-ad-article-bottom .ad-content-right {
    flex: 1 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.niriv-ad.niriv-ad-article-bottom .ad-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    margin: 0 0 6px 0 !important;
    padding: 0 !important;
    color: #1f2937 !important;
    line-height: 1.4 !important;
}

.niriv-ad.niriv-ad-article-bottom .ad-description {
    margin: 0 !important;
    padding: 0 !important;
    color: #6b7280 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    font-weight: 400 !important;
}

/* 3. Search Sidebar Widget */
.niriv-ad-search-sidebar {
    max-width: 100%;
    margin: 15px 0;
    padding: 15px;
    background: #ffffff;
    border-left: 3px solid #3b82f6;
}

.niriv-ad-search-sidebar .ad-title {
    font-size: 16px;
    margin-bottom: 8px;
}

.niriv-ad-search-sidebar .ad-description {
    font-size: 13px;
    margin-bottom: 10px;
}

.niriv-ad-search-sidebar .ad-cta-link {
    padding: 6px 12px;
    font-size: 13px;
    background: transparent;
    color: #3b82f6;
    border: 1px solid #3b82f6;
}

.niriv-ad-search-sidebar .ad-cta-link:hover {
    background: #3b82f6;
    color: #ffffff;
}

/* 4. Search Result Web Style - Matches web result style exactly */
.niriv-ad-search-result-web {
    /* Uses same styles as web results - no special styling needed */
    margin: 0;
}

.niriv-ad-search-result-web .text-niriv-brand-700 {
    color: #1e40af;
}

.niriv-ad-search-result-web .text-niriv-brand-700:hover {
    text-decoration: underline;
}

/* 5. Single Post Sidebar */
.niriv-ad-post-sidebar {
    max-width: 100%;
    margin: 20px 0;
    padding: 18px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
}

.niriv-ad-post-sidebar .ad-title {
    font-size: 17px;
    margin-bottom: 10px;
}

.niriv-ad-post-sidebar .ad-cta-button {
    width: 100%;
    text-align: center;
    padding: 12px;
}

/* 6. Cafe Article Bottom - Horizontal List Style */
.niriv-ad.niriv-ad-cafe-article-bottom {
    max-width: 100% !important;
    margin: 25px 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    position: relative !important;
}

.niriv-ad.niriv-ad-cafe-article-bottom .ad-wrapper-horizontal.ad-link-wrapper {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 16px !important;
    padding: 16px !important;
    margin: 0 !important;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    text-decoration: none !important;
    color: inherit !important;
    transition: all 0.2s ease !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.niriv-ad.niriv-ad-cafe-article-bottom .ad-wrapper-horizontal.ad-link-wrapper:hover {
    box-shadow: 0 2px 4px 0 rgba(0,0,0,0.04) !important;
    border-color: #d1d5db !important;
}

.niriv-ad.niriv-ad-cafe-article-bottom .ad-image-left {
    flex-shrink: 0 !important;
    width: 120px !important;
    height: 90px !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    background: #f3f4f6 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.niriv-ad.niriv-ad-cafe-article-bottom .ad-image-left .ad-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}

.niriv-ad.niriv-ad-cafe-article-bottom .ad-content-right {
    flex: 1 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.niriv-ad.niriv-ad-cafe-article-bottom .ad-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    margin: 0 0 6px 0 !important;
    padding: 0 !important;
    color: #1f2937 !important;
    line-height: 1.4 !important;
}

.niriv-ad.niriv-ad-cafe-article-bottom .ad-description {
    margin: 0 !important;
    padding: 0 !important;
    color: #6b7280 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    font-weight: 400 !important;
}

/* 7. Single View Photo/Text Post - Horizontal Layout */
.niriv-ad-feed-post-inline {
    margin: 20px 0;
    padding: 20px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 2px 4px 0 rgba(0,0,0,0.04) !important;
    text-align: center !important;
    display: block !important;
    padding: 12px 20px !important;
    background: #3b82f6 !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: background 0.2s !important;
    margin-top: 12px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
}

.niriv-ad-feed-post-inline .ad-cta-button:hover {
    background: #2563eb !important;
    color: #ffffff !important;
}

/* Additional specificity for feed post inline button */
.niriv-ad-feed-post-inline .ad-content-right .ad-cta-button,
.niriv-ad-feed-post-inline .feed-post-inline-cta {
    width: 100% !important;
    text-align: center !important;
    display: block !important;
    padding: 12px 20px !important;
    background: #3b82f6 !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    margin-top: 12px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
}

.niriv-ad-feed-post-inline .ad-content-right .ad-cta-button:hover,
.niriv-ad-feed-post-inline .feed-post-inline-cta:hover {
    background: #2563eb !important;
    color: #ffffff !important;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .niriv-ad {
        margin: 15px 0;
        padding: 12px;
    }
    
    .niriv-ad .ad-title {
        font-size: 16px;
    }
    
    .niriv-ad .ad-description {
        font-size: 13px;
    }
    
    .niriv-ad.niriv-ad-article-bottom .ad-wrapper-horizontal.ad-link-wrapper,
    .niriv-ad.niriv-ad-cafe-article-bottom .ad-wrapper-horizontal.ad-link-wrapper {
        flex-direction: row !important;
        gap: 12px !important;
    }
    
    .niriv-ad.niriv-ad-article-bottom .ad-image-left,
    .niriv-ad.niriv-ad-cafe-article-bottom .ad-image-left {
        width: 100px !important;
        height: 75px !important;
        flex-shrink: 0 !important;
    }
    
    .niriv-ad.niriv-ad-article-bottom .ad-title,
    .niriv-ad.niriv-ad-cafe-article-bottom .ad-title {
        font-size: 15px !important;
    }
    
    .niriv-ad.niriv-ad-article-bottom .ad-description,
    .niriv-ad.niriv-ad-cafe-article-bottom .ad-description {
        font-size: 13px !important;
        font-weight: 400 !important;
    }
    
    .niriv-ad-feed-post-inline .ad-wrapper-horizontal {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .niriv-ad-feed-post-inline .ad-image-left {
        width: 100%;
        height: auto;
        max-height: 200px;
    }

    .niriv-ad-feed-post-inline .ad-image-left .ad-image {
        max-height: 200px;
    }
    
    .niriv-ad-feed-post-inline .ad-cta-button {
        width: 100% !important;
        text-align: center !important;
        display: block !important;
    }
    
    .niriv-ad-search-sidebar {
        margin: 10px 0;
    }
    
    .niriv-ad-post-sidebar {
        margin: 15px 0;
    }
}

@media (max-width: 480px) {
    .niriv-ad {
        padding: 10px;
    }
    
    .niriv-ad .ad-label {
        font-size: 9px;
        padding: 2px 4px;
    }
    
    .niriv-ad .ad-title {
        font-size: 15px;
    }
    
    .niriv-ad .ad-description {
        font-size: 12px;
    }
    
    .niriv-ad .ad-cta-button {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* Inline ad wrapper within content */
.niriv-inline-ad-wrapper {
    margin: 2rem 0 !important;
    clear: both;
}

.niriv-inline-ad-wrapper .article-bottom-ad-link,
.niriv-inline-ad-wrapper .cafe-article-bottom-ad-link {
    margin: 0 !important;
}

/* Ensure description is normal weight in inline ads */
.niriv-inline-ad-wrapper .article-bottom-ad-link p,
.niriv-inline-ad-wrapper .article-bottom-ad-content p,
.niriv-inline-ad-wrapper .cafe-article-bottom-ad-link p,
.niriv-inline-ad-wrapper .cafe-article-bottom-ad-content p {
    font-weight: 400 !important;
}

/* Ensure inline ads don't break prose styling */
.prose .niriv-inline-ad-wrapper {
    margin: 2rem 0 !important;
}

.prose .niriv-inline-ad-wrapper * {
    max-width: 100%;
}

