/* ===========================================
   Modal d'amélioration IA (élément partagé : Elements/Ads/ai_improvement_modal.ctp)
   Structure flex header / body scrollable / footer fixe pour éviter que
   le contenu (éditeurs Quill) ne chevauche les boutons d'action.
   =========================================== */

.ai-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 40px 0;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    overflow-y: auto;
}

.ai-modal-dialog {
    position: relative;
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    max-height: calc(100vh - 80px); /* ne dépasse jamais la hauteur de l'écran */
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden; /* le scroll se fait dans .ai-modal-body */
}

.ai-modal-close {
    position: absolute;
    top: 12px;
    right: 15px;
    z-index: 2;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #666;
    cursor: pointer;
}

.ai-modal-header {
    flex: 0 0 auto;
    padding: 24px 30px 0;
}

.ai-modal-header h2 {
    margin: 0 0 20px;
    padding-bottom: 10px;
    padding-right: 30px; /* évite le chevauchement avec la croix de fermeture */
    color: #333;
    border-bottom: 2px solid #007bff;
}

.ai-modal-body {
    flex: 1 1 auto;
    overflow-y: auto; /* seule zone scrollable */
    padding: 6px 30px 24px;
}

.ai-modal-footer {
    flex: 0 0 auto;
    padding: 16px 30px;
    text-align: center;
    background-color: #fff;
    border-top: 1px solid #dee2e6;
}

.ai-footer-btn {
    margin: 0 6px;
    padding: 10px 20px;
}

/* Aperçu de l'annonce à l'étape 2 (modale #ai-preview-overlay) : rendu du
   titre + description comme sur la page publique, en police Raleway. */
.ai-preview-dialog {
    max-width: 760px;
}

.ai-preview-ad-title {
    margin: 0 0 18px;
    font-family: 'Raleway', Arial, sans-serif;
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1.3;
    color: #111;
}

.ai-preview-label {
    margin-bottom: 10px;
    color: #ee4e01;
    font-size: 1.05em;
    font-weight: 700;
}

#ai-preview-ad-desc {
    font-family: 'Raleway', Arial, sans-serif;
    color: #444;
}

/* Bloque le défilement de la page tant que l'aperçu est ouvert. */
body.ai-preview-open {
    overflow: hidden;
}

/* Bloc d'options (mode + orientations + générer/régénérer) — empilés verticalement */
.ai-modal-options {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #f6faff 0%, #eaf2ff 100%);
    border: 1px solid #d6e4ff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 86, 179, 0.05);
}

.ai-modal-options .ai-option {
    display: flex;
    flex-direction: column;
}

.ai-modal-options .ai-option-mode,
.ai-modal-options .ai-option-instructions {
    flex: 0 0 auto;
    width: 100%;
}

.ai-modal-options .ai-option-actions {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

.ai-modal-options label {
    margin-bottom: 7px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #1e3a5f;
}

.ai-mode-select {
    width: 100%;
    height: auto;
    line-height: 1.4;
    padding: 11px 38px 11px 13px;
    font-size: 14px;
    color: #1f2d3d;
    box-sizing: border-box;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23607089' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 15px;
    border: 1px solid #c2d6f5;
    border-radius: 9px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-mode-select:hover {
    border-color: #93b4ec;
}

.ai-mode-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.16);
}

.ai-instructions {
    width: 100%;
    padding: 11px 13px;
    font-size: 14px;
    color: #1f2d3d;
    line-height: 1.5;
    background-color: #fff;
    border: 1px solid #c2d6f5;
    border-radius: 9px;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-instructions::placeholder {
    color: #9aa7b8;
}

.ai-instructions:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.16);
}

/* Boutons Générer / Régénérer (priment sur le .btn de base, sans toucher au display géré par les états) */
.ai-modal-options .ai-generate-btn,
.ai-modal-options .ai-regenerate-btn {
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s, border-color 0.15s, transform 0.05s;
}

