/**
 * ┌─────────────────────────────────────────────────────────────┐
 * │  ToolBox Ad Styles — CLS-safe, Responsive, Performance-first │
 * └─────────────────────────────────────────────────────────────┘
 */

/* ── Base Ad Slot ─────────────────────────────────────────── */
.tb-ad-slot {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: opacity, transform;
}

.tb-ad-slot.tb-ad-active {
    opacity: 1;
}

.tb-ad-slot:not(.tb-ad-active) {
    opacity: 0.7;
}

/* Placeholder shimmer while loading */
.tb-ad-placeholder {
    animation: tb-ad-pulse 2s ease-in-out infinite;
}

@keyframes tb-ad-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* ── Ad Content (real ad) ─────────────────────────────────── */
.tb-ad-content {
    display: none;
    width: 100%;
    text-align: center;
}

.tb-ad-content iframe,
.tb-ad-content ins {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

/* ── Homepage Ad Specifics ────────────────────────────────── */
.tb-ad-hp-native-1,
.tb-ad-hp-native-2 {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.tb-ad-hp-footer {
    max-width: 728px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Tool Page Ad Specifics ───────────────────────────────── */
.tb-ad-tool-upload,
.tb-ad-tool-result,
.tb-ad-result-primary {
    max-width: 100%;
}

/* Result primary zone — styled as a card */
.tb-ad-result-primary {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    border: 1px solid #bae6fd !important;
}

/* ── Processing Ad ────────────────────────────────────────── */
.tb-ad-processing {
    min-height: 60px !important;
    max-height: 100px;
    margin: 12px 0 !important;
    border-style: solid !important;
}

.tb-ad-processing .tb-ad-placeholder {
    animation: none;
    opacity: 0.35;
}

/* ── Mobile Sticky Banner ─────────────────────────────────── */
.tb-mobile-sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
}

.tb-mobile-sticky.tb-sticky-visible {
    transform: translateY(0);
}

.tb-mobile-sticky.tb-sticky-hidden {
    transform: translateY(100%);
}

.tb-sticky-close {
    position: absolute;
    top: -14px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    color: #64748b;
    font-size: 12px;
    padding: 0;
    transition: all 0.2s;
}

.tb-sticky-close:hover {
    background: #f1f5f9;
    color: #334155;
}

.tb-sticky-close:active {
    transform: scale(0.92);
}

.tb-sticky-ad {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    text-align: center;
}

/* Body padding compensation when sticky is visible */
body.tb-sticky-active {
    padding-bottom: 64px;
}

/* ── Ad Label ─────────────────────────────────────────────── */
.tb-ad-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #94a3b8;
    margin-bottom: 4px;
    display: block;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .tb-ad-slot {
        margin: 16px 0 !important;
    }
    
    .tb-ad-hp-native-1,
    .tb-ad-hp-native-2,
    .tb-ad-hp-footer {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Reduce height on mobile for better density */
    .tb-ad-tool-upload,
    .tb-ad-tool-result {
        min-height: 200px !important;
    }
    
    .tb-ad-tool-result-sm,
    .tb-ad-tool-related {
        min-height: 200px !important;
    }
}

@media (max-width: 480px) {
    .tb-mobile-sticky {
        min-height: 50px;
    }
    
    .tb-sticky-close {
        width: 24px;
        height: 24px;
        top: -12px;
        right: 6px;
        font-size: 10px;
    }
    
    body.tb-sticky-active {
        padding-bottom: 58px;
    }
}

/* ── Print Hide ───────────────────────────────────────────── */
@media print {
    .tb-ad-slot,
    .tb-mobile-sticky {
        display: none !important;
    }
}

/* ── Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .tb-ad-slot,
    .tb-mobile-sticky,
    .tb-sticky-close {
        transition: none !important;
        animation: none !important;
    }
}

/* ── Dark Mode Support (if added later) ───────────────────── */
@media (prefers-color-scheme: dark) {
    .tb-ad-slot {
        background: #1e293b;
        border-color: #334155;
    }
    .tb-ad-placeholder span,
    .tb-ad-placeholder i {
        color: #64748b;
    }
    .tb-mobile-sticky {
        background: #0f172a;
        border-top-color: #334155;
    }
    .tb-sticky-close {
        background: #1e293b;
        border-color: #334155;
        color: #94a3b8;
    }
}

/* ── Site Footer ──────────────────────────────────────────── */
.site-footer {
    margin-top: 48px;
    padding: 40px 24px 24px;
    border-top: 1px solid var(--tb-border, #e2e8f0);
    background: var(--tb-bg-secondary, #f8f9fa);
}

.footer-inner {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.footer-brand {
    margin-bottom: 20px;
}

.footer-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--tb-text-primary, #1e293b);
}

.footer-tagline {
    font-size: 13px;
    color: var(--tb-text-secondary, #64748b);
    margin-top: 4px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px 24px;
    margin-bottom: 20px;
}

.footer-links a {
    font-size: 13px;
    color: var(--tb-text-secondary, #64748b);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--tb-primary, #0071e3);
}

.footer-copy {
    font-size: 12px;
    color: var(--tb-text-tertiary, #94a3b8);
}

@media (max-width: 768px) {
    .site-footer {
        padding: 32px 16px 16px;
        margin-top: 32px;
    }
    .footer-links {
        gap: 12px 16px;
    }
}

/* ── Ad Density Warning (dev only) ────────────────────────── */
.tb-ad-density-warning {
    position: fixed;
    top: 0;
    right: 0;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    z-index: 99999;
    display: none;
}
