/**
 * Styles pour l'optimisation des photos asynchrones
 * - Thumbnails optimisés
 * - États de chargement
 * - Modal de visualisation
 * - Animations fluides
 */

/* Conteneur des photos */
.photo-container {
    position: relative;
    width: 100%;
    height: 200px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Thumbnail principal */
.photo-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.3s ease;
    cursor: pointer;
}

.photo-thumbnail:hover {
    transform: scale(1.05);
}

/* Compteur de photos */
.photo-counter {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
}

/* Placeholder quand pas de photo */
.no-photo-placeholder {
    color: #6c757d;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* Indicateurs de chargement */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    z-index: 3;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Erreur de chargement */
.photo-error {
    color: #dc3545;
    font-size: 12px;
    text-align: center;
    padding: 20px;
}

/* États de chargement */
[data-furniture-id] {
    transition: opacity 0.3s ease;
}

[data-furniture-id].thumbnails-loaded {
    opacity: 1;
}

[data-furniture-id]:not(.thumbnails-loaded) {
    opacity: 0.7;
}

/* Modal de visualisation */
.photo-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

/* Backdrop pour la galerie de photos - NE PAS APPLIQUER AUX MODALS BOOTSTRAP */
.photo-gallery-modal .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

/* Contenu du modal de galerie - NE PAS APPLIQUER AUX MODALS BOOTSTRAP */
.photo-gallery-modal .modal-content {
    position: relative !important;
    background: white !important;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 10000 !important;
    pointer-events: auto;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Galerie principale */
.photo-gallery {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    max-height: 70vh;
}

.gallery-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gallery-main img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.gallery-prev,
.gallery-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-prev {
    left: 20px;
}

.gallery-next {
    right: 20px;
}

.gallery-prev:hover,
.gallery-next:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Thumbnails de la galerie */
.gallery-thumbnails {
    display: flex;
    gap: 8px;
    padding: 15px;
    overflow-x: auto;
    justify-content: center;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.gallery-thumbnails img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.gallery-thumbnails img:hover {
    opacity: 1;
    transform: scale(1.1);
}

.gallery-thumbnails img.active {
    opacity: 1;
    border-color: #007bff;
    transform: scale(1.1);
}

/* Compteur de la galerie */
.gallery-counter {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .gallery-prev,
    .gallery-next {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .gallery-prev {
        left: 10px;
    }
    
    .gallery-next {
        right: 10px;
    }
    
    .gallery-thumbnails img {
        width: 50px;
        height: 50px;
    }
}

/* Animation d'entrée */
.photo-container {
    animation: fadeInUp 0.5s ease-out;
}

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

/* Optimisation des performances */
.photo-thumbnail {
    will-change: transform;
    backface-visibility: hidden;
}

/* Skeleton loading */
.photo-container:not(.thumbnails-loaded)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    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;
    }
}
