/* Ad Layout CSS for Downloader.org - Speedtest.net Style */

/* Main ad layout container */
.ad-layout {
    display: grid;
    grid-template-columns: 160px 1fr 160px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "left top right"
        "left main right"
        "left bottom right";
    gap: 8px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px;
    min-height: 600px;
}

/* Large desktop - wider sidebars */
@media (min-width: 1400px) {
    .ad-layout {
        grid-template-columns: 300px 1fr 300px;
        gap: 10px;
        padding: 15px;
    }

    .ad-unit-sidebar {
        width: 300px;
    }
}

/* Left sidebar ad */
.ad-sidebar-left {
    grid-area: left;
    position: sticky;
    top: 80px;
    height: fit-content;
    align-self: start;
    display: flex;
    justify-content: flex-end;
}

/* Right sidebar ad */
.ad-sidebar-right {
    grid-area: right;
    position: sticky;
    top: 80px;
    height: fit-content;
    align-self: start;
    display: flex;
    justify-content: flex-start;
}

/* Top banner ad */
.ad-top-banner {
    grid-area: top;
    text-align: center;
    min-height: 90px;
}

/* Bottom banner ad */
.ad-bottom-banner {
    grid-area: bottom;
    text-align: center;
    min-height: 90px;
}

/* Main content area */
.ad-main-content {
    grid-area: main;
    min-height: 400px;
}

/* Ad unit container */
.ad-unit {
    background: #1a1a1a;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ad-unit a {
    display: block;
    line-height: 0;
}

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

.ad-unit-sidebar {
    width: 160px;
    min-height: 600px;
}

.ad-unit-banner {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    margin: 0 auto;
}

.ad-unit-mobile {
    width: 100%;
    max-width: 320px;
    min-height: 100px;
    margin: 0 auto;
}

/* Mobile top/middle/bottom ads - hidden on desktop */
.ad-mobile-top,
.ad-mobile-bottom {
    display: none;
    text-align: center;
    margin: 10px 0;
    padding: 10px 15px;
}

.ad-mobile-middle {
    display: none;
    text-align: center;
    margin: 20px 0;
    padding: 15px;
}

/* Mobile breakpoint - hide sidebars, show mobile ads */
@media (max-width: 768px) {
    .ad-layout {
        display: block;
        padding: 10px;
    }

    .ad-sidebar-left,
    .ad-sidebar-right {
        display: none;
    }

    .ad-top-banner,
    .ad-bottom-banner {
        display: none;
    }

    .ad-mobile-top,
    .ad-mobile-middle,
    .ad-mobile-bottom {
        display: block;
    }

    .ad-main-content {
        margin: 0;
    }
}

/* Paid user - no ads */
.no-ads .ad-sidebar-left,
.no-ads .ad-sidebar-right,
.no-ads .ad-top-banner,
.no-ads .ad-bottom-banner,
.no-ads .ad-mobile-top,
.no-ads .ad-mobile-middle,
.no-ads .ad-mobile-bottom {
    display: none;
}

.no-ads.ad-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
}

/* Wide layout variant - responsive ad display */
.ad-layout-wide {
    display: block;
    max-width: none;
}

/* Hide desktop ad containers on mobile */
.ad-layout-wide .ad-sidebar-left,
.ad-layout-wide .ad-sidebar-right,
.ad-layout-wide .ad-top-banner,
.ad-layout-wide .ad-bottom-banner {
    display: none;
}

/* Show mobile ad containers */
.ad-layout-wide .ad-mobile-top,
.ad-layout-wide .ad-mobile-middle,
.ad-layout-wide .ad-mobile-bottom {
    display: block;
}

/* Medium screens - larger mobile ads */
@media (min-width: 728px) {
    .ad-layout-wide .ad-mobile-top .ad-unit-mobile,
    .ad-layout-wide .ad-mobile-middle .ad-unit-mobile,
    .ad-layout-wide .ad-mobile-bottom .ad-unit-mobile {
        max-width: 728px;
        min-height: 90px;
    }
}

