/* Explore Page - Clean Image Grid with Sidebar */
/* Note: Sidebar styles are in navigation.css */

/* Gallery Container */
.gallery-container {
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.gallery-mode-switch {
    display: flex;
    gap: 10px;
    padding: 20px 20px 0;
}

.gallery-mode-btn {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gallery-mode-btn:hover {
    border-color: rgba(255, 255, 255, 0.32);
    color: var(--text-primary);
}

.gallery-mode-btn.active {
    border-color: var(--accent);
    background: rgba(168, 85, 247, 0.16);
    color: var(--text-primary);
}

.gallery-access-state {
    padding: 32px 20px 8px;
}

.gallery-access-state h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.gallery-access-state p {
    margin: 0;
}

/* Grid Layout - Responsive columns that fill available space */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: 280px;
    grid-auto-flow: dense;
    gap: 2px;
}

/* Gallery Item */
.gallery-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    grid-column: span 1;
    grid-row: span 1;
}

/* Span variations */
.gallery-item.span-2x1 {
    grid-column: span 2;
}

.gallery-item.span-1x2 {
    grid-row: span 2;
}

.gallery-item.span-2x2 {
    grid-column: span 2;
    grid-row: span 2;
}

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

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

/* Gallery Skeleton Loading Placeholder */
.gallery-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 25%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.03) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

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

/* Optional: Hover overlay with prompt */
.gallery-item::after {
    content: attr(data-prompt);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    color: white;
    font-size: 13px;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gallery-item:hover::after {
    opacity: 1;
}

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

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-secondary);
}

.empty-state a {
    color: var(--accent);
    text-decoration: none;
}

.empty-state a:hover {
    text-decoration: underline;
}

.maintenance-state {
    max-width: 680px;
    margin: 40px auto;
    padding: 32px 24px;
    border: 1px solid rgba(240, 189, 85, 0.35);
    border-radius: 14px;
    background: rgba(240, 189, 85, 0.08);
}

.maintenance-state h3 {
    margin: 0 0 12px;
    color: #f0bd55;
    font-size: 1.15rem;
    font-weight: 700;
}

.maintenance-state p {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Load More - Hidden sentinel for infinite scroll */
.load-more-container {
    padding: 20px 0;
    text-align: center;
}

.load-more-container .btn-secondary {
    display: none;
}

/* Lightbox Overlay */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: auto;
    touch-action: pan-y;
}

.lightbox.show {
    opacity: 1;
}

/* Outer close button - hidden on desktop, shown on mobile if needed */
.lightbox-close {
    display: none;
}

