/**
 * [INPUT]: 无外部依赖
 * [OUTPUT]: 相册视图样式，瀑布流/卡片/过滤器
 * [POS]: 前端样式模块，被 index.html 引用，配合 gallery-view.js
 * [PROTOCOL]: 变更时更新此头部，然后检查 /CLAUDE.md
 *
 * 内容: 切换按钮, 相册容器, 瀑布流布局, 视频卡片, 过滤栏
 */

/* Gallery Toggle Button */
.gallery-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #333;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.gallery-toggle-btn:hover {
    background: #000;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.gallery-toggle-btn:active {
    transform: scale(0.98);
}

/* Gallery View Container */
.gallery-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-view.active {
    opacity: 1;
    visibility: visible;
}

/* Gallery Header */
.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: white;
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.gallery-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.gallery-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.gallery-close-btn:hover {
    background: #333;
    color: white;
    transform: rotate(90deg);
}

/* Gallery Filter Bar */
.gallery-filter-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 40px;
    background: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.1s backwards;
}

.gallery-filter-bar::-webkit-scrollbar {
    display: none;
}

#galleryFactoryFilters {
    display: flex;
    align-items: center;
    gap: 15px;
}

.gallery-filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #999;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.2s;
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 6px;
    background: transparent;
    transition: all 0.2s ease;
}

.gallery-filter-item:hover {
    background: #f5f5f5;
    color: #666;
}

.gallery-filter-item:active {
    opacity: 0.6;
}

.gallery-filter-item.active {
    color: #333;
    background: #f0f0f0;
    font-weight: 500;
}

.gallery-filter-count {
    font-size: 13px;
    color: #ccc;
}

.gallery-filter-item.active .gallery-filter-count {
    color: #999;
}

/* 自定义分类筛选器分隔线 */
.gallery-filter-separator {
    color: #ddd;
    font-size: 16px;
    padding: 0 5px;
    user-select: none;
    flex-shrink: 0;
}

/* 自定义分类筛选项 - 区分于系统分类 */
.gallery-custom-category-filter {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
}

.gallery-custom-category-filter:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.gallery-custom-category-filter.active {
    background: #4a90a4;
    color: white;
    border-color: #4a90a4;
}

.gallery-custom-category-filter.active .gallery-filter-count {
    color: rgba(255, 255, 255, 0.8);
}

/* Gallery Subcategory Filter */
.gallery-subcategory-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 40px;
    background: #f9f9f9;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-subcategory-filter::-webkit-scrollbar {
    display: none;
}

.gallery-subcategory-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #999;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 4px;
    background: white;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.gallery-subcategory-item:hover {
    border-color: #ccc;
    color: #666;
}

.gallery-subcategory-item.active {
    color: #333;
    background: #333;
    color: white;
    border-color: #333;
}

/* ═══════════════════════════════════════════════════════════════════════════
   自定义分类动态层级筛选器
   ═══════════════════════════════════════════════════════════════════════════ */

#galleryCustomLevelFilters {
    display: none;
}

#galleryCustomLevelFilters.active {
    display: block;
}

.gallery-custom-level-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 40px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-custom-level-row::-webkit-scrollbar {
    display: none;
}

