/**
 * BinGuru Image Popup Styles
 * Version: 1.0.0
 * 
 * Follows the binguru-minimal theme design patterns
 * with CSS custom properties and responsive design
 */

/* CSS Custom Properties for consistency with theme */
:root {
    --popup-overlay-bg: rgba(0, 0, 0, 0.9);
    --popup-content-bg: var(--color-white, #ffffff);
    --popup-text-color: var(--color-text, #333333);
    --popup-border-radius: var(--border-radius, 8px);
    --popup-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --popup-z-index: 9999;
    --popup-animation-duration: 300ms;
    --popup-animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Button styles */
    --popup-button-size: 44px;
    --popup-button-bg: rgba(255, 255, 255, 0.9);
    --popup-button-hover-bg: rgba(255, 255, 255, 1);
    --popup-button-text: #333333;
    --popup-button-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    
    /* Navigation arrows */
    --popup-arrow-size: 20px;
    --popup-arrow-color: #333333;
    
    /* Counter and caption */
    --popup-info-bg: rgba(0, 0, 0, 0.7);
    --popup-info-text: #ffffff;
    --popup-info-padding: 8px 16px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --popup-content-bg: var(--color-dark-bg, #1a1a1a);
        --popup-text-color: var(--color-dark-text, #ffffff);
        --popup-button-bg: rgba(0, 0, 0, 0.8);
        --popup-button-hover-bg: rgba(0, 0, 0, 0.9);
        --popup-button-text: #ffffff;
        --popup-arrow-color: #ffffff;
    }
}

/* Main popup overlay */
.binguru-image-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--popup-overlay-bg);
    z-index: var(--popup-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--popup-animation-duration) var(--popup-animation-easing),
                visibility var(--popup-animation-duration) var(--popup-animation-easing);
    cursor: pointer;
    padding: 20px;
    box-sizing: border-box;
}

.binguru-image-popup.active {
    opacity: 1;
    visibility: visible;
}

/* Popup content container */
.binguru-image-popup-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: default;
    transform: scale(0.8);
    transition: transform var(--popup-animation-duration) var(--popup-animation-easing);
}

.binguru-image-popup.active .binguru-image-popup-content {
    transform: scale(1);
}

/* Image container */
.binguru-image-popup-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    background: var(--popup-content-bg);
    border-radius: var(--popup-border-radius);
    box-shadow: var(--popup-shadow);
    overflow: hidden;
}

/* Main image */
.binguru-image-popup-image {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    transition: opacity var(--popup-animation-duration) var(--popup-animation-easing);
}

.binguru-image-popup-image.loading {
    opacity: 0.5;
}

/* Loading indicator */
.binguru-image-popup-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--popup-info-text);
    font-size: 16px;
    font-weight: 500;
    opacity: 0;
    transition: opacity var(--popup-animation-duration) var(--popup-animation-easing);
}

.binguru-image-popup-loading.active {
    opacity: 1;
}

/* Close button */
.binguru-image-popup-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: var(--popup-button-size);
    height: var(--popup-button-size);
    background: var(--popup-button-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--popup-button-shadow);
    transition: all var(--popup-animation-duration) var(--popup-animation-easing);
    z-index: 10;
}

.binguru-image-popup-close:hover {
    background: var(--popup-button-hover-bg);
    transform: scale(1.1);
}

.binguru-image-popup-close:focus {
    outline: 2px solid var(--color-primary, #007cba);
    outline-offset: 2px;
}

.binguru-image-popup-close::before {
    content: '×';
    font-size: 24px;
    font-weight: bold;
    color: var(--popup-button-text);
    line-height: 1;
}

/* Navigation buttons */
.binguru-image-popup-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: var(--popup-button-size);
    height: var(--popup-button-size);
    background: var(--popup-button-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--popup-button-shadow);
    transition: all var(--popup-animation-duration) var(--popup-animation-easing);
    opacity: 0;
    visibility: hidden;
    z-index: 10;
}

.binguru-image-popup-nav.visible {
    opacity: 1;
    visibility: visible;
}