.ai-modal-options .ai-generate-btn {
    color: #fff;
    background: linear-gradient(135deg, #1e8bff 0%, #0062cc 100%);
    box-shadow: 0 2px 8px rgba(0, 98, 204, 0.28);
}

.ai-modal-options .ai-generate-btn:hover {
    background: linear-gradient(135deg, #0d7bf5 0%, #00509f 100%);
}

.ai-modal-options .ai-generate-btn:active {
    transform: translateY(1px);
}

.ai-modal-options .ai-regenerate-btn {
    color: #0062cc;
    background: #fff;
    border-color: #c2d6f5;
}

.ai-modal-options .ai-regenerate-btn:hover {
    background: #f0f6ff;
    border-color: #93b4ec;
}

.ai-modal-options .ai-generate-btn i,
.ai-modal-options .ai-regenerate-btn i {
    margin-right: 6px;
}

.ai-modal-options button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.ai-regenerate-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #0062cc;
    white-space: nowrap;
}

/* États de la modale.
   Par défaut (aucune classe d'état, ex. flux public) = comportement "résultat" :
   le bouton "Générer" est masqué, la comparaison + le pied sont visibles. */
#ai-generate {
    display: none;
}

/* État "options" (étape intermédiaire admin) : on ne montre que les options + "Générer" */
.ai-state-options #ai-generate {
    display: inline-block;
}
.ai-state-options #ai-regenerate,
.ai-state-options .ai-modal-compare,
.ai-state-options .ai-modal-footer {
    display: none !important;
}

@media (max-width: 768px) {
    .ai-modal-options .ai-option-mode,
    .ai-modal-options .ai-option-instructions,
    .ai-modal-options .ai-option-actions {
        flex: 1 1 100%;
    }
    .ai-modal-options .ai-option-actions .ai-generate-btn,
    .ai-modal-options .ai-option-actions .ai-regenerate-btn {
        flex: 1 1 auto;
    }
}

.ai-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.ai-modal-grid h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.ai-col-original h3 {
    color: #666;
}

.ai-col-improved h3 {
    color: #007bff;
}

.ai-original-title {
    padding: 10px;
    min-height: 40px;
    color: #333;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.ai-improved-title {
    width: 100%;
    padding: 10px;
    min-height: 40px;
    font-size: 14px;
    color: #333;
    background-color: #e7f3ff;
    border: 1px solid #007bff;
    border-radius: 4px;
    box-sizing: border-box;
}

.ai-quill-original,
.ai-quill-improved {
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    border-radius: 4px;
}

.ai-quill-original {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

.ai-quill-improved {
    background-color: #e7f3ff;
    border: 1px solid #007bff;
}

/* Borne la hauteur des éditeurs Quill au sein du corps scrollable */
.ai-modal-body .ql-container {
    max-height: 42vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .ai-modal-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .ai-modal-body .ql-container {
        max-height: 30vh;
    }

    .ai-quill-original,
    .ai-quill-improved {
        min-height: 180px;
    }
}


/* Styles pour l'éditeur Quill de l'amélioration IA */

#ai-improved-text .ql-editor {
    font-size: 14px !important;
    color: #333 !important;
    line-height: 1.6 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    background-color: transparent !important;
    background: transparent !important;
}

#ai-improved-text .ql-editor * {
    font-family: inherit !important;
    box-sizing: border-box !important;
    background-color: transparent !important;
}

#ai-improved-text .ql-editor h1 {
    font-size: 2.5em !important;
    font-weight: bold !important;
    margin: 0.67em 0 !important;
    color: #333 !important;
}

#ai-improved-text .ql-editor h2 {
    font-size: 1.5em !important;
    font-weight: bold !important;
    margin: 0.5em 0 !important;
    color: #333 !important;
}

#ai-improved-text .ql-editor h3 {
    font-size: 1.17em !important;
    font-weight: bold !important;
    margin: 0.5em 0 !important;
    color: #333 !important;
}