/* 层级深度递增背景色 */
.gallery-custom-level-row[data-level="2"] { background: #f9f9f9; }
.gallery-custom-level-row[data-level="3"] { background: #f5f5f5; }
.gallery-custom-level-row[data-level="4"] { background: #f0f0f0; }
.gallery-custom-level-row[data-level="5"] { background: #ebebeb; }
.gallery-custom-level-row[data-level="6"] { background: #e6e6e6; }

.gallery-custom-level-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 4px;
    background: white;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.gallery-custom-level-item:hover {
    border-color: #ccc;
    color: #333;
}

.gallery-custom-level-item.active {
    background: #4a90a4;
    color: white;
    border-color: #4a90a4;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .gallery-filter-bar {
        padding: 12px 20px;
    }

    .gallery-subcategory-filter {
        padding: 10px 20px;
    }

    .gallery-custom-level-row {
        padding: 10px 20px;
    }
}

/* Gallery Container - Waterfall Layout */
.gallery-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    column-count: 3;
    column-gap: 30px;
}

@media (max-width: 1400px) {
    .gallery-container {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    /* Mobile: scroll the entire view, not just container */
    .gallery-view {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: block; /* Change from flex to block */
    }

    .gallery-container {
        column-count: 2;
        column-gap: 8px;
        padding: 8px;
        padding-top: 8px;
        overflow: visible; /* Let content flow naturally */
    }

    .gallery-header {
        padding: 12px 16px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .gallery-title {
        font-size: 18px;
    }

    .gallery-close-btn {
        width: 36px;
        height: 36px;
    }

    /* Mobile Pinterest-style card - video only */
    .gallery-item {
        margin-bottom: 8px;
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }

    .gallery-item:hover {
        transform: none;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }

    /* Hide all info section on mobile - video only */
    .gallery-item-info {
        display: none;
    }

    /* Hide thumbnails on mobile */
    .gallery-thumbnails {
        display: none;
    }

    /* Video container adjustments */
    .gallery-item-video {
        border-radius: 8px;
    }

    /* Mobile play icon size */
    .gallery-play-icon {
        width: 36px;
        height: 36px;
    }

    .gallery-play-icon svg {
        width: 14px;
        height: 14px;
    }

    /* Simplify video overlay on mobile */
    .gallery-video-overlay {
        background: rgba(0, 0, 0, 0.2);
    }

    .gallery-item-video:hover .gallery-video-overlay {
        background: rgba(0, 0, 0, 0.2);
    }

    /* Filter bar mobile optimization - sticky at top */
    .gallery-filter-bar {
        gap: 10px;
        padding: 10px 12px;
        overflow-x: auto;
        overflow-y: hidden;
        position: sticky;
        top: 52px; /* Below header */
        z-index: 9;
        background: white;
    }

    .gallery-filter-item {
        font-size: 13px;
        padding: 5px 10px;
    }

    .gallery-subcategory-filter {
        padding: 8px 12px;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        position: sticky;
        top: 92px; /* Below header + filter bar */
        z-index: 8;
        background: #f9f9f9;
    }

    .gallery-subcategory-item {
        font-size: 12px;
        padding: 4px 8px;
    }
}

/* Gallery Item Card */
.gallery-item {
    break-inside: avoid;
    margin-bottom: 30px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

/* Stagger animation delay */
.gallery-item:nth-child(1) { animation-delay: 0.05s; }
.gallery-item:nth-child(2) { animation-delay: 0.1s; }
.gallery-item:nth-child(3) { animation-delay: 0.15s; }
.gallery-item:nth-child(4) { animation-delay: 0.2s; }
.gallery-item:nth-child(5) { animation-delay: 0.25s; }
.gallery-item:nth-child(6) { animation-delay: 0.3s; }
.gallery-item:nth-child(n+7) { animation-delay: 0.35s; }

/* Video Container in Gallery */
.gallery-item-video {
    position: relative;
    width: 100%;
    background: #000;
    cursor: pointer;
    aspect-ratio: 3/4;
}

.gallery-item-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease;
}

.gallery-item-video:hover video {
    opacity: 0.9;
}

.gallery-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 1;
    transition: all 0.3s ease;
    pointer-events: none;
}

.gallery-item-video:hover .gallery-video-overlay {
    background: rgba(0, 0, 0, 0.4);
}

/* Hide overlay when video is playing */
.gallery-item-video.playing .gallery-video-overlay {
    opacity: 0;
}

.gallery-play-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(1);
    transition: transform 0.3s ease;
}

.gallery-item-video:hover .gallery-play-icon {
    transform: scale(1.1);
}

/* Gallery Item Info */
.gallery-item-info {
    padding: 16px 20px;
}

.gallery-item-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.gallery-item-meta {
    font-size: 13px;
    color: #666;
    display: flex;
    gap: 8px;
}

.gallery-item-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Image Thumbnails Grid */
.gallery-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    padding: 0 20px 20px;
    margin-top: 12px;
}

.gallery-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #f5f5f5;
    transition: all 0.2s ease;
}

.gallery-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s ease;
}

.gallery-thumbnail:hover img {
    opacity: 0.85;
}

.gallery-thumbnail.active {
    border: 2px solid #333;
    box-shadow: 0 0 0 2px rgba(51, 51, 51, 0.1);
}

.gallery-thumbnail.active::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Empty State */
.gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: #999;
}

.gallery-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.gallery-empty p {
    font-size: 16px;
    margin: 0;
}

/* Loading State */
.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
}

.gallery-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Loading Indicator for Infinite Scroll */
.gallery-loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    width: 100%;
    grid-column: 1 / -1; /* Span all columns in the grid */
}

.gallery-loading-indicator .gallery-loading-spinner {
    width: 30px;
    height: 30px;
    border-width: 2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Smooth Scrollbar */
.gallery-container::-webkit-scrollbar {
    width: 10px;
}

.gallery-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.gallery-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.gallery-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Image Display Mode in Gallery Item */
.gallery-item.image-mode .gallery-item-video {
    background: #f5f5f5;
}

.gallery-item.image-mode .gallery-item-video video {
    display: none;
}

.gallery-item-image-display {
    display: none;
    width: 100%;
    height: auto;
}

.gallery-item.image-mode .gallery-item-image-display {
    display: block;
}

.gallery-item.image-mode .gallery-video-overlay {
    display: none;
}

/* ========================================
   Video Poster & Loading Optimization
   ======================================== */

/* Video Poster Container */
.video-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    overflow: hidden;
    background: #1a1a1a;
    transition: opacity 0.4s ease;
}

