/* 新增样式 */
.gallery-detail {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    overflow-y: auto;
    padding: 0;
}

.gallery-detail.active {
    display: block;
}

.detail-container {
    width: 100%;
    min-height: 100%;
    margin: 0 auto;
    background: #1a1a1a;
    border-radius: 0;
    padding: 20px;
    position: relative;
    color: #fff;
    display: flex;
    flex-direction: column;
}

.detail-close {
    position: fixed;
    top: 15px;
    right: 15px;
    background: #ef4444;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    z-index: 1001;
}

.detail-content {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    flex-shrink: 0;
}

.detail-header {
    text-align: center;
    margin-bottom: 15px;
}

.detail-title {
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 5px;
    word-break: break-word;
}

.detail-category {
    color: #a0aec0;
    font-size: 1rem;
    margin-bottom: 10px;
}

.detail-description {
    font-size: 1rem;
    line-height: 1.6;
    color: #e2e8f0;
    text-align: center;
    word-break: break-word;
}

.gallery-slider {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    min-height: 50vh;
}

.slider-main {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 300px;
}

.main-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    background: #2d3748;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-transform: translateZ(0);
}

.slider-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 8px;
    margin-top: 15px;
    flex-shrink: 0;
}

.nav-image {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.nav-image.active {
    border-color: #4f46e5;
    transform: scale(1.05);
}

.nav-image:hover {
    border-color: #4f46e5;
}

.slider-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-shrink: 0;
}

