/* Styles pour l'overlay */
.preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top, rgba(18, 43, 34, 0.55) 0%, rgba(6, 15, 12, 0.92) 45%, rgba(4, 10, 8, 0.95) 100%);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 24px;
}

/* Styles pour le conteneur principal */
.preview-main-container {
    display: flex;
    align-items: stretch;
    background: linear-gradient(145deg, rgba(18, 27, 24, 0.98), rgba(10, 16, 14, 0.98));
    box-sizing: border-box;
    padding: 28px;
    max-width: 80%; /* Pour éviter que le conteneur dépasse de l'écran */
    max-height: 80%; /* Pour éviter que le conteneur dépasse de l'écran */
    position: relative; /* Pour positionner le bouton de fermeture */
    border-radius: 24px;
    border: 1px solid rgba(74, 179, 120, 0.35);
    box-shadow: 0 28px 64px rgba(0, 0, 0, 0.55);
    gap: 32px;
    overflow: auto;
}

/* Styles pour le conteneur d'image */
.preview-image-container {
    display: flex;
    align-items: center;
    justify-content: center; /* Centrer le contenu verticalement */
    height: 70dvh; /* La hauteur est 70% de la hauteur de la fenêtre */
    width: 70dvh; /* La largeur est égale à la hauteur pour obtenir un carré */
    background: linear-gradient(160deg, rgba(25, 43, 36, 0.65), rgba(15, 24, 21, 0.9));
    box-sizing: border-box;
    padding: 24px; /* Padding autour de l'image */
    border-radius: 18px;
    border: 1px solid rgba(74, 179, 120, 0.25);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45);
}

/* Styles pour l'image agrandie */
.preview-enlarged-img {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.65);
    border-radius: 12px;
    border: 1px solid rgba(74, 179, 120, 0.18);
    background-color: #020604;
}

/* Styles pour le conteneur d'informations */
.preview-info-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Aligner en haut */
    color: #ffffff;
    box-sizing: border-box;
    height: 65dvh; /* La hauteur du conteneur d'informations est égale à celle du conteneur d'image */
    width: 320px; /* Largeur définie explicitement en pixels */
    padding-right: 8px;
    gap: 24px;
}

