/* public/assets/css/image-selector.css */

/* Style de base pour l'overlay de la modale, assure le centrage */
.is-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex; /* Utilise Flexbox pour centrer */
    align-items: center; /* Centre verticalement */
    justify-content: center; /* Centre horizontalement */
    z-index: 1050; /* Au-dessus des autres éléments */
    padding: 1rem;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

/* Contenu de la modale */
.is-modal-content {
    background-color: #1e1e1e;
    color: #ffffff;
    border-radius: 8px;
    width: 100%;
    max-width: 700px; /* Largeur maximale */
    max-height: 90vh; /* Hauteur maximale */
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    animation: is-fade-in 0.3s ease-out;
}

/* Contenu de la modale de recadrage, légèrement plus grand */
.is-modal-content.is-cropper-content {
    max-width: 800px;
}

@keyframes is-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.is-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid #333;
}

.is-modal-header h2 {
    margin: 0;
    font-size: 1.25em;
    font-weight: 600;
}

.is-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.is-close-btn:hover {
    color: #fff;
}

.is-modal-body {
    padding: 25px;
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Empêche le corps lui-même de défiler */
}

.is-tabs {
    display: flex;
    border-bottom: 1px solid #333;
    margin-bottom: 25px;
    flex-shrink: 0; 
}

.is-tab-link {
    background: none;
    border: none;
    color: #aaa;
    padding: 12px 18px;
    cursor: pointer;
    font-size: 1em;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px; /* Aligne avec la bordure inférieure */
    transition: color 0.2s, border-color 0.2s;
}

.is-tab-link.active {
    color: #fff;
    border-bottom-color: #fff;
}

.is-tab-content {
    display: none;
    flex-grow: 1; /* Permet à la zone de contenu de remplir l'espace restant */
    overflow-y: auto; /* Active le défilement uniquement dans cette zone */
    padding-right: 10px; /* Ajoute un espace pour que le contenu ne soit pas sous la scrollbar */
}

.is-tab-content.active {
    display: block;
}

/* MODIFICATION: Passage en Grid Layout pour une galerie justifiée */
.is-gallery-grid {
    display: grid;
    gap: 15px;
    /* Crée des colonnes responsives. Chaque colonne fait au moins 120px
       et peut grandir pour remplir l'espace. auto-fit s'assure que
       l'espace vide est distribué, justifiant les lignes pleines. */
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    /* Les lignes s'adaptent à la hauteur du contenu */
    grid-auto-rows: min-content;
}

.is-gallery-item {
    position: relative;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    background-color: #2a2a2a;
    /* La hauteur n'est plus fixe, elle dépend du ratio et de la largeur de la colonne */
}

/* MODIFICATION: On cible les types d'images pour leur donner une taille de colonne et un ratio */
.is-gallery-item[data-image-type="banner"] {
    grid-column: span 2; /* Les bannières essaient de prendre 2 colonnes */
    aspect-ratio: 16 / 9;
}

.is-gallery-item[data-image-type="avatar"] {
    grid-column: span 1; /* Les avatars prennent 1 colonne */
    aspect-ratio: 1 / 1;
}

/* Fallback pour les images sans dimensions ou type connu */
.is-gallery-item:not([data-image-type]) {
    grid-column: span 1;
    aspect-ratio: 1 / 1;
}

.is-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.is-gallery-item:hover img {
    transform: scale(1.05);
    opacity: 0.7;
}

/* Style pour le bouton de suppression sur les images de la galerie */
.is-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
    z-index: 10;
    font-size: 14px;
}

.is-gallery-item:hover .is-delete-btn {
    opacity: 1;
    transform: scale(1);
}

.is-delete-btn:hover {
    background-color: #dc3545;
    transform: scale(1.1);
}

.is-delete-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
}


/* Zone d'upload */
.is-upload-area {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 50px;
    text-align: center;
    color: #aaa;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.is-upload-area.active,
.is-upload-area:hover {
    background-color: #2a2a2a;
    border-color: #666;
}

.is-upload-area i {
    font-size: 2.5em;
    color: #666;
}

.is-upload-info {
    font-size: 0.9em;
    color: #aaa;
    text-align: center;
    margin-bottom: 15px; /* Espace avant la boîte de téléversement */
}

/* Styles du recadreur */
.is-cropper-container {
    width: 100%;
    height: 45vh;
    min-height: 300px;
    background-color: #111;
    margin-bottom: 20px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#is-cropper-canvas {
    cursor: grab;
}
#is-cropper-canvas:active {
    cursor: grabbing;
}

.is-cropper-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

#is-zoom-slider {
    width: 100%;
    cursor: pointer;
}

.is-modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #333;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Style pour le message d'erreur */
.is-error-message {
    background-color: #5c1a1a;
    color: #ffc2c2;
    border: 1px solid #a83c3c;
    border-radius: 5px;
    padding: 10px 15px;
    flex-grow: 1;
    text-align: left;
    font-size: 0.9em;
    margin-right: auto;
}

.is-error-message-selector {
    margin-bottom: 15px;
    flex-grow: 0;
    width: 100%;
    box-sizing: border-box;
}


/* Styles pour les boutons dans le footer de la modale */
.is-modal-footer .btn {
    padding: 10px 20px;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s, border-color 0.2s;
}

.is-modal-footer .btn:active {
    transform: scale(0.98);
}

.is-modal-footer .btn-secondary {
    background-color: #444;
    color: #fff;
    border-color: #555;
}
.is-modal-footer .btn-secondary:hover {
    background-color: #555;
    border-color: #666;
}

.is-modal-footer .btn-primary {
    background-color: #fff;
    color: #1e1e1e;
    border-color: #fff;
}
.is-modal-footer .btn-primary:hover {
    background-color: #e0e0e0;
}

.is-modal-footer .btn:disabled {
    background-color: #333;
    color: #777;
    cursor: not-allowed;
    border-color: #333;
}

.is-tab-content::-webkit-scrollbar {
    width: 8px;
}

.is-tab-content::-webkit-scrollbar-track {
    background: transparent; /* Pas de fond pour la piste */
}

.is-tab-content::-webkit-scrollbar-thumb {
    background-color: #aaa; /* Couleur de la barre */
    border-radius: 10px; /* Barre arrondie */
}

.is-tab-content::-webkit-scrollbar-thumb:hover {
    background-color: #ccc; /* Couleur au survol */
}
