/* Gallery 样式 - 增强版支持动态列数并采用canvas.js风格的模态框 */

/* 动态网格容器 */
.gallery-grid-container {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(var(--gallery-cols-mobile), 1fr);
}

/* 平板端响应式 */
@media (min-width: 768px) {
    .gallery-grid-container {
        grid-template-columns: repeat(var(--gallery-cols-tablet), 1fr);
    }
}

/* 桌面端响应式 */
@media (min-width: 1024px) {
    .gallery-grid-container {
        grid-template-columns: repeat(var(--gallery-cols-desktop), 1fr);
    }
}

/* 超大屏幕优化 - 当列数过多时调整间距 */
@media (min-width: 1280px) {
    .gallery-grid-container[data-cols="8"],
    .gallery-grid-container[data-cols="9"],
    .gallery-grid-container[data-cols="10"],
    .gallery-grid-container[data-cols="11"],
    .gallery-grid-container[data-cols="12"] {
        gap: 1rem;
    }

    .gallery-grid-container[data-cols="10"],
    .gallery-grid-container[data-cols="11"],
    .gallery-grid-container[data-cols="12"] {
        gap: 0.75rem;
    }
}

/* 当列数较多时，调整图片高度 */
.gallery-grid-container[data-cols="5"] .gallery-image,
.gallery-grid-container[data-cols="6"] .gallery-image,
.gallery-grid-container[data-cols="7"] .gallery-image,
.gallery-grid-container[data-cols="8"] .gallery-image {
    height: 200px;
}

.gallery-grid-container[data-cols="9"] .gallery-image,
.gallery-grid-container[data-cols="10"] .gallery-image,
.gallery-grid-container[data-cols="11"] .gallery-image,
.gallery-grid-container[data-cols="12"] .gallery-image {
    height: 160px;
}

/* 超多列数时的特殊处理 */
.gallery-grid-container[data-cols="15"],
.gallery-grid-container[data-cols="20"] {
    gap: 0.5rem;
}

.gallery-grid-container[data-cols="15"] .gallery-image,
.gallery-grid-container[data-cols="20"] .gallery-image {
    height: 120px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(var(--primary), 0.15);
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
    padding: 20px;
    color: white;
    opacity: 0;
    transition: all 0.3s ease;
    transform: translateY(20px);
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* 当列数过多时，简化overlay内容 */
.gallery-grid-container[data-cols="5"] .gallery-overlay,
.gallery-grid-container[data-cols="6"] .gallery-overlay,
.gallery-grid-container[data-cols="7"] .gallery-overlay,
.gallery-grid-container[data-cols="8"] .gallery-overlay,
.gallery-grid-container[data-cols="9"] .gallery-overlay,
.gallery-grid-container[data-cols="10"] .gallery-overlay,
.gallery-grid-container[data-cols="11"] .gallery-overlay,
.gallery-grid-container[data-cols="12"] .gallery-overlay {
    padding: 12px;
    font-size: 0.875rem;
}

.gallery-grid-container[data-cols="5"] .gallery-overlay h3,
.gallery-grid-container[data-cols="6"] .gallery-overlay h3,
.gallery-grid-container[data-cols="7"] .gallery-overlay h3,
.gallery-grid-container[data-cols="8"] .gallery-overlay h3,
.gallery-grid-container[data-cols="9"] .gallery-overlay h3,
.gallery-grid-container[data-cols="10"] .gallery-overlay h3,
.gallery-grid-container[data-cols="11"] .gallery-overlay h3,
.gallery-grid-container[data-cols="12"] .gallery-overlay h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.gallery-grid-container[data-cols="15"] .gallery-overlay,
.gallery-grid-container[data-cols="20"] .gallery-overlay {
    padding: 8px;
    font-size: 0.75rem;
}

.gallery-grid-container[data-cols="15"] .gallery-overlay h3,
.gallery-grid-container[data-cols="20"] .gallery-overlay h3 {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

/* 图片查看器模态框样式 - 修复与DaisyUI冲突的问题 */
.gallery-image-viewer-modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: rgba(0, 0, 0, 0.98) !important; /* 强制深黑色背景 */
    backdrop-filter: none !important; /* 禁用DaisyUI的backdrop-filter */
}

.gallery-image-viewer-modal.gallery-modal-open {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.gallery-modal-box {
    position: relative;
    background: transparent !important;
    border-radius: 12px;
    box-shadow: none !important; /* 移除DaisyUI的默认阴影 */
    transform: scale(0.95);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100vw;
    max-width: 100vw !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 800px;
}

.gallery-image-viewer-modal.gallery-modal-open .gallery-modal-box {
    transform: scale(1);
}

/* 图片容器优化 */
.modal-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 95vh;
    padding: 4px;
    position: relative;
}

#modal-image {
    opacity: 0;
    transition: opacity 0.7s ease, transform 0.7s ease;
    transform: scale(0.95);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.15);
    max-height: 95vh;
    max-width: 95vw;
    object-fit: contain;
    border-radius: 8px;
    cursor: pointer;
}

#modal-image.loaded {
    opacity: 1;
    transform: scale(1.1); /* 更大的放大效果 */
}

/* 关闭按钮样式 - 采用canvas.js风格 */
.modal-close-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.7);
    transform: scale(1.1);
}

/* 模态框背景点击区域 */
.modal-backdrop {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.modal-backdrop button {
    opacity: 0;
    position: absolute;
}

/* 图片加载动画 */
.modal-image-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    z-index: 5;
}