#ai-improved-text .ql-editor h4 {
    font-size: 1em !important;
    font-weight: bold !important;
    margin: 0.5em 0 !important;
    color: #333 !important;
}

#ai-improved-text .ql-editor h5 {
    font-size: 0.83em !important;
    font-weight: bold !important;
    margin: 0.5em 0 !important;
    color: #333 !important;
}

#ai-improved-text .ql-editor h6 {
    font-size: 0.67em !important;
    font-weight: bold !important;
    margin: 0.5em 0 !important;
    color: #333 !important;
}

#ai-improved-text .ql-editor p {
    margin: 0.5em 0 !important;
    font-size: 14px !important;
    color: #333 !important;
}

#ai-improved-text .ql-editor ul,
#ai-improved-text .ql-editor ol {
    margin: 0.5em 0 !important;
    padding-left: 1.5em !important;
}

#ai-improved-text .ql-editor li {
    margin: 0.25em 0 !important;
    font-size: 14px !important;
    color: #333 !important;
}

#ai-improved-text .ql-editor strong {
    font-weight: bold !important;
}

#ai-improved-text .ql-editor em {
    font-style: italic !important;
}


/* ===========================================
   #8 (retour Daniel) — Rendu de la description.
   L'éditeur de saisie Quill (#original-text-quill, utilisé en création front
   et en admin) reprend la police du site (Raleway) et un gras marqué en
   quasi-noir, pour coller au rendu de la page publique de l'annonce
   (« Description de l'annonce », .search-result__comment ci-dessous).
   =========================================== */

#original-text-quill .ql-editor {
    font-family: 'Raleway', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #444;
}

#original-text-quill .ql-editor p {
    margin: 0.8em 0;
}

#original-text-quill .ql-editor ul,
#original-text-quill .ql-editor ol {
    margin: 0.8em 0;
    padding-left: 1.5em;
}

#original-text-quill .ql-editor li {
    margin: 0.4em 0;
    line-height: 1.6;
}

/* Gras nettement distinct du texte normal (quasi-noir), rendu « ChatGPT ». */
#original-text-quill .ql-editor strong,
#original-text-quill .ql-editor b {
    font-weight: 700;
    color: #111;
}


/* ===========================================
   Styles pour l'affichage des annonces améliorées par l'IA
   Ces styles s'appliquent au HTML généré (h2, h3, p, ul, li, strong)
   =========================================== */

.search-result__comment h2 {
    font-size: 1.4em;
    font-weight: 600;
    color: #2c3e50;
    margin: 1.2em 0 0.6em 0;
    padding-bottom: 0.3em;
    border-bottom: 2px solid #f39c12;
}

.search-result__comment h2:first-child {
    margin-top: 0;
}

.search-result__comment h3 {
    font-size: 1.15em;
    font-weight: 600;
    color: #34495e;
    margin: 1em 0 0.5em 0;
}

.search-result__comment p {
    margin: 0.8em 0;
    line-height: 1.7;
    color: #444;
}

.search-result__comment ul {
    margin: 0.8em 0;
    padding-left: 1.5em;
    list-style-type: disc;
}

.search-result__comment ol {
    margin: 0.8em 0;
    padding-left: 1.5em;
    list-style-type: decimal;
}

.search-result__comment ul li,
.search-result__comment ol li {
    margin: 0.4em 0;
    line-height: 1.6;
    color: #444;
}

.search-result__comment strong {
    font-weight: 700;
    color: #111;
}


/* Styles pour le preview de l'annonce (si différent du view) */

.fiche-bloc--annonce .search-result__comment h2,
.fiche-bloc--annonce .search-result__comment h3 {
    color: #e67e22;
}

.fiche-bloc--annonce .search-result__comment h2 {
    border-bottom-color: #e67e22;
}