/* Wide screens - show sidebars + grid banners, hide mobile ads */
@media (min-width: 1100px) {
    .ad-layout-wide {
        display: grid;
        grid-template-columns: 160px 1fr 160px;
        grid-template-areas:
            "left top right"
            "left main right"
            "left bottom right";
        max-width: 1400px;
        margin: 0 auto;
    }

    .ad-layout-wide .ad-sidebar-left,
    .ad-layout-wide .ad-sidebar-right {
        display: flex;
    }

    .ad-layout-wide .ad-top-banner,
    .ad-layout-wide .ad-bottom-banner {
        display: block;
    }

    .ad-layout-wide .ad-mobile-top,
    .ad-layout-wide .ad-mobile-middle,
    .ad-layout-wide .ad-mobile-bottom {
        display: none;
    }
}

/* Extra wide screens - wider sidebars */
@media (min-width: 1400px) {
    .ad-layout-wide {
        grid-template-columns: 300px 1fr 300px;
        max-width: 1800px;
    }
}

/* Loading Ad Styles */
.loading-ad-container {
    margin: 20px auto;
    text-align: center;
    padding: 15px;
}

.loading-ad-container .ad-unit {
    margin: 0 auto;
}

/* Content wrapper inside ad layout */
.ad-content-wrapper {
    background: transparent;
    min-height: 300px;
}

/* Hide element when sidebars appear (1100px+) */
.ad-hide-wide {
    display: block;
}

@media (min-width: 1100px) {
    .ad-hide-wide {
        display: none !important;
    }
}

/* Result Ad Layout - Sidebars around results */
.result-ad-layout {
    min-height: auto;
    padding: 0;
}

.result-ad-layout .ad-main-content {
    min-height: auto;
}

/* Result layout - simplified grid (just sidebars + main) */
.result-ad-layout {
    grid-template-rows: 1fr;
    grid-template-areas: "left main right";
}

/* Ad below input */
.ad-below-input {
    text-align: center;
    width: 100%;
}

.ad-below-input .ad-unit {
    margin: 0 auto;
    background: transparent;
}

/* Hide ad-below-input on mobile, show rectangle ad instead */
@media (max-width: 767px) {
    .ad-below-input .ad-unit-banner img {
        max-width: 300px;
        height: auto;
    }
}

/* Result layout responsive */
@media (max-width: 1099px) {
    .result-ad-layout {
        display: block;
    }

    .result-ad-layout .ad-sidebar-left,
    .result-ad-layout .ad-sidebar-right {
        display: none;
    }
}

@media (min-width: 1100px) {
    .result-ad-layout {
        display: grid;
        grid-template-columns: 160px 1fr 160px;
        grid-template-areas: "left main right";
        gap: 15px;
    }

    .result-ad-layout .ad-sidebar-left,
    .result-ad-layout .ad-sidebar-right {
        display: flex;
    }
}

@media (min-width: 1400px) {
    .result-ad-layout {
        grid-template-columns: 200px 1fr 200px;
    }
}

/* Fixed Sidebar Ads - positioned next to content */
.ad-sidebar-fixed {
    position: fixed;
    top: 100px;
    z-index: 100;
    display: none;
}

/* Position sidebars relative to center - next to the ~960px content area */
.ad-sidebar-fixed-left {
    left: calc(50% - 480px - 170px); /* half content width + ad width + gap */
}

.ad-sidebar-fixed-right {
    right: calc(50% - 480px - 170px);
}

.ad-sidebar-fixed .ad-unit-sidebar {
    background: transparent;
}

/* Show fixed sidebars only on wide screens where there's room (content + 2 sidebars + gaps) */
@media (min-width: 1320px) {
    .ad-sidebar-fixed {
        display: block;
    }

    /* Constrain main content to not overflow behind fixed sidebars */
    .main-container,
    #result,
    #postList,
    #postListWrapper {
        max-width: 960px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Ensure container class is also constrained */
    .container {
        max-width: 960px !important;
    }
}

/* On very wide screens, keep ads close to content, don't drift to edges */
@media (min-width: 1600px) {
    .ad-sidebar-fixed-left {
        left: calc(50% - 500px - 170px);
    }
    .ad-sidebar-fixed-right {
        right: calc(50% - 500px - 170px);
    }
}

