/**
 * KS - Image à la Une - Styles Frontend
 * Auteur: Stéphane Agnus - Karting-Sud.com
 */

/* Widget Container */
.ks-image-une-widget-content {
    position: relative;
    overflow: hidden;
    width: 100% !important;
    max-width: 100% !important;
}

/* Correction pour éviter width: 0 des thèmes */
.widget_ks_image_une_widget {
    width: 100% !important;
}

/* Image principale */
.ks-image-une-widget-content img,
.ks-image-une img {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
    border-radius: 4px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

/* Effet hover sur l'image */
.ks-image-une-link:hover img,
.ks-image-une-widget-content a:hover img,
.ks-image-une-widget-content img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Lightbox Overlay */
.ks-lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    cursor: pointer;
    animation: ks-fadeIn 0.3s ease;
}

.ks-lightbox-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image dans la lightbox */
.ks-lightbox-image {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    animation: ks-zoomIn 0.3s ease;
    cursor: default;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

/* Bouton fermer */
.ks-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000000;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    line-height: 1;
}

.ks-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Animations */
@keyframes ks-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Animation de fermeture */
.ks-lightbox-overlay.closing {
    animation: ks-fadeOut 0.3s ease;
}

.ks-lightbox-overlay.closing .ks-lightbox-image {
    animation: ks-zoomOut 0.3s ease;
}

@keyframes ks-fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

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

/* Lien sans soulignement */
.ks-image-une-link {
    display: block;
    text-decoration: none;
    line-height: 0;
}

/* Caption/Titre de l'image */
.ks-image-une-caption {
    margin: 10px 0 0 0;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background: #f9f9f9;
    border-left: 3px solid #2271b1;
    border-radius: 0 4px 4px 0;
}

/* Info de debug (visible seulement pour les admins) */
.ks-image-une-debug {
    font-size: 11px;
    color: #666;
    margin-top: 5px;
    padding: 5px 8px;
    background: #f0f0f1;
    border-radius: 3px;
    font-family: monospace;
}

/* Shortcode Container */
.ks-image-une {
    margin: 20px 0;
    text-align: center;
}

.ks-image-une img {
    margin: 0 auto;
}

/* Responsive */
@media screen and (max-width: 782px) {
    .ks-image-une-caption {
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* Animation de chargement (optionnelle) */
.ks-image-une-widget-content.loading {
    min-height: 200px;
    position: relative;
}

.ks-image-une-widget-content.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2271b1;
    border-radius: 50%;
    animation: ks-spin 1s linear infinite;
}

@keyframes ks-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Style pour sidebar étroite */
.widget-area .ks-image-une-widget-content {
    max-width: 100%;
}

/* Effet de fondu au chargement */
.ks-image-une img,
.ks-image-une-widget-content img {
    animation: ks-fadeIn 0.5s ease-in;
}

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

/* Styles pour thèmes sombres (optionnel) */
@media (prefers-color-scheme: dark) {
    .ks-image-une-caption {
        background: #2c2c2c;
        color: #e0e0e0;
        border-left-color: #4a90e2;
    }
    
    .ks-image-une-debug {
        background: #2c2c2c;
        color: #999;
    }
}

/* Personnalisation selon la largeur du widget */
@media screen and (min-width: 1200px) {
    .widget-area .ks-image-une-widget-content {
        /* Ajustements pour grandes sidebars */
    }
}

/* Support pour images très hautes */
.ks-image-une-widget-content img {
    max-height: 600px;
    object-fit: cover;
    width: 100%;
}

/* Centrage dans le widget */
.ks-image-une-widget {
    text-align: center;
}

/* Espacement du widget */
.ks-image-une-widget .widget-title {
    margin-bottom: 15px;
}

/* Classes utilitaires personnalisables */
.ks-image-rounded {
    border-radius: 12px !important;
}

.ks-image-shadow {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.ks-image-bordered {
    border: 2px solid #ddd;
    padding: 4px;
    background: #fff;
}

.ks-image-grayscale {
    filter: grayscale(100%);
    transition: filter 0.3s ease;
}

.ks-image-grayscale:hover {
    filter: grayscale(0%);
}
