/**
 * 自動注入商品推薦樣式
 * 
 * @package Uni_Shopee_Affiliate_TW
 * @since 1.2.0
 */

/* 自動注入商品推薦樣式 */
.uni-shopee-auto-inject {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid #ff6b35;
}

.uni-shopee-auto-inject .inject-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.uni-shopee-auto-inject .inject-title::before {
    content: "🛍️";
    margin-right: 8px;
}

.uni-shopee-auto-inject .inject-keywords {
    font-size: 12px;
    color: #666;
    margin-bottom: 15px;
}

.uni-shopee-auto-inject .inject-keywords::before {
    content: "關鍵字: ";
    font-weight: bold;
}

/* 自動注入容器 - 防止布局破壞 */
.uni-shopee-auto-inject-container {
    margin: 20px 0 !important;
    padding: 0 !important;
    clear: both !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* 確保注入的商品卡片不會溢出 */
.uni-shopee-auto-inject-container .shopee-products-grid,
.uni-shopee-auto-inject-container .shopee-product-card,
.uni-shopee-auto-inject-container .mercari-products-grid {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* 修正可能的浮動問題 */
.uni-shopee-auto-inject-container::before,
.uni-shopee-auto-inject-container::after {
    content: "";
    display: table;
    clear: both;
}

/* 確保在不同主題下的相容性 */
.uni-shopee-auto-inject-container img {
    max-width: 100% !important;
    height: auto !important;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .uni-shopee-auto-inject {
        margin: 15px 0;
        padding: 12px;
    }
    
    .uni-shopee-auto-inject .inject-title {
        font-size: 14px;
    }
    
    .uni-shopee-auto-inject-container {
        margin: 15px 0 !important;
    }
}

/* 自動注入容器基本樣式 */
.uni-shopee-auto-injected {
    margin: 30px 0;
    padding: 0;
    clear: both;
    position: relative;
    background: transparent;
}

/* 注入標籤樣式 */
.uni-shopee-auto-injected .injection-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
    text-align: center;
    font-weight: 500;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.uni-shopee-auto-injected .injection-label::before,
.uni-shopee-auto-injected .injection-label::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 1px;
    background: #ddd;
    vertical-align: middle;
    margin: 0 10px;
}

/* 標準樣式模式 */
.uni-shopee-auto-injected.normal-style {
    border: none;
    background: transparent;
}

/* 簡約樣式模式 */
.uni-shopee-auto-injected.minimal-style {
    border: none;
    background: transparent;
    margin: 20px 0;
}

.uni-shopee-auto-injected.minimal-style .injection-label {
    font-size: 12px;
    margin-bottom: 8px;
    opacity: 0.6;
}

.uni-shopee-auto-injected.minimal-style .injection-label::before,
.uni-shopee-auto-injected.minimal-style .injection-label::after {
    width: 20px;
    margin: 0 8px;
}

/* 突出樣式模式 */
.uni-shopee-auto-injected.highlighted-style {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 24px;
    margin: 40px 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.uni-shopee-auto-injected.highlighted-style::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.uni-shopee-auto-injected.highlighted-style .injection-label {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 16px;
    font-size: 15px;
}

.uni-shopee-auto-injected.highlighted-style .injection-label::before,
.uni-shopee-auto-injected.highlighted-style .injection-label::after {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    height: 2px;
}

/* 確保注入的短碼內容正常顯示 */
.uni-shopee-auto-injected .shopee-products-container,
.uni-shopee-auto-injected .uni-product-grid,
.uni-shopee-auto-injected .uni-product-slider {
    margin: 0;
    padding: 0;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .uni-shopee-auto-injected {
        margin: 20px 0;
    }
    
    .uni-shopee-auto-injected.highlighted-style {
        padding: 16px;
        margin: 24px 0;
        border-radius: 8px;
    }
    
    .uni-shopee-auto-injected .injection-label {
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .uni-shopee-auto-injected .injection-label::before,
    .uni-shopee-auto-injected .injection-label::after {
        width: 20px;
        margin: 0 8px;
    }
    
    .uni-shopee-auto-injected.minimal-style {
        margin: 16px 0;
    }
    
    .uni-shopee-auto-injected.minimal-style .injection-label {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    .uni-shopee-auto-injected.minimal-style .injection-label::before,
    .uni-shopee-auto-injected.minimal-style .injection-label::after {
        width: 15px;
        margin: 0 6px;
    }
}

@media (max-width: 480px) {
    .uni-shopee-auto-injected {
        margin: 16px 0;
    }
    
    .uni-shopee-auto-injected.highlighted-style {
        padding: 12px;
        margin: 20px 0;
        border-radius: 6px;
    }
    
    .uni-shopee-auto-injected .injection-label {
        font-size: 12px;
        margin-bottom: 8px;
    }
    
    .uni-shopee-auto-injected .injection-label::before,
    .uni-shopee-auto-injected .injection-label::after {
        width: 15px;
        margin: 0 6px;
    }
}

/* 深色模式支援 */
@media (prefers-color-scheme: dark) {
    .uni-shopee-auto-injected.highlighted-style {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .uni-shopee-auto-injected .injection-label {
        color: #a0aec0;
    }
    
    .uni-shopee-auto-injected .injection-label::before,
    .uni-shopee-auto-injected .injection-label::after {
        background: #4a5568;
    }
    
    .uni-shopee-auto-injected.highlighted-style .injection-label {
        color: #90cdf4;
    }
    
    .uni-shopee-auto-injected.highlighted-style .injection-label::before,
    .uni-shopee-auto-injected.highlighted-style .injection-label::after {
        background: linear-gradient(90deg, #90cdf4 0%, #a78bfa 100%);
    }
}

/* 與主題整合 */
.uni-shopee-auto-injected {
    font-family: inherit;
    line-height: inherit;
}

.uni-shopee-auto-injected * {
    box-sizing: border-box;
}

/* 避免與主題樣式衝突 */
.uni-shopee-auto-injected .injection-label {
    all: unset;
    font-size: 14px !important;
    color: #666 !important;
    margin-bottom: 12px !important;
    text-align: center !important;
    font-weight: 500 !important;
    opacity: 0.8 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    display: block !important;
    position: relative !important;
}

/* 確保注入內容不會被主題樣式覆蓋 */
.uni-shopee-auto-injected .shopee-products-container {
    all: unset;
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 動畫效果 */
.uni-shopee-auto-injected {
    animation: fadeInUp 0.6s ease-out;
}

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

/* 載入狀態 */
.uni-shopee-auto-injected.loading {
    opacity: 0.6;
    pointer-events: none;
}

.uni-shopee-auto-injected.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 錯誤狀態 */
.uni-shopee-auto-injected.error {
    border: 1px dashed #dc3545;
    background: #f8d7da;
    color: #721c24;
    padding: 16px;
    border-radius: 6px;
    text-align: center;
}

.uni-shopee-auto-injected.error::before {
    content: '⚠️ ';
    font-size: 16px;
}

/* 隱藏模式（用於測試） */
.uni-shopee-auto-injected.hidden {
    display: none !important;
}

/* 調試模式 */
.uni-shopee-auto-injected.debug {
    border: 2px dashed #ffc107;
    background: #fff3cd;
    position: relative;
}

.uni-shopee-auto-injected.debug::before {
    content: '🔧 AUTO INJECT DEBUG MODE';
    position: absolute;
    top: -12px;
    left: 12px;
    background: #ffc107;
    color: #212529;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: bold;
    border-radius: 3px;
    z-index: 10;
}

/* 特殊主題相容性 */
.entry-content .uni-shopee-auto-injected,
.post-content .uni-shopee-auto-injected,
.article-content .uni-shopee-auto-injected {
    margin: 30px auto !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* Gutenberg 編輯器相容性 */
.wp-block .uni-shopee-auto-injected {
    margin: 30px 0 !important;
}

/* AMP 相容性 */
amp-story .uni-shopee-auto-injected {
    display: none !important;
}

/* 列印樣式 */
@media print {
    .uni-shopee-auto-injected {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .uni-shopee-auto-injected .injection-label::before,
    .uni-shopee-auto-injected .injection-label::after {
        display: none;
    }
}
