/**
 * AdSystem Styles v1.0 - 統一廣告樣式
 * 
 * 統一管理全站 Google AdSense 廣告樣式
 * 取代分散在各頁面的內聯廣告樣式
 */

/* ============================================
   廣告容器基礎樣式
   ============================================ */

.ad-wrapper {
    width: 100%;
    margin-bottom: 12px;
    background-color: transparent;
    padding: 15px 0;
    text-align: center;
    position: relative;
    min-height: 280px; /* 防止 CLS (Cumulative Layout Shift) */
    
    display: block;
    max-width: 100vw;
    overflow-x: hidden; /* 隱藏超出的邊緣，防止頁面左右搖晃 */
    box-sizing: border-box;
}

/* 電腦版樣式 */
@media (min-width: 962px) {
    .ad-wrapper {
        margin-bottom: 20px;
        max-width: 728px; /* 電腦版限制最大寬度 */
        margin-left: auto;
        margin-right: auto;
    }
}

/* ============================================
   廣告標籤
   ============================================ */

.ad-label {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

/* ============================================
   載入中動畫
   ============================================ */

.ad-loading {
    background: linear-gradient(90deg, #fff 25%, #f4f6f8 50%, #fff 75%);
    background-size: 200% 100%;
    animation: ad-loading-shimmer 1.5s infinite;
}

@keyframes ad-loading-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   AdSense 內部元素覆寫
   ============================================ */

.ad-wrapper ins.adsbygoogle {
    position: relative !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
}

/* ============================================
   移動設備優化
   ============================================ */

@media (max-width: 768px) {
    .ad-wrapper ins {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* 避免廣告 iframe 溢出屏幕 */
.ad-wrapper ins iframe {
    width: 100% !important;
    max-width: 100% !important;
}

/* ============================================
   Explore 手機版專用廣告尺寸 (320x100)
   ============================================ */

.ad-wrapper-mobile {
    width: 100%;
    margin-bottom: 12px;
    background-color: transparent;
    padding: 10px 0;
    text-align: center;
    position: relative;
    min-height: 100px; /* 320x100 廣告尺寸 */
    
    display: block;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* 手機版樣式 */
@media (max-width: 768px) {
    .ad-wrapper-mobile {
        min-height: 100px;
        max-width: 320px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .ad-wrapper-mobile ins.adsbygoogle {
        width: 320px !important;
        height: 100px !important;
        max-width: 100% !important;
    }
}

/* 電腦版隱藏手機廣告 */
@media (min-width: 769px) {
    .ad-wrapper-mobile {
        display: none;
    }
}

/* ============================================
   Merchant 頂部多尺寸廣告
   ============================================ */

.ad-wrapper-merchant-top {
    width: 100%;
    min-height: 250px;
    background: #f5f5f5; /* 背景色填充 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    text-align: center;
    position: relative;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* 廣告標籤置頂 */
.ad-wrapper-merchant-top .ad-label {
    margin-bottom: 8px;
}

/* AdSense 內部元素 */
.ad-wrapper-merchant-top ins.adsbygoogle {
    display: block !important;
    margin: 0 auto !important;
    max-width: 100% !important;
}

/* 手機版隱藏（另有專屬手機廣告） */
@media (max-width: 768px) {
    .ad-wrapper-merchant-top {
        display: none;
    }
}

/* ============================================
   舊版兼容性樣式 (deprecated)
   ============================================ */

/* 
 * .google-ad-container 為舊版遺留類名
 * 保留以下樣式以確保向後兼容
 */
.google-ad-container ins {
    width: 100% !important;
    max-width: 100% !important;
}

.google-ad-container ins iframe {
    width: 100% !important;
    max-width: 100% !important;
}

@media (max-width: 768px) {
    .google-ad-container ins {
        width: 100% !important;
        max-width: 100% !important;
    }
}
