/* ---------- Bandeau du mode édition ---------- */
/* En bas de l'écran (pas en haut) : de nombreux thèmes ont leur propre menu fixé en
   haut de page, qu'un bandeau en haut recouvrirait sans que le thème le sache. */
.ttp-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1d2327;
    color: #fff;
    text-align: center;
    padding: 8px 12px;
    font-size: 13px;
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.ttp-banner-warning {
    background: #b32d2e;
}

.ttp-ai-banner-btn {
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.ttp-ai-banner-btn:hover:not(:disabled) {
    background: #6d28d9;
}

.ttp-ai-banner-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.ttp-rescan-btn {
    background: #2271b1;
}

.ttp-rescan-btn:hover:not(:disabled) {
    background: #135e96;
}

/* ---------- Texte traduit (indicateur visible en mode édition uniquement) ---------- */
body.ttp-edit-active .ttp-text.ttp-translated {
    box-shadow: inset 0 -2px 0 #46b450;
}

/* Contour pointillé au survol, pour bien voir quel élément est traduisible (admin uniquement) */
body.ttp-edit-active .ttp-text:hover {
    outline: 2px dashed #2271b1;
    outline-offset: 2px;
    background-color: rgba(34, 113, 177, 0.08);
    border-radius: 2px;
}

/* ---------- Ancrage du stylo : tout élément traduisible (texte, champ, liste...) ---------- */
.ttp-pencil-anchor {
    position: relative;
}

body.ttp-edit-active .ttp-pencil-anchor:hover {
    outline: 2px dashed #2271b1;
    outline-offset: 2px;
    border-radius: 2px;
}

.ttp-pencil-anchor:hover > .ttp-pencil {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Cas d'un texte enveloppé (mélangé à d'autres éléments dans le même bloc, ex: un
   paragraphe avec un mot en gras au milieu) : un élément "inline" qui s'étale sur
   plusieurs lignes positionne son contenu absolu de façon imprévisible (souvent
   collé à un élément voisin). "inline-block" fige une seule boîte de référence,
   pour que le stylo reste toujours à SON PROPRE coin, jamais sur celui d'à côté. */
.ttp-text-frag {
    display: inline-block;
    vertical-align: top;
    max-width: 100%;
}

/* ---------- Encadrement serré autour d'un champ (input, select...) ---------- */
/* Épouse la taille exacte du champ, pour que le crayon reste collé à son coin */
.ttp-field-wrap {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

body.ttp-edit-active .ttp-field-wrap:hover {
    outline: 2px dashed #2271b1;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- Le stylo lui-même : coin haut-droit de l'élément survolé ---------- */
/* Légèrement À L'INTÉRIEUR du cadre (pas en dehors) : certains boutons ont
   overflow:hidden (ex: pilules arrondies avec avatar) qui couperait un stylo
   positionné en dehors de leurs limites, le rendant invisible. */
.ttp-pencil {
    display: flex !important;
    visibility: visible !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    line-height: 18px;
    padding: 0;
    margin: 0;
    border: 1px solid #2271b1;
    background: #fff;
    color: #2271b1;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.ttp-field-wrap:hover > .ttp-pencil {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.ttp-pencil:hover,
.ttp-pencil:focus {
    background: #2271b1;
    color: #fff;
    outline: none;
}

/* ---------- Champ "Choisir un fichier" personnalisé ---------- */
.ttp-file-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.ttp-file-native {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.ttp-file-label {
    display: inline-block;
    padding: 6px 14px;
    background: #f0f0f1;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.ttp-file-label:hover {
    background: #e0e0e1;
}

.ttp-file-name {
    font-size: 13px;
    color: #666;
}

/* ---------- Sélecteur de langue public ---------- */
.ttp-switcher {
    position: fixed;
    bottom: 8px;
    left: 2px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    transition: bottom 0.15s ease;
}

.ttp-switcher-raised {
    bottom: 46px;
}

.ttp-switcher-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    color: #1d2327;
    border: none;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.ttp-switcher-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e2e2;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    width: max-content;
    max-width: 260px;
}

.ttp-switcher.ttp-switcher-open .ttp-switcher-menu {
    display: block;
}

.ttp-switcher-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 4px 14px;
    border: none;
    border-bottom: 1px solid #eeeeee;
    background: #fff;
    cursor: pointer;
    color: #1d2327;
    white-space: nowrap;
}

.ttp-switcher-option:last-child {
    border-bottom: none;
}

.ttp-switcher-option:hover {
    background: #f0f0f1;
}

.ttp-switcher-option.ttp-switcher-active {
    font-weight: 600;
    color: #2271b1;
}

/* ---------- Fenêtres modales ---------- */
.ttp-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

.ttp-modal.ttp-modal-open {
    display: flex;
}

.ttp-modal-box {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1d2327;
    line-height: 1.5;
}

.ttp-modal-box-wide {
    max-width: 600px;
}

.ttp-modal-lang {
    font-size: 12px;
    font-weight: 600;
    color: #2271b1;
    margin-bottom: 10px;
}

.ttp-modal-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ttp-modal-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.ttp-modal-label-row .ttp-modal-label {
    margin-bottom: 0;
}

.ttp-modal-reset {
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid #ccc;
    background: #f6f7f7;
    border-radius: 12px;
    cursor: pointer;
    color: #555;
    white-space: nowrap;
}

.ttp-modal-reset:hover {
    background: #e0e0e1;
}

.ttp-modal-original-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 13px;
    color: #444;
    background: #f6f7f7;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 14px;
}

.ttp-modal-original-textarea:focus {
    background: #fff;
    border-color: #2271b1;
}

.ttp-modal-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
    font-family: inherit;
}

.ttp-modal-scope {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.ttp-modal-scope input[type="checkbox"] {
    -webkit-appearance: checkbox !important;
    appearance: checkbox !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0;
    cursor: pointer;
}

.ttp-modal-scope-hint {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.ttp-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.ttp-modal-actions .ttp-btn-ai {
    margin-right: auto;
}

.ttp-btn {
    padding: 6px 14px;
    border-radius: 4px;
    border: 1px solid #8c8f94;
    background: #f6f7f7;
    color: #1d2327;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
}

.ttp-btn-cancel:hover {
    background: #e0e0e1;
    border-color: #646970;
}

.ttp-btn-save {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.ttp-btn-save:hover {
    background: #135e96;
}

.ttp-btn-ai {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

.ttp-btn-ai:hover:not(:disabled) {
    background: #6d28d9;
}

.ttp-btn-ai:disabled {
    opacity: 0.6;
    cursor: default;
}

.ttp-ai-status {
    font-size: 13px;
    color: #7c3aed;
    margin: 10px 0;
}

/* ---------- Sélection d'une zone (Alt + glisser) ---------- */
.ttp-zone-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    cursor: crosshair;
    background: rgba(124, 58, 237, 0.03);
}

.ttp-zone-box {
    position: fixed;
    border: 2px dashed #7c3aed;
    background: rgba(124, 58, 237, 0.12);
    pointer-events: none;
}

/* ---------- Menu clic-droit ---------- */
.ttp-context-menu {
    display: none;
    position: fixed;
    z-index: 9999999;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    min-width: 140px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ttp-context-menu.ttp-context-menu-open {
    display: block;
}

.ttp-context-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 14px;
    border: none;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    color: #1d2327;
}

.ttp-context-menu-item:hover {
    background: #f0f0f1;
}

/* ---------- Liste d'options (select) dans la modale ---------- */
.ttp-options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

.ttp-options-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.ttp-options-reset {
    padding: 6px 10px;
    border: 1px solid #ccc;
    background: #f6f7f7;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #1d2327;
}

.ttp-options-reset:hover {
    background: #e0e0e1;
}

.ttp-options-original {
    font-size: 13px;
    color: #444;
    padding: 8px 10px;
    background: #f6f7f7;
    border-radius: 4px;
}

.ttp-options-input {
    box-sizing: border-box;
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}

/* Bandeau de traduction en mode invité (visiteur déconnecté) */
.ttp-guest-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    background: #1d2327;
    color: #fff;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 8px 16px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.25);
}

.ttp-guest-bar-label {
    font-weight: 600;
    white-space: nowrap;
}

.ttp-guest-bar-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ttp-guest-bar-select a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 3px 8px;
    border-radius: 3px;
}

.ttp-guest-bar-select a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.ttp-guest-bar-select a.ttp-guest-bar-active {
    background: #2271b1;
    color: #fff;
}

.ttp-guest-bar-toggle {
    margin-left: auto;
    color: #fff;
    background: #2271b1;
    padding: 5px 12px;
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
}

.ttp-guest-bar-toggle:hover {
    background: #135e96;
}

.ttp-guest-bar-exit {
    margin-left: 8px;
    background: #d63638;
}

.ttp-guest-bar-exit:hover {
    background: #b32d2e;
}

/* Cadre d'aperçu "voir comme déconnecté" : superposé à la page réelle, qui
   elle-même ne change jamais (vraie session, vraie barre WordPress en haut). */
#ttp-preview-overlay {
    position: fixed;
    top: 32px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99998;
    background: #fff;
}

body.admin-bar #ttp-preview-overlay {
    top: 32px;
}

@media screen and (max-width: 782px) {
    #ttp-preview-overlay {
        top: 46px;
    }
}

#ttp-preview-iframe {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 44px;
    width: 100%;
    height: auto;
    border: 0;
    background: #fff;
}

#ttp-preview-overlay .ttp-guest-bar {
    position: absolute;
}
