/* ========================================
   TELEGRAM-STYLE IMAGE PREVIEW MODAL
   Full-screen lightbox with blur-up loading
   ======================================== */

/* Modal Container */
.telegram-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    animation: fadeIn 0.2s ease;
}

.telegram-image-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Dark Overlay */
.telegram-image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1;
}

/* Content Container */
.telegram-image-modal-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Close Button */
.telegram-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.telegram-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.telegram-modal-close:active {
    transform: scale(0.95);
}

/* Download Button */
.telegram-modal-download {
    position: absolute;
    top: 20px;
    right: 80px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    text-decoration: none;
    backdrop-filter: blur(10px);
}

.telegram-modal-download:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    color: white;
}

.telegram-modal-download:active {
    transform: scale(0.95);
}

/* Navigation Arrows (for gallery) */
.telegram-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.telegram-modal-prev {
    left: 40px;
}

.telegram-modal-next {
    right: 40px;
}

.telegram-modal-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.telegram-modal-nav:active {
    transform: translateY(-50%) scale(0.95);
}

/* Image Container */
.telegram-image-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Thumbnail (blur-up placeholder) */
.telegram-preview-thumb {
    position: absolute;
    max-width: 90vw;
    max-height: 90vh;
    filter: blur(20px);
    transform: scale(1.1);
    opacity: 0.8;
    z-index: 1;
}

/* Full Resolution Image */
.telegram-preview-full {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    cursor: default;
}

.telegram-preview-full.loaded {
    opacity: 1;
}

/* Hide thumbnail when full image loads */
.telegram-preview-full.loaded ~ .telegram-preview-thumb {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Loading Spinner */
.telegram-image-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    color: rgba(255, 255, 255, 0.8);
    z-index: 3;
}

.telegram-image-loading.hidden {
    display: none;
}

/* Image Info (filename, size) */
.telegram-image-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-size: 13px;
    display: flex;
    gap: 12px;
    align-items: center;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.telegram-image-filename {
    font-weight: 500;
}

.telegram-image-size {
    color: rgba(255, 255, 255, 0.7);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .telegram-modal-close,
    .telegram-modal-download {
        top: 10px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .telegram-modal-download {
        right: 60px;
    }
    
    .telegram-modal-nav {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .telegram-modal-prev {
        left: 20px;
    }
    
    .telegram-modal-next {
        right: 20px;
    }
    
    .telegram-image-container {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .telegram-preview-thumb,
    .telegram-preview-full {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .telegram-image-info {
        bottom: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Light Theme Adjustments */
[data-theme="light"] .telegram-image-modal-overlay {
    background: rgba(255, 255, 255, 0.98);
}

[data-theme="light"] .telegram-modal-close,
[data-theme="light"] .telegram-modal-download,
[data-theme="light"] .telegram-modal-nav {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1c1e21;
}

[data-theme="light"] .telegram-modal-close:hover,
[data-theme="light"] .telegram-modal-download:hover,
[data-theme="light"] .telegram-modal-nav:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #1c1e21;
}

[data-theme="light"] .telegram-image-loading {
    color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .telegram-image-info {
    background: rgba(255, 255, 255, 0.9);
    color: #1c1e21;
}

[data-theme="light"] .telegram-image-size {
    color: rgba(0, 0, 0, 0.5);
}