.video-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-poster.poster-hidden {
    opacity: 0;
    pointer-events: none;
}

.video-poster.error {
    background: #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-poster.error::after {
    content: 'Video unavailable';
    color: #666;
    font-size: 12px;
}

/* Skeleton Loading Animation */
.video-poster.skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Video Loading Indicator */
.video-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gallery-item-video.loading .video-loading-indicator {
    opacity: 1;
}

.video-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Video Hidden State */
.gallery-item-video video.video-hidden {
    opacity: 0;
}

.gallery-item-video video {
    transition: opacity 0.4s ease;
}

/* Slow Network Indicator */
.slow-network-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #ffc107;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    z-index: 5;
    display: none;
}

.gallery-item-video.slow-network .slow-network-badge {
    display: block;
}

/* ========================================
   Mobile Optimizations
   ======================================== */
@media (max-width: 768px) {
    .gallery-item-video video,
    .video-poster {
        transition: opacity 0.2s ease;
    }

    .video-loading-spinner {
        width: 28px;
        height: 28px;
        border-width: 2px;
    }

    .video-poster.skeleton {
        animation: shimmer 1.2s infinite;
    }
}

/* ========================================
   Low-end Device Optimizations
   ======================================== */
.reduce-motion .gallery-item,
.reduce-motion .video-poster,
.reduce-motion video {
    transition: none !important;
    animation: none !important;
}

.reduce-motion .gallery-item:hover {
    transform: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.reduce-motion .video-poster.skeleton {
    animation: none !important;
    background: #2a2a2a;
}

/* ========================================
   Network Status Badge
   ======================================== */
.network-status-badge {
    position: fixed;
    top: 60px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 10002;
    display: none;
}

.network-status-badge.visible {
    display: block;
}

.network-status-badge.slow {
    background: rgba(255, 152, 0, 0.9);
}

.network-status-badge.offline {
    background: rgba(244, 67, 54, 0.9);
}

/* ========================================
   Mobile Gallery Image Overlay
   ======================================== */

/* Only show on mobile */
@media (max-width: 768px) {
    .mobile-image-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
        background: #000;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .mobile-image-overlay.visible {
        opacity: 1;
        visibility: visible;
    }

    .mobile-image-overlay img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .mobile-image-close {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.6);
        color: white;
        border: none;
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 12;
        transition: background 0.2s ease;
    }

    .mobile-image-close:hover,
    .mobile-image-close:active {
        background: rgba(0, 0, 0, 0.8);
    }

    .mobile-image-counter {
        position: absolute;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.6);
        color: white;
        padding: 4px 12px;
        border-radius: 12px;
        font-size: 12px;
        z-index: 12;
    }

    /* Navigation areas - transparent clickable zones */
    .mobile-image-nav {
        position: absolute;
        top: 0;
        width: 25%;
        height: 100%;
        z-index: 11;
        cursor: pointer;
    }

    .mobile-nav-prev {
        left: 0;
    }

    .mobile-nav-next {
        right: 0;
    }

    /* Optional: Add subtle visual feedback on tap */
    .mobile-image-nav:active {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Hide on desktop */
@media (min-width: 769px) {
    .mobile-image-overlay {
        display: none !important;
    }
}

/* ========================================
   Gallery Fullscreen Image Viewer
   ======================================== */

.gallery-fullscreen-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gallery-fullscreen-viewer.visible {
    opacity: 1;
    visibility: visible;
}

.gallery-fullscreen-viewer img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: none;
    transition: opacity 0.3s ease;
}

/* Image loading indicator */
.gallery-viewer-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10099;
}

.gallery-viewer-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: gallerySpinnerRotate 0.8s linear infinite;
}

@keyframes gallerySpinnerRotate {
    to { transform: rotate(360deg); }
}

/* Close button */
.gallery-viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10101;
    transition: background 0.2s ease, transform 0.2s ease;
}

.gallery-viewer-close:hover,
.gallery-viewer-close:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

/* Image counter */
.gallery-viewer-counter {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10101;
}

/* Navigation buttons */
.gallery-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10101;
    transition: background 0.2s ease, transform 0.2s ease;
}

.gallery-viewer-nav:hover,
.gallery-viewer-nav:active {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.1);
}

.gallery-viewer-prev {
    left: 16px;
}

.gallery-viewer-next {
    right: 16px;
}

/* Slide animations */
.gallery-fullscreen-viewer img.slide-out-left {
    animation: gallerySlideOutLeft 0.15s ease-out forwards;
}