.fiche-bloc--annonce .search-result__comment h3 {
    font-weight: 700;
}
/* ---------------------------------------------------------------------------
   Parcours de création « Enregistrer et voir mon annonce améliorée avec IA »
   (View/Ads/edit.ctp) : étapes, bandeau de vérification, overlay de chargement
   --------------------------------------------------------------------------- */
/* Reprend le bandeau d'étapes de la première connexion (webroot/css/first_connexion.css) */
/* Bandeau d'étapes en chevrons, calqué sur le bandeau de référence du site
   (« Mes données personnelles / Mes conditions d'exercice ») : segments en
   forme de flèche (pointe à droite, encoche à gauche) qui s'imbriquent, la
   pointe de l'un rentrant dans l'encoche du suivant avec un fin liseré ;
   étape en cours en orange, étapes faites/à venir en gris. */
.ai-flow-steps {
    display: flex;
    margin: 2rem 0 3rem;
    padding: 0;
    list-style: none;
    min-height: 64px;
}

.ai-flow-step {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    padding: 8px 20px;
    font-weight: bold;
    font-size: 1rem;
    line-height: 1.2;
    white-space: nowrap;
    text-align: center;
    text-transform: uppercase;
    color: rgb(89, 107, 125);
    background-color: #f1f1f1;
    /* Chevron : pointe à droite + encoche à gauche pour s'imbriquer. */
    clip-path: polygon(0 0, calc(100% - 28px) 0, 100% 50%, calc(100% - 28px) 100%, 0 100%, 28px 50%);
}

/* Les segments se chevauchent : la pointe du précédent rentre dans l'encoche
   du suivant (encoche 28px - 2px de liseré = chevauchement de 26px). */
.ai-flow-step + .ai-flow-step {
    margin-left: -26px;
}

/* Première étape : bord gauche plat (pas d'encoche), pas de chevauchement. */
.ai-flow-step:first-child {
    clip-path: polygon(0 0, calc(100% - 28px) 0, 100% 50%, calc(100% - 28px) 100%, 0 100%);
}

/* Seule l'étape en cours est orange (comme le bandeau de référence). */
.ai-flow-step.is-active {
    background-color: #ee4e01;
    color: #fff;
}

@media screen and (max-width: 767px) {
    .ai-flow-step {
        font-size: 0.72rem;
        padding: 6px 12px;
        white-space: normal;
        /* flèches moins profondes sur petit écran pour préserver la place du texte */
        clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%, 16px 50%);
    }
    .ai-flow-step + .ai-flow-step {
        margin-left: -14px;
    }
    .ai-flow-step:first-child {
        clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
    }
}

.ai-review-banner {
    margin: 0 0 24px;
    padding: 14px 18px;
    border-left: 4px solid #0e68a8;
    background-color: #eef5fb;
    border-radius: 4px;
}

.ai-review-banner__text {
    margin: 0;
    color: #1d2b36;
    font-size: 15px;
}

.ai-keep-original {
    margin-top: 8px;
    text-align: right;
}

.ai-keep-original a {
    color: #5b6b78;
    font-size: 13px;
    text-decoration: underline;
}

.ai-flow-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(15, 30, 45, 0.45);
}

.ai-flow-overlay__box {
    max-width: 360px;
    margin: 0 16px;
    padding: 24px 28px;
    background-color: #fff;
    border-radius: 6px;
    text-align: center;
    color: #1d2b36;
}

.ai-flow-overlay__box .fa-spinner {
    font-size: 28px;
    color: #0e68a8;
}

.ai-flow-overlay__box p {
    margin: 12px 0 0;
    font-weight: 700;
}

.ai-flow-overlay__box .ai-flow-overlay__hint {
    margin-top: 4px;
    font-weight: 400;
    font-size: 13px;
    color: #5b6b78;
}

/* Étape 3 du parcours : page de confirmation (View/Ads/published.ctp) */
.ai-published {
    margin-bottom: 3rem;
    font-size: 15px;
}

.ai-published__lead {
    font-weight: 700;
}
