/* backend/core/static/css/blog-gallery.css */

/* ===== ОСНОВНЫЕ СТИЛИ ГАЛЕРЕИ ===== */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
    position: relative;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.gallery-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05);
}

/* Подпись к изображению */
.gallery-item figcaption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 20px 15px 15px;
    font-size: 14px;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* ===== LIGHTBOX СТИЛИ ===== */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-image {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    display: block;
}

.lightbox-caption {
    padding: 20px;
    background: white;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    text-align: center;
}

/* Кнопки навигации */
.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    z-index: 10001;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 10001;
}

.lightbox-prev {
    left: 15px;
    border-radius: 0 25px 25px 0;
}

.lightbox-next {
    right: 15px;
    border-radius: 25px 0 0 25px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Счетчик изображений */
.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10001;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .image-gallery,
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        margin: 20px 0;
    }
    
    .gallery-image {
        height: 200px;
    }
    
    .lightbox-content {
        max-width: 95%;
        max-height: 95%;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .lightbox-close {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .image-gallery,
    .gallery-grid {
        gap: 10px;
        margin: 15px 0;
    }
    
    .gallery-image {
        height: 180px;
    }
    
    .gallery-item figcaption {
        font-size: 12px;
        padding: 15px 10px 10px;
    }
}

/* ===== СПЕЦИАЛЬНЫЕ КЛАССЫ ===== */
.gallery-2-cols {
    grid-template-columns: repeat(2, 1fr) !important;
}

.gallery-3-cols {
    grid-template-columns: repeat(3, 1fr) !important;
}

.gallery-4-cols {
    grid-template-columns: repeat(4, 1fr) !important;
}

@media (max-width: 768px) {
    .gallery-2-cols,
    .gallery-3-cols,
    .gallery-4-cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 480px) {
    .gallery-2-cols,
    .gallery-3-cols,
    .gallery-4-cols {
        grid-template-columns: 1fr !important;
    }
}

/* ===== АНИМАЦИИ ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: scale(0.8);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

.lightbox.active {
    animation: fadeIn 0.3s ease;
}

.lightbox-content {
    animation: slideIn 0.3s ease;
}

/* ===== ЗАГРУЗКА ИЗОБРАЖЕНИЙ ===== */
.gallery-image.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* ===== ИНДИКАТОР ГАЛЕРЕИ В РЕДАКТОРЕ ===== */
.blog-content .image-gallery::before {
    content: "🖼️ Галерея изображений";
    position: absolute;
    top: -15px;
    left: 0;
    background: #0073aa;
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
}