.gallery-fullscreen-viewer img.slide-out-right {
    animation: gallerySlideOutRight 0.15s ease-out forwards;
}

.gallery-fullscreen-viewer img.slide-in-from-right {
    animation: gallerySlideInFromRight 0.3s ease-out forwards;
}

.gallery-fullscreen-viewer img.slide-in-from-left {
    animation: gallerySlideInFromLeft 0.3s ease-out forwards;
}

@keyframes gallerySlideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-30%); opacity: 0; }
}

@keyframes gallerySlideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(30%); opacity: 0; }
}

@keyframes gallerySlideInFromRight {
    from { transform: translateX(30%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes gallerySlideInFromLeft {
    from { transform: translateX(-30%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .gallery-viewer-close {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 24px;
    }

    .gallery-viewer-counter {
        bottom: 20px;
        padding: 6px 16px;
        font-size: 13px;
    }

    .gallery-viewer-nav {
        width: 44px;
        height: 44px;
        font-size: 28px;
    }

    .gallery-viewer-prev {
        left: 8px;
    }

    .gallery-viewer-next {
        right: 8px;
    }

    .gallery-fullscreen-viewer img {
        max-width: 95vw;
        max-height: 80vh;
    }
}

/* ========================================
   Mobile Gallery Item Info (Two-Row Layout)
   ======================================== */

/* Hidden by default (desktop) */
.gallery-item-info-mobile {
    display: none;
}

@media (max-width: 768px) {
    .gallery-item-info-mobile {
        display: block;
        padding: 6px 8px;
        background: #fff;
        border-radius: 0 0 8px 8px;
    }

    /* First row: Factory / Category / Model Number */
    .gallery-mobile-meta {
        font-size: 10px;
        color: #666;
        text-align: center;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        margin-bottom: 4px;
    }

    .gallery-mobile-factory,
    .gallery-mobile-id {
        font-weight: 500;
        color: #333;
    }

    .gallery-mobile-category {
        color: #666;
    }

    .gallery-mobile-sep {
        margin: 0 3px;
        color: #ccc;
    }

    /* Second row: Action buttons centered */
    .gallery-mobile-actions {
        display: flex;
        justify-content: center;
        gap: 16px;
    }

    .gallery-mobile-btn {
        background: none;
        border: none;
        padding: 4px;
        cursor: pointer;
        color: #999;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: color 0.2s ease;
    }

    .gallery-mobile-btn:active {
        transform: scale(0.9);
    }

    .gallery-mobile-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Like button active state */
    .gallery-mobile-btn.gallery-like-btn.liked {
        color: #ff4757;
    }

    .gallery-mobile-btn.gallery-like-btn.liked svg {
        fill: #ff4757;
    }

    /* Adjust gallery item to include info area */
    .gallery-item {
        overflow: hidden;
    }

    .gallery-item-video {
        border-radius: 8px 8px 0 0;
    }
}

/* ==================== */
/* Gallery Comment Styles */
/* ==================== */

.gallery-comment-btn {
    color: #999;
    transition: all 0.2s ease;
}

.gallery-comment-btn:hover {
    color: #f39c12;
}

.gallery-comment-btn.has-comment {
    color: #f39c12;
}

.gallery-comment-btn.has-comment svg {
    fill: rgba(243, 156, 18, 0.2);
}

.gallery-item-comment {
    padding: 8px 12px;
    margin: 0 10px 10px;
    background: rgba(243, 156, 18, 0.08);
    border-left: 3px solid #f39c12;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    color: #555;
    line-height: 1.4;
    word-break: break-word;
}

/* Desktop adjustments */
@media (min-width: 769px) {
    .gallery-item-comment {
        margin: 0 0 8px;
        font-size: 13px;
    }
}

/* ==================== */
/* Desktop Gallery Action Buttons */
/* ==================== */

.gallery-item-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.gallery-action-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #999;
}

.gallery-action-btn:hover {
    color: #333;
}

.gallery-action-btn:active {
    transform: scale(0.9);
}

.gallery-action-btn svg {
    width: 18px;
    height: 18px;
}

/* Like button states */
.gallery-action-btn.gallery-like-btn.liked {
    color: #e74c3c;
}

.gallery-action-btn.gallery-like-btn.liked svg {
    fill: #e74c3c;
}

.gallery-action-btn.gallery-like-btn:hover {
    color: #e74c3c;
}

/* Send button hover */
.gallery-action-btn.gallery-send-btn:hover {
    color: #3498db;
}

/* Share button hover */
.gallery-action-btn.gallery-share-btn:hover {
    color: #27ae60;
}

/* Hide desktop buttons on mobile (mobile has its own layout) */
@media (max-width: 768px) {
    .gallery-item-actions {
        display: none;
    }
}
