/* ================================================
   GT Addon — Editor de Traducciones (Frontend)
   Solo carga para administradores
   ================================================ */

/* ---- Badge de modo activo ---- */
#gt-editor-badge {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2147483646;
    background: #007cba;
    color: #fff;
    font-family: 'Montserrat', -apple-system, sans-serif;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
    display: none;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.3px;
    pointer-events: none;
}

#gt-editor-badge.visible {
    display: flex;
}

#gt-editor-badge .gt-badge-lang {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
}

/* ---- Resaltado de selección cuando el modo está activo ---- */
body.gt-editor-active ::selection {
    background: rgba(0, 124, 186, 0.25);
}

/* Permitir selección de texto en todo el body (invalida user-select: none de los themes) */
body.gt-editor-active,
body.gt-editor-active * {
    cursor: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    -webkit-user-drag: none !important;
    /* Prevenir que las imágenes y links se arrastren en lugar de seleccionarse */
}

/* El popup sí mantiene cursores normales */
#gt-editor-popup,
#gt-editor-popup * {
    cursor: auto !important;
}

#gt-editor-popup button,
#gt-editor-popup input {
    cursor: pointer !important;
}

/* ---- Popup flotante ---- */
#gt-editor-popup {
    position: fixed;
    z-index: 2147483647;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-top: 3px solid #007cba;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    padding: 16px;
    min-width: 340px;
    max-width: 440px;
    font-family: 'Montserrat', -apple-system, sans-serif;
    font-size: 13px;
    display: none;
    flex-direction: column;
    gap: 12px;
    animation: gt-popup-in 0.15s ease;
}

#gt-editor-popup.visible {
    display: flex;
}

@keyframes gt-popup-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---- Header del popup ---- */
.gt-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.gt-popup-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #1d2327;
}

.gt-popup-lang-tag {
    background: #007cba;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* #2 — Selector de idioma en el popup */
.gt-lang-selector {
    border: 1px solid #ccd0d4;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
    color: #1d2327;
    cursor: pointer;
    outline: none;
    max-width: 220px;
}

.gt-lang-selector:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.12);
}

/* #1 — Hint de traducción existente en el popup */
.gt-existing-hint {
    font-size: 10px;
    color: #00a651;
    font-weight: 600;
    margin-bottom: 2px;
    display: block;
}

.gt-fragment-row.gt-has-existing .gt-original-text {
    border-color: #b3e0cc;
    background: #f0faf5;
}

/* #1 — Resaltado en el DOM de traducciones ya personalizadas */
mark.gt-addon-translated {
    background: transparent;
    border-bottom: 2px solid #00a651;
    color: inherit;
    padding: 0;
    cursor: text;
}

/* Tooltip al hover sobre un texto ya traducido */
mark.gt-addon-translated:hover::after {
    content: '✓ Traducción personalizada';
    position: fixed;
    background: #1d2327;
    color: #fff;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2147483647;
    transform: translate(4px, -110%);
}

.gt-popup-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    margin-left: 8px;
    transition: color 0.15s;
}

.gt-popup-close:hover {
    color: #333;
}

/* ---- Filas de fragmentos ---- */
.gt-fragment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gt-fragment-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gt-fragment-row label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
}

.gt-original-text {
    background: #f8f8f8;
    border: 1px solid #e5e5e5;
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 12px;
    color: #555;
    word-break: break-word;
    max-height: 50px;
    overflow-y: auto;
}

.gt-translation-input {
    width: 100%;
    border: 1px solid #ccd0d4;
    border-radius: 5px;
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.15s;
    outline: none;
}

.gt-translation-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.12);
}

/* ---- Divider entre fragmentos múltiples ---- */
.gt-fragment-divider {
    border: none;
    border-top: 1px dashed #eee;
    margin: 2px 0;
}

/* ---- Footer del popup ---- */
.gt-popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.gt-btn-cancel {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    color: #666;
    transition: all 0.15s;
}

.gt-btn-cancel:hover {
    border-color: #bbb;
    color: #333;
}

.gt-btn-save {
    background: #007cba;
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    color: #fff;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gt-btn-save:hover {
    background: #005d98;
}

.gt-btn-save:disabled {
    background: #aaa;
    cursor: not-allowed;
}

.gt-btn-save.saved {
    background: #00a651;
}

.gt-btn-save.error {
    background: #d63638;
}