.modal-image-container.loading::before {
    opacity: 1;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 导航按钮样式 - 采用canvas.js风格 */
#prev-image, #next-image {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    user-select: none;
}

#prev-image {
    left: 3vw;
}

#next-image {
    right: 3vw;
}

#prev-image:hover, #next-image:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transform: translateY(-50%) scale(1.1);
}

#prev-image:active, #next-image:active {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(0.95);
}

#prev-image:disabled, #next-image:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
}

#prev-image:disabled:hover, #next-image:disabled:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    transform: translateY(-50%);
}

/* 图片信息栏样式 - 隐藏底部信息栏 */
.modal-info-bar {
    display: none !important; /* 完全隐藏底部信息栏 */
}

#modal-image-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7);
    line-height: 1.3;
}

.modal-info-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

#modal-image-counter {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-download-btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-download-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

/* 提示样式 - 原图加载提示 */
.original-image-hint {
    position: absolute;
    top: 3rem;
    right: 3rem;
    z-index: 1000;
    opacity: 1;
    animation: fadeInOut 3s ease-in-out;
}

.original-image-hint .hint-content {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.original-image-hint .hint-icon {
    width: 20px;
    height: 20px;
}

/* 键盘导航提示 - 优化版 */
.keyboard-hint {
    position: absolute;
    top: 3rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    opacity: 1;
    animation: fadeInOut 4s ease-in-out;
}

.keyboard-hint .hint-content {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.keyboard-hint kbd {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* 加载更多按钮样式 */
.load-more-btn {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: none;
    outline: none;
    cursor: pointer;
}

.load-more-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.load-more-btn:hover::before {
    left: 100%;
}

.load-more-btn:active {
    transform: scale(0.98);
}

/* 图片淡入动画 */
.gallery-item {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.gallery-item.hidden-mobile {
    opacity: 0;
    transform: translateY(20px);
}

/* Gallery项目hover效果增强 */
.gallery-item::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
}

.gallery-item:hover::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.9;
}

/* 响应式布局 - Gallery专用 */
@media (max-width: 768px) {
    /* 移动端强制使用单列布局，忽略桌面端配置 */
    .gallery-grid-container {
        grid-template-columns: repeat(var(--gallery-cols-mobile), 1fr) !important;
    }

    /* 移动端图片高度统一 */
    .gallery-grid-container .gallery-image {
        height: 250px !important;
    }

    /* 移动端overlay样式重置 */
    .gallery-grid-container .gallery-overlay {
        padding: 16px !important;
        font-size: 0.9rem !important;
    }

    .gallery-grid-container .gallery-overlay h3 {
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* 移动端模态框调整 */
    .gallery-modal-box {
        min-width: unset;
    }

    /* 移动端图片查看器优化 */
    #prev-image, #next-image {
        width: 45px;
        height: 45px;
    }

    #prev-image {
        left: 3vw;
    }

    #next-image {
        right: 3vw;
    }

    .modal-close-btn {
        width: 40px;
        height: 40px;
        top: 2rem;
        right: 2rem;
    }

    .modal-info-bar {
        padding: 20px 6vw 16px;
    }

    #modal-image-title {
        font-size: 1.3rem;
        margin-bottom: 12px;
    }

    #modal-image-counter {
        font-size: 0.9rem;
        padding: 8px 16px;
    }

    .modal-download-btn {
        font-size: 0.9rem;
        padding: 8px 16px;
    }

    .keyboard-hint {
        font-size: 0.85rem;
        padding: 10px 16px;
    }

    .original-image-hint {
        top: 2rem;
        right: 2rem;
    }

    .original-image-hint .hint-content {
        font-size: 0.85rem;
        padding: 10px 16px;
    }
}

@media (max-width: 480px) {
    /* 超小屏幕优化 */
    #modal-image {
        max-width: 95vw;
        max-height: 85vh;
    }

    #modal-image-title {
        font-size: 1.1rem;
    }

    #modal-image-counter {
        font-size: 0.8rem;
        padding: 6px 12px;
    }

    .modal-download-btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }

    .modal-info-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* Gallery 筛选按钮样式 - 绿色主题 */
.gallery-filter-btn {
    background: white;
    color: rgb(34, 139, 34);
    border: 1px solid rgba(34, 139, 34, 0.3);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.gallery-filter-btn:hover {
    background-color: rgba(34, 139, 34, 0.05);
    border-color: rgba(34, 139, 34, 0.5);
    box-shadow: 0 4px 12px rgba(34, 139, 34, 0.15);
}

.gallery-filter-btn.active {
    background: rgb(34, 139, 34);
    color: white;
    border-color: rgb(34, 139, 34);
    box-shadow: 0 4px 15px rgba(34, 139, 34, 0.3);
}

.gallery-filter-btn.active:hover {
    background: rgb(46, 125, 50);
    border-color: rgb(46, 125, 50);
    box-shadow: 0 6px 20px rgba(34, 139, 34, 0.4);
}

/* 覆盖DaisyUI的modal样式 */
.gallery-image-viewer-modal:not(.modal-open) {
    display: flex !important; /* 保持flex布局 */
}

/* 确保我们的模态框样式优先级最高 */
body .gallery-image-viewer-modal {
    background-color: rgba(0, 0, 0, 0.98) !important;
    backdrop-filter: none !important;
}