/* 自定义图片画廊核心样式 */
.custom-gallery {
    --gallery-primary-color: #4a90e2;
    --gallery-bg-dark: rgba(0, 0, 0, 0.3);
    --gallery-bg-light: rgba(255, 255, 255, 0.1);
    --gallery-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --gallery-border-radius: 12px;
    --gallery-transition: all 0.3s ease;
    --gallery-height: 600px;
    
    max-width: 1200px;
    width: 100%;
    margin: 40px auto;
    padding: 0 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 画廊容器 */
.custom-gallery .gallery-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 主图容器 */
.custom-gallery .main-image-container {
    position: relative;
    width: 100%;
    border-radius: var(--gallery-border-radius);
    background: var(--gallery-bg-dark);
    box-shadow: var(--gallery-shadow);
    height: var(--gallery-height);
    overflow: hidden;
}

/* 图片显示区域 */
.custom-gallery .image-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--gallery-transition);
}

.custom-gallery .image-display:hover {
    transform: scale(1.01);
}

.custom-gallery .current-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
}

.custom-gallery .image-display:hover .current-image {
    opacity: 0.9;
}

/* 图片计数器 */
.custom-gallery .image-counter {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 5;
}

/* 导航按钮 */
.custom-gallery .nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--gallery-transition);
    border: none;
    z-index: 10;
    font-size: 1.2rem;
    font-weight: 300;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.custom-gallery .nav-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.custom-gallery .nav-button:active {
    transform: translateY(-50%) scale(0.95);
}

.custom-gallery .nav-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.custom-gallery .nav-button.prev {
    left: 20px;
}

.custom-gallery .nav-button.next {
    right: 20px;
}

/* 箭头图标 */
.custom-gallery .arrow-icon {
    width: 20px;
    height: 20px;
    stroke: white;
    stroke-width: 2;
    fill: none;
    transition: var(--gallery-transition);
}

.custom-gallery .nav-button:hover .arrow-icon {
    stroke-width: 2.5;
}

.custom-gallery .nav-button.prev .arrow-icon {
    transform: rotate(180deg);
}

/* 缩略图容器 - 修改为单行水平滚动 */
.custom-gallery .thumbnails-container {
    width: 100%;
    background: var(--gallery-bg-light);
    border-radius: var(--gallery-border-radius);
    padding: 20px;
    display: flex;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    
    /* 关键修改：单行水平滚动，隐藏滚动条 */
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    flex-wrap: nowrap; /* 禁止换行 */
    -webkit-overflow-scrolling: touch; /* 移动端平滑滚动 */
    scrollbar-width: none; /* Firefox 隐藏滚动条 */
    -ms-overflow-style: none; /* IE/Edge 隐藏滚动条 */
    
    /* 确保内容左对齐 */
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    min-height: 120px; /* 固定高度防止抖动 */
}

/* WebKit浏览器隐藏滚动条 */
.custom-gallery .thumbnails-container::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
    background: transparent;
}

/* 缩略图 */
.custom-gallery .thumbnail {
    /* 关键：使用 inline-block 或 flex-shrink: 0 防止缩放 */
    display: inline-flex;
    flex: 0 0 auto; /* 禁止伸缩 */
    width: 140px;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--gallery-transition);
    border: 3px solid transparent;
    position: relative;
    opacity: 0.7;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* 第一个缩略图左对齐容器 */
.custom-gallery .thumbnail:first-child {
    /* 如果容器有内边距，可能需要调整 */
    margin-left: 0;
}

.custom-gallery .thumbnail:hover {
    opacity: 0.9;
    transform: translateY(-8px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.custom-gallery .thumbnail.active {
    border-color: var(--gallery-primary-color);
    opacity: 1;
    box-shadow: 0 6px 12px rgba(74, 144, 226, 0.4);
}

.custom-gallery .thumbnail.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 4px;
    background: var(--gallery-primary-color);
    border-radius: 2px;
}

.custom-gallery .thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 加载状态 */
.custom-gallery .gallery-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: var(--gallery-height);
    color: #666;
    font-size: 1.1rem;
}

.custom-gallery .gallery-loading::after {
    content: '';
    width: 30px;
    height: 30px;
    margin-left: 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--gallery-primary-color);
    border-radius: 50%;
    animation: cig-spin 1s linear infinite;
}

@keyframes cig-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误状态 */
.custom-gallery .gallery-error {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: var(--gallery-height);
    color: #e74c3c;
    font-size: 1.1rem;
    text-align: center;
    padding: 20px;
}

.custom-gallery .gallery-error button {
    margin-top: 15px;
    padding: 8px 16px;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.custom-gallery .gallery-error button:hover {
    background: #3a7bc8;
}

/* 响应式设计 */
@media (max-width: 950px) {
    .custom-gallery .main-image-container {
        height: 450px;
    }
    
    .custom-gallery .thumbnails-container {
        gap: 15px;
        padding: 15px;
        min-height: 100px;
    }
    
    .custom-gallery .thumbnail {
        width: 120px;
        height: 80px;
    }
    
    .custom-gallery .nav-button {
        width: 45px;
        height: 45px;
    }
    
    .custom-gallery .arrow-icon {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 768px) {
    .custom-gallery .main-image-container {
        height: 400px;
    }
    
    .custom-gallery .thumbnails-container {
        gap: 12px;
        padding: 12px;
        min-height: 90px;
    }
    
    .custom-gallery .thumbnail {
        width: 100px;
        height: 70px;
    }
    
    .custom-gallery .nav-button {
        width: 40px;
        height: 40px;
    }
    
    .custom-gallery .arrow-icon {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 600px) {
    .custom-gallery {
        padding: 0 15px;
    }
    
    .custom-gallery .main-image-container {
        height: 350px;
    }
    
    .custom-gallery .thumbnails-container {
        gap: 10px;
        padding: 10px;
        min-height: 80px;
    }
    
    .custom-gallery .thumbnail {
        width: 85px;
        height: 60px;
    }
    
    .custom-gallery .nav-button {
        width: 35px;
        height: 35px;
    }
    
    .custom-gallery .arrow-icon {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 480px) {
    .custom-gallery {
        padding: 0 10px;
        margin: 20px auto;
    }
    
    .custom-gallery .main-image-container {
        height: 300px;
    }
    
    .custom-gallery .thumbnails-container {
        gap: 8px;
        padding: 8px;
        min-height: 70px;
    }
    
    .custom-gallery .thumbnail {
        width: 70px;
        height: 50px;
    }
    
    .custom-gallery .nav-button {
        width: 30px;
        height: 30px;
    }
    
    .custom-gallery .arrow-icon {
        width: 12px;
        height: 12px;
    }
}

/* 短代码提示样式 */
.cig-notice {
    padding: 15px;
    background: #f8f9fa;
    border-left: 4px solid #4a90e2;
    margin: 20px 0;
    border-radius: 4px;
}