/**
 * Fix Thumbnail Display on Mobile for Custom Sections
 * Ensures proper layout for posts with thumbnails
 */

/* Mobile Thumbnail Layout Fix */
@media (max-width: 767px) {
    /* Container fixes */
    .custom-section .posts-list-thumbnail {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Post item container */
    .custom-section .post-item-thumbnail {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Link container - Flex layout */
    .custom-section .post-link-thumbnail {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        width: 100% !important;
        padding: 10px !important;
        gap: 10px !important;
        box-sizing: border-box !important;
    }
    
    /* Thumbnail wrapper - Fixed size */
    .custom-section .post-thumbnail-wrapper {
        display: block !important;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        width: 80px !important;
        height: 80px !important;
        min-width: 80px !important;
        max-width: 80px !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 6px !important;
        overflow: hidden !important;
        position: relative !important;
    }
    
    /* Thumbnail image */
    .custom-section .post-thumbnail-img,
    .custom-section .post-thumbnail-wrapper img {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Placeholder for missing images */
    .custom-section .post-thumbnail-placeholder {
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #f0f0f0 !important;
        font-size: 20px !important;
        color: #ccc !important;
    }
    
    /* Content wrapper - Flexible width */
    .custom-section .post-content-wrapper {
        display: block !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: auto !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Post title */
    .custom-section .post-title-thumbnail {
        display: block !important;
        display: -webkit-box !important;
        font-size: 14px !important;
        line-height: 1.4 !important;
        font-weight: 600 !important;
        margin: 0 0 5px 0 !important;
        padding: 0 !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        word-wrap: break-word !important;
    }
    
    /* Post excerpt */
    .custom-section .post-excerpt {
        display: block !important;
        display: -webkit-box !important;
        font-size: 12px !important;
        line-height: 1.4 !important;
        color: #666 !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        word-wrap: break-word !important;
    }
    
    /* Fix for WordPress generated images */
    .custom-section .post-thumbnail-wrapper .attachment-thumbnail,
    .custom-section .post-thumbnail-wrapper .attachment-medium,
    .custom-section .post-thumbnail-wrapper .attachment-large {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* Ensure no overflow */
    .custom-section .stat-box-content {
        overflow: hidden !important;
    }
}

/* Small mobile devices (max-width: 480px) */
@media (max-width: 480px) {
    .custom-section .post-thumbnail-wrapper {
        width: 70px !important;
        height: 70px !important;
        min-width: 70px !important;
        max-width: 70px !important;
    }
    
    .custom-section .post-link-thumbnail {
        padding: 8px !important;
        gap: 8px !important;
    }
    
    .custom-section .post-title-thumbnail {
        font-size: 13px !important;
    }
    
    .custom-section .post-excerpt {
        font-size: 11px !important;
    }
}

/* Tablet (768px to 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .custom-section .post-thumbnail-wrapper {
        width: 100px !important;
        height: 100px !important;
        min-width: 100px !important;
    }
    
    .custom-section .post-link-thumbnail {
        padding: 12px !important;
        gap: 12px !important;
    }
}

/* Debug helper - Remove in production */
.debug-border .post-thumbnail-wrapper {
    border: 2px solid red !important;
}
.debug-border .post-content-wrapper {
    border: 2px solid blue !important;
}