.binguru-image-popup-nav:hover {
    background: var(--popup-button-hover-bg);
    transform: translateY(-50%) scale(1.1);
}

.binguru-image-popup-nav:focus {
    outline: 2px solid var(--color-primary, #007cba);
    outline-offset: 2px;
}

.binguru-image-popup-prev {
    left: -60px;
}

.binguru-image-popup-next {
    right: -60px;
}

/* Navigation arrows */
.binguru-image-popup-nav::before {
    content: '';
    width: var(--popup-arrow-size);
    height: var(--popup-arrow-size);
    border: 2px solid var(--popup-arrow-color);
    border-right: none;
    border-bottom: none;
    transform: rotate(-45deg);
}

.binguru-image-popup-next::before {
    transform: rotate(135deg);
}

/* Image counter */
.binguru-image-popup-counter {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--popup-info-bg);
    color: var(--popup-info-text);
    padding: var(--popup-info-padding);
    border-radius: var(--popup-border-radius);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity var(--popup-animation-duration) var(--popup-animation-easing);
}

.binguru-image-popup-counter.visible {
    opacity: 1;
}

/* Image caption */
.binguru-image-popup-caption {
    margin-top: 16px;
    background: var(--popup-info-bg);
    color: var(--popup-info-text);
    padding: var(--popup-info-padding);
    border-radius: var(--popup-border-radius);
    font-size: 14px;
    line-height: 1.4;
    max-width: 80vw;
    text-align: center;
    opacity: 0;
    transition: opacity var(--popup-animation-duration) var(--popup-animation-easing);
}

.binguru-image-popup-caption.visible {
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .binguru-image-popup {
        padding: 10px;
    }
    
    .binguru-image-popup-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .binguru-image-popup-image {
        max-height: 70vh;
    }
    
    .binguru-image-popup-close {
        top: -40px;
        right: -10px;
    }
    
    .binguru-image-popup-prev {
        left: -50px;
    }
    
    .binguru-image-popup-next {
        right: -50px;
    }
    
    .binguru-image-popup-counter {
        top: -35px;
        font-size: 12px;
    }
    
    .binguru-image-popup-caption {
        font-size: 13px;
        max-width: 90vw;
        margin-top: 12px;
    }
}

@media (max-width: 480px) {
    .binguru-image-popup {
        padding: 5px;
    }
    
    .binguru-image-popup-image {
        max-height: 60vh;
    }
    
    .binguru-image-popup-close {
        top: -35px;
        right: -5px;
        width: 36px;
        height: 36px;
    }
    
    .binguru-image-popup-close::before {
        font-size: 20px;
    }
    
    .binguru-image-popup-nav {
        width: 36px;
        height: 36px;
    }
    
    .binguru-image-popup-prev {
        left: -40px;
    }
    
    .binguru-image-popup-next {
        right: -40px;
    }
    
    .binguru-image-popup-nav::before {
        width: 16px;
        height: 16px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .binguru-image-popup,
    .binguru-image-popup-content,
    .binguru-image-popup-image,
    .binguru-image-popup-close,
    .binguru-image-popup-nav,
    .binguru-image-popup-counter,
    .binguru-image-popup-caption,
    .binguru-image-popup-loading {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --popup-overlay-bg: rgba(0, 0, 0, 0.95);
        --popup-button-bg: #ffffff;
        --popup-button-hover-bg: #f0f0f0;
        --popup-button-text: #000000;
        --popup-arrow-color: #000000;
        --popup-shadow: 0 0 0 2px #ffffff;
    }
}

/* Print styles */
@media print {
    .binguru-image-popup {
        display: none !important;
    }
}

/* Focus management for accessibility */
.binguru-image-popup:focus {
    outline: none;
}

.binguru-image-popup-content:focus {
    outline: 2px solid var(--color-primary, #007cba);
    outline-offset: 4px;
}

/* Animation keyframes for loading */
@keyframes binguru-popup-pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

.binguru-image-popup-loading.pulse {
    animation: binguru-popup-pulse 1.5s ease-in-out infinite;
}