/* HTML Ad Styles */
.ad-html {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    font-family: Arial, sans-serif;
    text-decoration: none;
    color: inherit;
    display: block;
}

.ad-html:hover {
    text-decoration: none;
    color: inherit;
}

/* Banner Ad (728x90 desktop, 320x100 mobile) */
.ad-banner {
    max-width: 728px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 4px solid #3b82f6;
    margin: 0 auto;
}

.ad-banner-logo {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    flex-shrink: 0;
}

.ad-banner-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.ad-banner-headline {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ad-banner-features {
    font-size: 10px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ad-banner-price {
    text-align: center;
    background: #f0f9ff !important;
    border: 2px solid #3b82f6 !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
    flex-shrink: 0;
    box-shadow: none !important;
    line-height: 1.2 !important;
}

.ad-banner-price-label {
    font-size: 10px !important;
    color: #64748b !important;
    display: block;
    line-height: 1.2 !important;
}

.ad-banner-price-value {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #3b82f6 !important;
    display: block;
    line-height: 1.2 !important;
}

.ad-banner-cta {
    background: #3b82f6 !important;
    color: #fff !important;
    padding: 8px 16px !important;
    border-radius: 5px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap;
    flex-shrink: 0;
    border: none !important;
    box-shadow: none !important;
    text-decoration: none !important;
    line-height: 1.2 !important;
    display: inline-block !important;
}

/* Mobile banner - responsive height */
@media (max-width: 767px) {
    .ad-banner {
        max-width: 100%;
        min-height: 60px;
        height: auto;
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 10px 8px;
        justify-content: flex-start;
        align-items: center;
    }

    .ad-banner-logo {
        font-size: 16px;
        font-weight: 700;
        white-space: nowrap;
        flex-shrink: 0;
        order: 1;
    }

    .ad-banner-content {
        display: block;
        flex: 1 1 auto;
        min-width: 120px;
        text-align: left;
        order: 2;
    }

    .ad-banner-headline {
        font-size: 13px;
        margin-bottom: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.3;
    }

    /* Hide features on mobile to reduce clutter */
    .ad-banner-features {
        display: none;
    }

    .ad-banner-price {
        padding: 4px 8px;
        border-width: 1px;
        flex-shrink: 0;
        order: 3;
        min-width: 70px;
    }

    /* Hide price label on mobile */
    .ad-banner-price-label {
        display: none;
    }

    .ad-banner-price-value {
        font-size: 14px;
    }

    .ad-banner-cta {
        padding: 6px 12px;
        font-size: 11px;
        flex-shrink: 0;
        white-space: nowrap;
        order: 4;
        min-width: 70px;
    }
}

/* Sidebar Ad (160x600) */
.ad-sidebar {
    width: 160px;
    padding: 15px 10px;
    text-align: center;
    border-top: 6px solid #3b82f6;
}

.ad-sidebar-logo {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 5px;
}

.ad-sidebar-tagline {
    font-size: 10px;
    color: #64748b;
    margin-bottom: 15px;
}

.ad-sidebar-headline {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 15px;
    line-height: 1.3;
}

.ad-sidebar-features {
    text-align: left;
    margin: 0 5px 20px;
}

.ad-sidebar-feature {
    font-size: 11px;
    color: #475569;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ad-sidebar-feature::before {
    content: "";
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
}

.ad-sidebar-price {
    background: #f0f9ff;
    border: 2px solid #3b82f6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
}

.ad-sidebar-price-label {
    font-size: 10px;
    color: #64748b;
}

.ad-sidebar-price-value {
    font-size: 24px;
    font-weight: 700;
    color: #3b82f6;
}

.ad-sidebar-price-period {
    font-size: 10px;
    color: #64748b;
}

.ad-sidebar-cta {
    display: block;
    background: #3b82f6;
    color: #fff;
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 15px;
}

.ad-sidebar-trust {
    font-size: 10px;
    color: #64748b;
}