.slider-btn {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.slider-btn:hover {
    background: #4338ca;
    transform: translateY(-2px);
}

.slider-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.image-counter {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 10;
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #4f46e5;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    z-index: 999;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}

.back-to-top:hover {
    background: #4338ca;
    transform: translateY(-3px);
}

/* 首页图集样式修改 - 增加高度，减少边距 */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    padding: 10px;
}

.image-card {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    background: #fff;
    margin: 5px;
}

.image-card:hover {
    transform: translateY(-5px);
}

.image-container {
    position: relative;
    width: 100%;
    height: 520px;
    overflow: hidden;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-card:hover .image-container img {
    transform: scale(1.05);
}

.watermark {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    min-width: auto;
    width: auto;
}

.watermark.available {
    background: #10b981;
    width: 86px;
}

.watermark.off {
    background: #ef4444;
    width: 39px;
}

.image-count-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.image-info {
    padding: 15px;
}

.image-info h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

/* iOS Safari 特定修复 - 移除图片高度限制 */
@supports (-webkit-touch-callout: none) {
    .gallery-detail {
        -webkit-overflow-scrolling: touch;
        position: fixed;
        overflow: auto;
    }
    
    .detail-container {
        padding: 15px 10px;
        min-height: auto;
        display: flex;
        flex-direction: column;
    }
    
    .gallery-slider {
        min-height: auto;
        margin-bottom: 15px;
        flex: none;
    }
    
    .slider-main {
        min-height: auto;
        max-height: none;
        height: auto;
        display: flex;
        align-items: flex-start;
        justify-content: center;
    }
    
    .main-image {
        max-height: none;
        height: auto;
        width: auto;
        max-width: 100%;
        object-fit: contain;
    }
    
    .detail-content {
        margin-top: 15px;
        padding: 12px;
        position: relative;
        z-index: 20;
        flex: none;
    }
    
    .detail-title, .detail-category, .detail-description {
        -webkit-user-select: none;
        user-select: none;
    }
    
    .nav-image, .slider-btn, .detail-close {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    @media (orientation: landscape) {
        .detail-container {
            flex-direction: row;
            align-items: flex-start;
        }
        
        .gallery-slider {
            flex: 2;
            margin-right: 15px;
            margin-bottom: 0;
        }
        
        .detail-content {
            flex: 1;
            margin-top: 0;
            max-height: 90vh;
            overflow-y: auto;
        }
        
        .slider-main {
            max-height: 90vh;
        }
        
        .main-image {
            max-height: 85vh;
        }
    }
}

/* 响应式调整 */
@media (max-width: 768px) {
    .detail-title {
        font-size: 1.5rem;
    }
    
    .detail-container {
        padding: 10px;
    }
    
    .slider-main {
        height: auto;
        min-height: auto;
    }
    
    .main-image {
        max-height: none;
    }
    
    .slider-nav {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 5px;
    }
    
    .nav-image {
        height: 50px;
    }
    
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* 手机端图集显示优化 - 每行2个，99.99%宽度铺满 */
    .gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 4px !important;
        padding: 2px !important;
        width: 99.99% !important;
        margin: 0 auto !important;
    }
    
    .image-card {
        margin: 1px !important;
        border-radius: 8px !important;
    }
    
    .image-container {
        height: 280px !important;
    }
    
    .image-info {
        padding: 6px !important;
        min-height: 36px !important;
    }
    
    .image-info h3 {
        font-size: 0.85rem !important;
    }
    
    @supports (-webkit-touch-callout: none) {
        .detail-container {
            padding: 15px 8px;
        }
        
        .detail-title {
            font-size: 1.5rem;
        }
        
        .detail-content {
            margin-top: 15px;
            padding: 12px;
        }
        
        .slider-main {
            min-height: auto;
            max-height: none;
        }
        
        .main-image {
            max-height: none;
        }
        
        .slider-nav {
            grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
            gap: 6px;
        }
        
        .nav-image {
            height: 50px;
        }
        
        .slider-controls {
            margin-top: 12px;
        }
    }
}

/* 超小屏幕手机优化 */
@media (max-width: 480px) {
    .qr-codes {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .qr-image {
        width: 120px;
        height: 120px;
    }
    
    .qr-label {
        font-size: 0.8rem;
    }
    
    /* 超小屏幕图集显示优化 - 每行2个，99.99%宽度铺满 */
    .gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 3px !important;
        padding: 1px !important;
        width: 99.99% !important;
        margin: 0 auto !important;
    }
    
    .image-card {
        margin: 1px !important;
        border-radius: 6px !important;
    }
    
    .image-container {
        height: 240px !important;
    }
    
    .image-info {
        padding: 4px !important;
        min-height: 32px !important;
    }
    
    .image-info h3 {
        font-size: 0.75rem !important;
    }
    
    @supports (-webkit-touch-callout: none) {
        .detail-container {
            padding: 10px 5px;
        }
        
        .detail-close {
            top: 10px;
            right: 10px;
            width: 35px;
            height: 35px;
            font-size: 16px;
        }
        
        .detail-title {
            font-size: 1.3rem;
        }
        
        .detail-content {
            margin-top: 12px;
            padding: 10px;
        }
        
        .detail-description {
            font-size: 0.9rem;
        }
        
        .slider-main {
            min-height: auto;
            max-height: none;
        }
        
        .main-image {
            max-height: none;
        }
        
        .slider-nav {
            grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
            gap: 5px;
        }
        
        .nav-image {
            height: 40px;
        }
        
        .slider-btn {
            padding: 8px 16px;
            font-size: 12px;
        }
        
        .image-counter {
            top: 10px;
            left: 10px;
            padding: 4px 8px;
            font-size: 11px;
        }
    }
}

/* 平板设备图集优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .image-container {
        height: 320px !important;
    }
    
    .gallery {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 横屏模式优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .detail-container {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .gallery-slider {
        flex: 2;
        margin-right: 15px;
        margin-bottom: 0;
    }
    
    .detail-content {
        flex: 1;
        margin-top: 0;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .slider-main {
        max-height: 70vh;
    }
    
    .main-image {
        max-height: 60vh;
    }
}

/* 高性能设备优化 */
@media (min-width: 1025px) and (min-height: 800px) {
    .detail-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 30px;
    }
    
    .gallery-slider {
        min-height: 60vh;
    }
    
    .slider-main {
        min-height: 400px;
    }
    
    .main-image {
        max-height: 70vh;
    }
    
    .detail-content {
        margin-top: 25px;
        padding: 20px;
    }
    
    .detail-title {
        font-size: 2rem;
    }
    
    .detail-description {
        font-size: 1.1rem;
    }
}

/* 暗色模式支持 - 但因为我们改成了白色背景，这里保留但调整 */
@media (prefers-color-scheme: dark) {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    
    .container {
        background: #ffffff;
    }
    
    .image-card {
        background: #ffffff !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    }
    
    .image-info h3 {
        color: #222222 !important;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    .image-card,
    .image-container img,
    .slider-btn,
    .nav-image,
    .back-to-top {
        transition: none;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .watermark.available {
        background: #00ff00;
        color: #000;
    }
    
    .watermark.off {
        background: #ff0000;
        color: #000;
    }
    
    .detail-content {
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid #fff;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .image-card:hover {
        transform: none;
    }
    
    .image-card:hover .image-container img {
        transform: none;
    }
    
    .slider-btn:hover {
        transform: none;
        background: #4f46e5;
    }
    
    .back-to-top:hover {
        transform: none;
        background: #4f46e5;
    }
}

/* 打印样式 */
@media print {
    .gallery-detail,
    .back-to-top,
    .navbar,
    .banner,
    .contact-section,
    .bottom-contact,
    footer {
        display: none !important;
    }
    
    .detail-container {
        position: static;
        background: white;
        color: black;
        padding: 0;
    }
    
    .detail-content {
        background: white;
        color: black;
        border: 1px solid #000;
    }
    
    .detail-title,
    .detail-category,
    .detail-description {
        color: black;
    }
}