/* Touch target improvements for mobile */
@media (max-width: 768px) {
    .lightbox-close {
        display: none;
    }
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: auto;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-prompt {
    margin-top: 20px;
    font-size: 16px;
    color: #f0f0f0;
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
}

.lightbox-meta {
    margin-top: 12px;
    font-size: 13px;
    color: #888;
    display: flex;
    gap: 16px;
}

/* Lightbox Actions Container */
.lightbox-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* Copy Prompt Button */
.btn-copy {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 12px 16px;
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
    border: 1px solid #a855f7;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

/* Touch target improvements for mobile */
@media (max-width: 768px) {
    .btn-copy {
        min-height: 48px;
        padding: 14px 16px;
    }
}

.btn-copy:hover {
    background: rgba(168, 85, 247, 0.2);
}

.btn-copy.copied {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    color: #22c55e;
}

/* Edit Button */
.btn-edit {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 12px 16px;
    background: rgba(34, 211, 238, 0.1);
    color: #22d3ee;
    border: 1px solid #22d3ee;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

/* Touch target improvements for mobile */
@media (max-width: 768px) {
    .btn-edit {
        min-height: 48px;
        padding: 14px 16px;
    }
}

.btn-edit:hover {
    background: rgba(34, 211, 238, 0.2);
}

/* Download Button */
.btn-download {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

/* Touch target improvements for mobile */
@media (max-width: 768px) {
    .btn-download {
        min-height: 48px;
        padding: 14px 16px;
    }
}

.btn-download:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Report Button */
.btn-report {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid #ef4444;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

/* Touch target improvements for mobile */
@media (max-width: 768px) {
    .btn-report {
        min-height: 48px;
        padding: 14px 16px;
    }
}

.btn-report:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Close button on image (mobile friendly) */
.btn-close-image {
    display: flex;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: background 0.2s;
}

.btn-close-image:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Report Modal - Success Message */
.success-message {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #22c55e;
    border-radius: 8px;
    color: #22c55e;
    font-size: 14px;
    font-weight: 500;
}

/* Pull to Refresh Indicator */
.pull-refresh-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: var(--accent, #a855f7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pull-refresh-indicator.visible {
    opacity: 1;
}

.pull-refresh-indicator.pulling {
    transform: translateX(-50%) scale(1);
}

.pull-refresh-indicator.ready {
    transform: translateX(-50%) scale(1.1);
    background: #22c55e;
}

.pull-refresh-indicator.spinning::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.pull-refresh-indicator:not(.spinning)::before {
    content: '↓';
    color: white;
    font-size: 20px;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.pull-refresh-indicator.ready:not(.spinning)::before {
    transform: rotate(180deg);
}

/* Gallery wrapper for positioning the refresh indicator */
.gallery-wrapper {
    position: relative;
    width: 100%;
    min-height: 100vh;
}

/* Lightbox Image Container for Zoom */
.lightbox-image-container {
    position: relative;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

/* Swipe Navigation Arrows */
.lightbox-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    opacity: 0;
    z-index: 10;
}

.lightbox:hover .lightbox-nav-arrow,
.lightbox.show .lightbox-nav-arrow {
    opacity: 0.7;
}

.lightbox-nav-arrow:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1 !important;
}

.lightbox-nav-arrow.prev {
    left: 20px;
}

.lightbox-nav-arrow.next {
    right: 20px;
}

/* Swipe hint indicator for mobile */
.swipe-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 5;
}

.swipe-hint.left {
    left: 20px;
}

.swipe-hint.right {
    right: 20px;
}

.swipe-hint.visible {
    opacity: 1;
}

.lightbox-image-container:active {
    cursor: grabbing;
}

.lightbox-image-container img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s ease-out;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
}

/* Generation Image Container for Zoom */
.generation-image-container {
    position: relative;
    overflow: hidden;
    touch-action: none;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border-radius: 8px;
}

.generation-image-container:active {
    cursor: grabbing;
}

.generation-image-container img {
    width: 100%;
    height: auto;
    transition: transform 0.1s ease-out;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
}

/* Zoom Indicator */
.zoom-indicator {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 10;
}

.zoom-indicator.visible {
    opacity: 1;
}

/* Reset Zoom Button */
.reset-zoom-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent, #a855f7);
    color: black;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s, background 0.2s;
    z-index: 10;
}

.reset-zoom-btn.visible {
    opacity: 1;
}

.reset-zoom-btn:hover {
    background: var(--accent-hover, #c084fc);
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-container {
        padding: 16px 8px 100px;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: auto;
        gap: 8px;
    }
    
    .gallery-item {
        aspect-ratio: 1;
    }
    
    /* Disable span variations on mobile for consistent 2-column grid */
    .gallery-item.span-2x1,
    .gallery-item.span-1x2,
    .gallery-item.span-2x2 {
        grid-column: span 1;
        grid-row: span 1;
    }

    /* Mobile lightbox - MUST be at end to override base styles */
    .lightbox {
        padding: 120px 16px 40px;
        align-items: flex-start;
        justify-content: flex-start;
    }
    
    .lightbox-content {
        max-width: 100%;
        max-height: none;
        margin-top: auto;
        margin-bottom: auto;
    }
    
    .lightbox-content img {
        max-height: 55vh;
    }
    
    .lightbox-prompt {
        font-size: 14px;
        margin-top: 12px;
    }
    
    .lightbox-meta {
        font-size: 12px;
        gap: 12px;
    }
    
    /* Lightbox actions - 2x2 grid on mobile */
    .lightbox-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-top: 16px;
        width: 100%;
        max-width: 280px;
    }
    
    .lightbox-actions .btn-copy,
    .lightbox-actions .btn-edit,
    .lightbox-actions .btn-download,
    .lightbox-actions .btn-report {
        min-height: 44px;
        height: 44px;
        padding: 8px 12px;
        justify-content: center;
        font-size: 12px;
        border-radius: 8px;
    }
    
    .lightbox-actions svg {
        width: 18px;
        height: 18px;
    }
}