/* Styles pour l'utilisateur */
.user-container {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.user-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: #0c1b15;
    background: linear-gradient(135deg, #4ab378, #39a069);
    box-shadow: 0 12px 24px rgba(58, 167, 110, 0.35);
    text-transform: uppercase;
}


/* Styles pour le lien utilisateur */
.user-login-link {
    color: #ffffff;
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.user-login-link:hover,
.user-login-link:focus-visible {
    background-color: rgba(74, 179, 120, 0.16);
    color: #ffffff;
    outline: none;
}

/* Styles pour le conteneur du prompt, job id, et format */
.prompt-container, .job-id-container, .format-container {
    width: 100%;
    margin-top: 20px;
}

.prompt-title-container, .format-title-container{
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative; /* Pour positionner le message de confirmation */
    border-bottom: 1px solid rgba(74, 179, 120, 0.15);
    padding-bottom: 6px;
}

.prompt-title, .format-title{
    font-weight: bold;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.prompt-text, .format-text {
    background: rgba(16, 34, 27, 0.82);
    padding: 14px;
    border-radius: 12px;
    margin-top: 12px;
    color: #ffffff;
    word-wrap: break-word;
    border: 1px solid rgba(74, 179, 120, 0.22);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    scrollbar-color: rgba(74, 179, 120, 0.45) rgba(15, 24, 21, 0.6);
    scrollbar-width: thin;
}


.format-product-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.format-product-item {
    background: rgba(18, 40, 31, 0.55);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid rgba(74, 179, 120, 0.16);
}

.format-product-name {
    font-weight: 600;
    margin-bottom: 6px;
    color: #ffffff;
}

.format-variant-list {
    margin: 0;
    padding-left: 18px;
    color: #ffffff;
}

.format-variant-item {
    margin: 4px 0;
    list-style: disc;
}

.prompt-text {
    max-height: 25dvh;
    overflow: auto;
}

.format-text {
    max-height: 20dvh; /* ≃ 10 % de la hauteur de l'écran */
    overflow-y: auto;
}

.prompt-text::-webkit-scrollbar,
.format-text::-webkit-scrollbar {
    width: 6px;
}

.prompt-text::-webkit-scrollbar-track,
.format-text::-webkit-scrollbar-track {
    background: rgba(10, 20, 16, 0.35);
    border-radius: 999px;
}

.prompt-text::-webkit-scrollbar-thumb,
.format-text::-webkit-scrollbar-thumb {
    background: rgba(74, 179, 120, 0.45);
    border-radius: 999px;
}

/* Styles pour le bouton de copie */
.copy-button {
    background: rgba(74, 179, 120, 0.14);
    border: 1px solid rgba(74, 179, 120, 0.45);
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    padding: 8px 12px; /* Padding horizontal et vertical */
    display: flex;
    align-items: center;
    border-radius: 8px; /* Optionnel : arrondir les coins */
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.copy-button:hover,
.copy-button:focus-visible {
    background: rgba(74, 179, 120, 0.25);
    color: #ffffff;
    border-color: rgba(74, 179, 120, 0.65);
    outline: none;
    transform: translateY(-1px);
}

.copy-button i {
    font-size: 16px; /* Taille intermédiaire de l'icône */
    pointer-events: none; /* Empêche l'icône de capturer les événements de clic */
    margin-right: 5px; /* Espace entre l'icône et le texte */
    color: inherit;
}

/* Styles pour le message de confirmation de copie */
.copy-confirmation {
    position: absolute;
    bottom: 100%; /* Positionner au-dessus du bouton */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(10, 26, 20, 0.95);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    white-space: nowrap; /* Pour éviter que le texte ne se casse sur plusieurs lignes */
    border: 1px solid rgba(74, 179, 120, 0.4);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* Styles pour le bouton de fermeture */
.close-button {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(7, 20, 15, 0.9);
    border: 1px solid rgba(74, 179, 120, 0.45);
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    padding: 6px; /* Carré */
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px; /* Optionnel : arrondir les coins */
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.close-button:hover,
.close-button:focus-visible {
    background-color: rgba(74, 179, 120, 0.16);
    color: #ffffff;
    border-color: rgba(74, 179, 120, 0.7);
    outline: none;
    transform: translateY(-1px);
}

.close-button i {
    font-size: 16px; /* Taille intermédiaire de l'icône */
}

/* Styles pour les boutons Use Prompt et Use Image */
.use-container {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    width: 100%;
    padding-top: 20px; /* Espace en haut des boutons */
    gap: 16px;
}

.use-button {
    background: linear-gradient(140deg, rgba(74, 179, 120, 0.92), rgba(66, 158, 106, 0.88));
    color: #03140c;
    border: none;
    padding: 12px;
    cursor: pointer;
    border-radius: 12px;
    width: 48%; /* Pour que les boutons occupent la même largeur et soient espacés */
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 16px 32px rgba(58, 167, 110, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.use-button:hover,
.use-button:focus-visible {
    background: linear-gradient(140deg, rgba(89, 207, 141, 0.95), rgba(74, 179, 120, 0.92));
    transform: translateY(-1px);
    box-shadow: 0 22px 40px rgba(58, 167, 110, 0.45);
    outline: none;
}

.preview-enlarge {
    cursor: zoom-in; /* Change le curseur en loupe */
}

.product-chooser-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(4px);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 9999;
        padding: 24px;
        animation: productChooserOverlayFade 0.2s ease;
}

.product-chooser-box {
        background: linear-gradient(155deg, rgba(28, 28, 28, 0.95), rgba(20, 20, 20, 0.98));
        border-radius: 16px;
        box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
        border: 1px solid rgba(255, 255, 255, 0.06);
        padding: 28px;
        max-width: 460px;
        width: min(100%, 460px);
        color: #f5f5f5;
        display: flex;
        flex-direction: column;
        gap: 20px;
        animation: productChooserBoxPop 0.25s ease;
}

.product-chooser-box h3 {
        margin: 0;
        font-size: 1.35rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        text-align: left;
}

.product-choice-list {
        display: flex;
        flex-direction: column;
        gap: 18px;
}

.product-choice-group {
        display: flex;
        flex-direction: column;
        gap: 12px;
        background: linear-gradient(160deg, rgba(56, 56, 56, 0.35), rgba(38, 38, 38, 0.4));
        border-radius: 14px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        padding: 18px;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.product-choice-group-header {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
}

.product-choice-group-name {
        font-size: 1.05rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        color: #ffffff;
}

.product-choice-group-count {
        font-size: 0.72rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: rgba(214, 221, 255, 0.75);
        background: rgba(112, 138, 255, 0.12);
        border: 1px solid rgba(112, 138, 255, 0.35);
        border-radius: 999px;
        padding: 2px 10px;
}

.product-choice-variants {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 12px;
        max-height: min(42vh, 320px);
        overflow-y: auto;
        padding-right: 4px;
}

.product-choice-button {
        width: 100%;
        padding: 16px 18px;
        background: linear-gradient(145deg, rgba(72, 72, 72, 0.55), rgba(46, 46, 46, 0.6));
        color: #ffffff;
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 12px;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        font: inherit;
        text-align: left;
        transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.product-choice-button:hover,
.product-choice-button:focus-visible {
        background: linear-gradient(140deg, rgba(104, 104, 104, 0.65), rgba(62, 62, 62, 0.7));
        border-color: rgba(112, 138, 255, 0.6);
        box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
        transform: translateY(-1px);
        outline: none;
}

.product-choice-button:focus-visible {
        outline: 2px solid rgba(112, 138, 255, 0.7);
        outline-offset: 2px;
}

.product-choice-name {
        font-size: 0.95rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        color: #ffffff;
}

.product-choice-description {
        font-size: 0.8rem;
        color: rgba(226, 226, 226, 0.75);
}

.product-choice-badges {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
}

.product-choice-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        padding: 4px 10px;
        font-size: 0.75rem;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.12);
        color: #dcdcdc;
}

.product-choice-badge--color {
        background: rgba(88, 144, 255, 0.12);
        border-color: rgba(88, 144, 255, 0.35);
        color: #b9d2ff;
}

.product-choice-badge--ratio {
        background: rgba(167, 127, 255, 0.14);
        border-color: rgba(167, 127, 255, 0.4);
        color: #e0d0ff;
}

.close-choice-button {
        align-self: center;
        padding: 8px 22px;
        font-size: 0.85rem;
        background: transparent;
        color: #ffffff;
        border: 1px solid rgba(255, 255, 255, 0.18);
        border-radius: 999px;
        cursor: pointer;
        transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.close-choice-button:hover,
.close-choice-button:focus-visible {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.35);
        color: #ffffff;
        transform: translateY(-1px);
        outline: none;
}

.close-choice-button:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.45);
        outline-offset: 3px;
}

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

@keyframes productChooserBoxPop {
        from {
                opacity: 0;
                transform: translateY(18px) scale(0.97);
        }
        to {
                opacity: 1;
                transform: translateY(0) scale(1);
        }
}

@media (max-width: 600px) {
        .product-chooser-box {
                width: 100%;
                padding: 24px 20px;
        }

        .product-choice-group {
                padding: 16px;
        }

        .product-choice-button {
                padding: 14px 16px;
        }

        .product-choice-variants {
                grid-template-columns: 1fr;
        }
}
