/* 
 * 前台圖片自適應縮放樣式
 * 這個文件包含所有關於圖片響應式顯示的樣式
 * 使用類別來控制不同場景下的圖片行為
 */

/* 基礎圖片樣式：應用到所有圖片 */
.img-responsive {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 容器內部的圖片自動適應 */
.img-container {
    width: 100%;
    position: relative;
    overflow: hidden;
}

.img-container img {
    width: 100%;
    height: auto;
    display: block;
}

/* 不同的對象擬合模式 */
.img-cover {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.img-contain {
    object-fit: contain;
    width: 100%;
    height: 100%;
    max-width: 100%;
    margin: 0 auto;
    display: block;
    background-color: #000;
    border: 2px solid var(--dark-bg-2);
    border-radius: 10px;
}

.img-fill {
    object-fit: fill;
    width: 100%;
    height: 100%;
}

.img-scale-down {
    object-fit: scale-down;
    width: 100%;
    height: 100%;
}

/* 按比例固定的容器 */
.img-ratio {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.img-ratio::before {
    content: "";
    display: block;
    padding-top: 56.25%; /* 16:9比例 */
}

.img-ratio img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 特定比例的類別 */
.ratio-1-1::before {
    padding-top: 100%; /* 1:1比例 */
}

.ratio-4-3::before {
    padding-top: 75%; /* 4:3比例 */
}

.ratio-16-9::before {
    padding-top: 56.25%; /* 16:9比例 */
}

.ratio-21-9::before {
    padding-top: 42.85%; /* 21:9比例 */
}

/* 卡片內的圖片樣式 */
.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

/* 新聞/文章圖片樣式 */
.news-img {
    width: 100%;
    height: 220px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.news-img:hover {
    transform: scale(1.05);
}

/* 產品圖片樣式 */
.product-img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* 專案圖片樣式 */
.project-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.6s ease;
}

/* 圓形圖片 */
.img-circle {
    border-radius: 50%;
    object-fit: contain;
}

/* 不同大小的圖片容器 */
.img-xs {
    width: 50px;
    height: 50px;
}

.img-sm {
    width: 100px;
    height: 100px;
}

.img-md {
    width: 200px;
    height: 200px;
}

.img-lg {
    width: 300px;
    height: 300px;
}

/* 圖庫/輪播樣式 */
.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.gallery-thumb {
    width: 80px;
    height: 60px;
    object-fit: contain;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.gallery-thumb.active {
    border-color: var(--primary, #00f5d4);
}

/* CSS Grid圖片網格 */
.img-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.img-grid-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.img-grid-item::before {
    content: "";
    display: block;
    padding-top: 75%;
}

.img-grid-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.img-grid-item:hover img {
    transform: scale(1.1);
}

/* 特效處理 */
.img-hover-zoom {
    overflow: hidden;
}

.img-hover-zoom img {
    transition: transform 0.5s ease;
}

.img-hover-zoom:hover img {
    transform: scale(1.1);
}

/* 圖片邊框和陰影 */
.img-border {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.img-shadow {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* 調整特定圖片大小的類別 */
.thumbnail {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.medium-thumbnail {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.large-thumbnail {
    width: 200px;
    height: 150px;
    object-fit: contain;
}

/* 響應式圖片容器 */
@media (max-width: 768px) {
    .card-img {
        height: 180px;
    }
    
    .news-img {
        height: 180px;
    }
    
    .gallery-thumb {
        width: 60px;
        height: 45px;
    }
    
    .img-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 576px) {
    .card-img {
        height: 150px;
    }
    
    .news-img {
        height: 150px;
    }
    
    .img-md {
        width: 150px;
        height: 150px;
    }
    
    .img-lg {
        width: 200px;
        height: 200px;
    }
    
    .gallery-thumb {
        width: 50px;
        height: 40px;
    }
    
    .img-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* 修復特定位置的圖片問題 */
.news-image img,
.product-image img,
.project-image img,
.carousel-image img,
.feature-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.news-card .news-image img,
.product-card .product-image img,
.project-card .project-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-main-image img,
.image-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* 特殊容器中的圖片保持原樣式但使用contain */
.carousel-container img,
.gallery-container img,
.banner-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 內容編輯器生成的圖片 */
.content-area img,
article img,
.news-detail-content img,
.product-description img,
.core-value-content img {
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

/* 特殊情況：保持原始比例但限制大小 */
.preserve-ratio {
    max-width: 100%;
    height: auto;
}

/* 圖標尺寸控制 */
.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-md {
    width: 24px;
    height: 24px;
}

.icon-lg {
    width: 32px;
    height: 32px;
}

/* 確保SVG正確顯示 */
.svg-img {
    width: 100%;
    height: auto;
} 