/**
 * TradingTeaching Ad System Styles
 * Version: 2.0.1 - Self-Promotional Focus
 */

/* =========================================
   HIDE EMPTY AD CONTAINERS
   ========================================= */

.ad-container:empty {
    display: none !important;
}

/* =========================================
   AD CONTAINER BASE STYLES
   ========================================= */

.ad-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(0, 212, 170, 0.15);
    border-radius: 8px;
    overflow: hidden;
    box-sizing: border-box;
}

.ad-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 170, 0.4), transparent);
}

/* =========================================
   AD LOADING STATE
   ========================================= */

.ad-loading {
    min-height: 90px;
}

.ad-loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 212, 170, 0.2);
    border-top-color: #00d4aa;
    border-radius: 50%;
    animation: ad-spinner 0.6s linear infinite;
}

@keyframes ad-spinner {
    to { transform: rotate(360deg); }
}

/* =========================================
   AD LABEL
   ========================================= */

.ad-label {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 2px 8px;
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    z-index: 10;
}

/* =========================================
   SELF-PROMOTIONAL ADS
   ========================================= */

.ad-self-promo {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(0, 212, 170, 0.2);
}

.self-promo-ad {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    height: 100%;
    padding: 15px;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.self-promo-ad:hover {
    background: rgba(0, 212, 170, 0.05);
}

/* Ad Badge */
.ad-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0a0a14;
    background: linear-gradient(135deg, #00d4aa 0%, #00a88a 100%);
    border-radius: 4px;
    z-index: 10;
}

.ad-badge-inline {
    padding: 3px 8px;
    margin-right: 10px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0a0a14;
    background: #00d4aa;
    border-radius: 3px;
}

/* Image Section */
.self-promo-image {
    flex-shrink: 0;
    width: 100px;
    height: auto;
}

.self-promo-image img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid rgba(0, 212, 170, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Content Section */
.self-promo-content {
    flex: 1;
    min-width: 0;
}

.self-promo-content.full-width {
    text-align: center;
}

.self-promo-icon {
    display: block;
    font-size: 32px;
    margin-bottom: 8px;
}

.self-promo-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
}

.self-promo-desc {
    margin: 0 0 12px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.self-promo-cta {
    display: inline-block;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0a0a14;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.self-promo-ad:hover .self-promo-cta {
    transform: translateX(3px);
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.4);
}

/* =========================================
   BANNER ADS (Horizontal)
   ========================================= */

.self-promo-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 100%;
    padding: 0 20px;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.self-promo-banner:hover {
    background: rgba(0, 212, 170, 0.05);
}

.banner-icon {
    font-size: 20px;
}

.banner-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
}

.banner-divider {
    color: rgba(255, 255, 255, 0.3);
}

.banner-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.banner-cta {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0a0a14;
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.self-promo-banner:hover .banner-cta {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(0, 212, 170, 0.3);
}

/* =========================================
   PLACEMENT-SPECIFIC STYLES
   ========================================= */

/* Header Banner */
.ad-container[id^="ad-header"] {
    margin: 10px auto 20px;
    max-width: 728px;
}

/* Sidebar Ads */
.ad-container[id^="ad-sidebar"] {
    margin: 0 auto 20px;
    max-width: 300px;
}

/* Sticky Sidebar */
.ad-sticky {
    position: sticky !important;
    z-index: 100;
}

/* In-Content Ads */
.ad-in-content {
    margin: 30px auto;
    max-width: 100%;
    clear: both;
}

/* Footer Banner */
.ad-container[id^="ad-footer"] {
    margin: 30px auto 20px;
    max-width: 728px;
}

/* =========================================
   MOBILE STICKY AD
   ========================================= */

.ad-mobile-sticky {
    position: fixed;
    bottom: -100px;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    padding: 8px;
    background: linear-gradient(180deg, rgba(10, 10, 20, 0.97) 0%, rgba(10, 10, 20, 1) 100%);
    border-top: 1px solid rgba(0, 212, 170, 0.3);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    transition: bottom 0.3s ease;
}

.ad-mobile-sticky.ad-visible {
    bottom: 0;
}

.ad-mobile-sticky .ad-container {
    margin: 0;
    background: transparent;
    border: none;
}

.ad-mobile-sticky .ad-container::before {
    display: none;
}

.ad-close-btn {
    position: absolute;
    top: -12px;
    right: 15px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
    background: #ff4757;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.ad-close-btn:hover {
    background: #ff6b7a;
    transform: scale(1.1);
}

/* =========================================
   THIRD-PARTY AD STYLES (Phase 2)
   ========================================= */

.third-party-ad {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    height: 100%;
    padding: 15px;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
}

.third-party-image {
    max-width: 100px;
    max-height: 80px;
    object-fit: contain;
}

.third-party-content h4 {
    margin: 0 0 5px;
    font-size: 15px;
    color: #ffffff;
}

.third-party-content p {
    margin: 0 0 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.third-party-cta {
    display: inline-block;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #0a0a14;
    background: #00d4aa;
    border-radius: 4px;
}

/* =========================================
   RESPONSIVE STYLES
   ========================================= */

/* Tablet */
@media (max-width: 768px) {
    .ad-container[id^="ad-header"],
    .ad-container[id^="ad-footer"] {
        max-width: 468px;
    }

    .self-promo-ad {
        padding: 12px;
        gap: 12px;
    }

    .self-promo-image {
        width: 70px;
    }

    .self-promo-title {
        font-size: 14px;
    }

    .self-promo-desc {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }

    .banner-desc {
        max-width: 150px;
    }

    .ad-sticky[id="ad-sidebar-sticky"] {
        display: none;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .ad-container {
        margin: 15px auto;
        border-radius: 6px;
    }

    .ad-container[id^="ad-header"],
    .ad-container[id^="ad-footer"] {
        max-width: 320px;
    }

    .self-promo-ad {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }

    .self-promo-image {
        width: 80px;
    }

    .self-promo-title {
        font-size: 15px;
    }

    .self-promo-desc {
        display: none;
    }

    .self-promo-content.full-width .self-promo-desc {
        display: block;
        -webkit-line-clamp: 1;
    }

    /* Banner mobile layout */
    .self-promo-banner {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 12px;
    }

    .banner-divider,
    .banner-desc {
        display: none;
    }

    .banner-title {
        font-size: 12px;
    }

    .banner-cta {
        padding: 5px 12px;
        font-size: 10px;
    }

    .ad-container[id="ad-sidebar-sticky"] {
        display: none !important;
    }
}

/* =========================================
   PRINT STYLES
   ========================================= */

@media print {
    .ad-container,
    .ad-mobile-sticky {
        display: none !important;
    }
}

/* =========================================
   ANIMATIONS
   ========================================= */

.ad-loaded {
    animation: adFadeIn 0.4s ease forwards;
}

@keyframes adFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   ACCESSIBILITY
   ========================================= */

.ad-container:focus-within {
    outline: 2px solid #00d4aa;
    outline-offset: 2px;
}

.self-promo-ad:focus,
.self-promo-banner:focus {
    outline: 2px solid #00d4aa;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .ad-loading::after {
        animation: none;
    }

    .ad-loaded {
        animation: none;
    }

    .ad-mobile-sticky {
        transition: none;
    }
}

/* =========================================
   HIGH CONTRAST MODE
   ========================================= */

@media (prefers-contrast: high) {
    .ad-container {
        border: 2px solid #00d4aa;
    }

    .self-promo-title {
        color: #ffffff;
    }

    .self-promo-desc {
        color: #cccccc;
    }
}
