/**** 文章相簿功能 ****/

/* 相簿模態視窗樣式 */
.photo-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    /*width: 100%;
    height: 100%;*/
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    overflow: hidden !important;
	
	
	width: 100vw !important; /* 使用視窗寬度單位，並強制優先級 */
    height: 100vh !important; /* 使用視窗高度單位，並強制優先級 */
    max-width: 100vw !important; /* 確保不會超過視窗寬度 */
    max-height: 100vh !important; /* 確保不會超過視窗高度 */
    margin: 0 !important; /* 移除所有可能的外邊距 */
    padding: 0 !important; /* 移除所有可能的內邊距 */
  
    box-sizing: border-box !important; /* 確保padding不會造成寬度增加 */
	
}


/*
.gallery-content {
    position: relative;
    width: 90%;
    max-width: 1100px;
    height: 90%;
    max-height: 850px;
    display: flex;
    flex-direction: column;
    background-color: rgb(15, 15, 15);
    border-radius: 12px;
    overflow: hidden !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 20px;
    box-sizing: border-box !important;
}
*/

.gallery-content {
    position: relative;
    width: 90%; /* 大多數裝置上使用百分比 */
    height: 90%;
    background-color: rgb(15, 15, 15);
    border-radius: 12px;
    overflow: hidden !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 20px;
    box-sizing: border-box !important;
    display: flex;
    flex-direction: column;
}

/* 只在較大螢幕上設置最大值限制 */
@media screen and (min-width: 1200px) {
    .gallery-content {
        max-width: 1100px;
        max-height: 850px;
    }
}



.gallery-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 20px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2010;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.gallery-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.gallery-main-container {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    margin: 10px 0 20px;
    min-height: 0;
    overflow: hidden !important;
    width: 100%;
    box-sizing: border-box;
}

.gallery-main-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    position: relative;
}

.gallery-main-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: auto !important;
    height: auto !important;
}

/* 圖片載入指示器 */
.gallery-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 2005;
    font-size: 14px;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(23, 23, 23, 0.7);
    color: #fff;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2005;
    font-size: 18px;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.gallery-nav:hover {
    background: rgba(23, 122, 194, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.gallery-prev {
    left: 20px;
}

.gallery-next {
    right: 20px;
}

.gallery-counter {
    text-align: center;
    color: #fff;
    font-size: 16px;
    margin-bottom: 15px;
    font-weight: 600;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 縮圖區域相關樣式 */
.gallery-thumbnails {
    height: 110px;
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px 0;
    margin-top: auto;
    flex-shrink: 0;
}

.thumbnails-container {
    display: flex;
    gap: 10px;
    padding: 0 20px;
    overflow-y: hidden;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.5) transparent;
    max-width: 100%;
   /* height: 90px;*/
    -webkit-overflow-scrolling: touch;
}

.thumbnails-container::-webkit-scrollbar {
    height: 5px;
}

.thumbnails-container::-webkit-scrollbar-track {
    background: transparent;
}

.thumbnails-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
}

.gallery-thumbnail {
    flex: 0 0 auto;
    width: 80px;
    height: 80px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.gallery-thumbnail:hover {
    opacity: 0.9;
    transform: translateY(-3px);
}

.gallery-thumbnail.active {
    box-sizing: border-box;
    border: 3px solid #147ac2;
    opacity: 1;
    position: relative;
    z-index: 1;
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
    background-color: #000;
}

.gallery-nav.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* 主圖片容器樣式調整 */
.article-content img, .main-image {
    cursor: zoom-in;
    transition: filter 0.3s;
}

.article-content img:hover, .main-image:hover {
    filter: brightness(1.05);
}

/* 提示框樣式 */
.image-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    transform-origin: center left;
}

.image-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    border-width: 6px 6px 6px 0;
    border-style: solid;
    border-color: transparent rgba(0, 0, 0, 0.75) transparent transparent;
}

/* 圖片加載時的樣式 */
.img-loading {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.img-loaded {
    opacity: 1;
}

/* 針對第一張圖片的特殊處理 */
.initial-image-fix {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: calc(95vh - 150px) !important;
    transform: scale(0.98);
    transition: transform 0.2s ease-out;
}

/* 響應式設計 */
@media screen and (max-width: 768px) {
    .gallery-content {
        width: 90vw !important;
        max-width: 90vw !important;
        height: 90vh !important;
        max-height: 90vh !important;
        padding: 15px;
    }
    
    .gallery-main-container {
        flex: 1;
        min-height: 0;
        padding: 0;
    }
    
    .gallery-main-image {
        width: 100%;
        height: 100%;
    }
    
    .gallery-main-image img {
        max-width: 100% !important;
        max-height: 100% !important;
        width: auto !important;
        height: auto !important;
    }
    
    .gallery-nav {
        width: 40px;
        height: 40px;
    }
    
    .gallery-prev {
        left: 10px;
    }
    
    .gallery-next {
        right: 10px;
    }
    
    .gallery-thumbnails {
        height: 90px;
        min-height: 90px;
    }
    
    .gallery-thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .gallery-close {
        top: 16.5px;
        right: 16.5px;
        width: 33px;
        height: 33px;
        border: 1px solid #FFF;
        line-height: 33px;
        padding: 0;
    }
}

/* 特小螢幕設備的進一步優化 */
@media screen and (max-width: 480px) {
    .gallery-content {
        width: 90vw !important;
        max-width: 90vw !important;
        height: 90vh !important;
        max-height: 90vh !important;
        padding: 10px !important;
    }
    
    .gallery-thumbnails {
        height: 80px;
        min-height: 80px;
    }
    
    .gallery-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .gallery-nav {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .gallery-main-image img {
        max-width: 100% !important;
        max-height: calc(98vh - 120px) !important;
    }
}