/* PolyTrans Frontend Live Editor */

/* Push content below fixed toolbar */
body.polytrans-editor-active {
    padding-top: 52px !important;
}

/* ── Toolbar ──────────────────────────────────────────── */
#polytrans-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    /*
     * Use max safe z-index (2^31 - 1) so the toolbar is ALWAYS above page modals,
     * overlays, and popups — regardless of what z-index they use.
     */
    z-index: 2147483647;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

body.admin-bar #polytrans-toolbar { top: 32px; }
@media screen and (max-width: 782px) {
    body.admin-bar #polytrans-toolbar       { top: 46px; }
    body.admin-bar.polytrans-editor-active  { padding-top: 98px !important; }
}

/* ── Collapsed toolbar ───────────────────────────────────── */
#polytrans-toolbar.pt-collapsed {
    height: 0;
    overflow: hidden;
    box-shadow: none;
}
body.polytrans-toolbar-collapsed {
    padding-top: 0 !important;
}

/* ── Expand pill (visible when toolbar is collapsed) ─────── */
#polytrans-expand-pill {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 6px;
    background: #1a1a2e;
    color: #7ec8e3;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 14px 4px 10px;
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    z-index: 2147483647;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    transition: background 0.15s;
    user-select: none;
    white-space: nowrap;
}
#polytrans-expand-pill.visible { display: flex; }
#polytrans-expand-pill:hover   { background: #2a2a4e; }
#polytrans-expand-pill svg     { flex-shrink: 0; opacity: 0.75; }
body.admin-bar #polytrans-expand-pill { top: 32px; }

.pt-pill-arrow {
    font-size: 10px;
    opacity: 0.6;
    margin-left: 2px;
}

.polytrans-toolbar-logo {
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    color: #7ec8e3;
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,0.1);
    height: 100%;
    flex-shrink: 0;
}
.polytrans-toolbar-logo svg { width: 20px; height: 20px; }

.polytrans-toolbar-langs {
    display: flex;
    align-items: center;
    height: 100%;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.polytrans-toolbar-langs::-webkit-scrollbar { display: none; }

.polytrans-toolbar-lang {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 100%;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,0.07);
    transition: background 0.15s, color 0.15s;
}
.polytrans-toolbar-lang:hover { background: rgba(255,255,255,0.08); color: #fff; }
.polytrans-toolbar-lang.active {
    background: rgba(126,200,227,0.15);
    color: #7ec8e3;
    border-bottom: 2px solid #7ec8e3;
    font-weight: 600;
}
.polytrans-toolbar-lang .pt-flag { font-size: 16px; }

.polytrans-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 100%;
    border-left: 1px solid rgba(255,255,255,0.1);
    margin-left: auto;
    flex-shrink: 0;
}

#polytrans-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
#polytrans-edit-btn:hover  { background: #005f8a; }
#polytrans-edit-btn.active { background: #cc1818; }
#polytrans-edit-btn.active:hover { background: #aa1414; }

.pt-admin-link {
    color: rgba(255,255,255,0.55);
    font-size: 11px;
    text-decoration: none;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.pt-admin-link:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* ── Collapse button ─────────────────────────────────────── */
.pt-collapse-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.5);
    border-radius: 4px;
    width: 26px;
    height: 26px;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.pt-collapse-btn:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.45);
    background: rgba(255,255,255,0.08);
}

/* ── Translate Mode – crosshair cursor & highlight ──────── */
body.polytrans-translate-mode,
body.polytrans-translate-mode * {
    cursor: crosshair !important;
}

body.polytrans-translate-mode #polytrans-popover,
body.polytrans-translate-mode #polytrans-popover * {
    cursor: auto !important;
}

.pt-highlight {
    outline: 2px solid #0073aa !important;
    outline-offset: 2px !important;
    background-color: rgba(0, 115, 170, 0.06) !important;
    border-radius: 2px;
}

/* ── Popover ─────────────────────────────────────────────── */
#polytrans-popover {
    position: absolute;
    z-index: 2147483647;
    width: 400px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.12);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    overflow: hidden;
}

.pt-pop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    background: #1a1a2e;
    color: #fff;
}

.pt-pop-title {
    font-weight: 600;
    font-size: 13px;
    color: #7ec8e3;
}

.pt-pop-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.pt-pop-close:hover { color: #fff; background: rgba(255,255,255,0.12); }

.pt-pop-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 4px;
}

.pt-pop-original {
    padding: 10px 14px 8px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.pt-pop-original-text {
    font-size: 13px;
    color: #444;
    line-height: 1.5;
    max-height: 72px;
    overflow: hidden;
    word-break: break-word;
}

.pt-pop-translation {
    padding: 10px 14px 8px;
}

/* ── Formatting toolbar (B / I / U) ──────────────────────── */
.pt-fmt-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    padding: 4px 6px;
    background: #f4f4f4;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
}

.pt-fmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 26px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    transition: background 0.12s, border-color 0.12s;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
.pt-fmt-btn:hover   { background: #e8f0fe; border-color: #0073aa; color: #0073aa; }
.pt-fmt-btn b       { font-weight: 900; font-size: 13px; }
.pt-fmt-btn i       { font-style: italic; font-size: 13px; }
.pt-fmt-btn u       { text-decoration: underline; font-size: 13px; }

.pt-fmt-hint {
    font-size: 10px;
    color: #aaa;
    margin-left: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Contenteditable translation editor ─────────────────── */
.pt-pop-editor {
    width: 100%;
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 0 0 5px 5px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    color: #222;
    outline: none;
    word-break: break-word;
    transition: border-color 0.15s;
}
.pt-pop-editor:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.15);
}
.pt-pop-editor:empty::before {
    content: attr(placeholder);
    color: #aaa;
}
/* Style inline formatting inside the editor */
.pt-pop-editor b,
.pt-pop-editor strong { font-weight: 700; }
.pt-pop-editor i,
.pt-pop-editor em     { font-style: italic; }
.pt-pop-editor u      { text-decoration: underline; }

.pt-pop-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 12px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

.pt-pop-save {
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.pt-pop-save:hover    { background: #005f8a; }
.pt-pop-save:disabled { background: #aaa; cursor: not-allowed; }

.pt-pop-status       { font-size: 12px; font-weight: 500; }
.pt-pop-status.ok    { color: #46b450; }
.pt-pop-status.err   { color: #dc3232; }

/* ─────────────────────────────────────────────────────────
   BLOCK TRANSLATION MODAL
───────────────────────────────────────────────────────── */
#polytrans-block-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
}

.ptbm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.ptbm-dialog {
    position: relative;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 16px 56px rgba(0,0,0,0.28), 0 4px 12px rgba(0,0,0,0.14);
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ptbm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    background: #1a1a2e;
    color: #fff;
    flex-shrink: 0;
}

.ptbm-title {
    font-weight: 700;
    font-size: 14px;
    color: #7ec8e3;
    letter-spacing: 0.2px;
}

.ptbm-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.55);
    font-size: 15px;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.ptbm-close:hover { color: #fff; background: rgba(255,255,255,0.12); }

/* ── Block-modal formatting bar (B / I / U) ─────────────── */
.ptbm-fmt-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: #f0f4fa;
    border-bottom: 1px solid #dde3ec;
    flex-shrink: 0;
}
.ptbm-fmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s;
}
.ptbm-fmt-btn:hover   { background: #e8f0fe; border-color: #0073aa; color: #0073aa; }
.ptbm-fmt-btn:active  { background: #0073aa; color: #fff; border-color: #0073aa; }
.ptbm-fmt-hint {
    margin-left: 8px;
    font-size: 11px;
    color: #888;
    font-style: italic;
}

/* Column header row */
.ptbm-col-labels {
    display: grid;
    grid-template-columns: 1fr 1fr 28px;
    gap: 0 10px;
    padding: 8px 18px 6px;
    background: #f7f7f7;
    border-bottom: 1px solid #e5e5e5;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    flex-shrink: 0;
}

/* Scrollable list of string rows */
.ptbm-body {
    overflow-y: auto;
    flex: 1 1 auto;
    padding: 6px 0;
}

.ptbm-row {
    display: grid;
    grid-template-columns: 1fr 1fr 28px;
    gap: 0 10px;
    align-items: start;
    padding: 8px 18px;
    border-bottom: 1px solid #f2f2f2;
    transition: background 0.1s;
}
.ptbm-row:last-child { border-bottom: none; }
.ptbm-row:hover      { background: #fafcff; }

.ptbm-original {
    padding: 8px 10px;
    background: #f9f9f9;
    border: 1px solid #e8e8e8;
    border-radius: 5px;
    color: #555;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    min-height: 36px;
    max-height: 120px;
    overflow-y: auto;
    align-self: stretch;
    display: flex;
    align-items: flex-start;
}

.ptbm-editor {
    min-height: 36px;
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    color: #222;
    outline: none;
    word-break: break-word;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
    box-sizing: border-box;
}
.ptbm-editor:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.14);
}
.ptbm-editor:empty::before {
    content: "Enter translation…";
    color: #bbb;
    pointer-events: none;
}
.ptbm-editor b, .ptbm-editor strong { font-weight: 700; }
.ptbm-editor i, .ptbm-editor em     { font-style: italic; }
.ptbm-editor u                       { text-decoration: underline; }

.ptbm-row-status {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    padding-top: 10px;
    min-width: 20px;
}
.ptbm-row-status.ok  { color: #46b450; }
.ptbm-row-status.err { color: #dc3232; }

/* Footer */
.ptbm-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.ptbm-count {
    font-size: 12px;
    color: #999;
    margin-right: auto;
}

.ptbm-status       { font-size: 12px; font-weight: 600; }
.ptbm-status.ok    { color: #46b450; }
.ptbm-status.err   { color: #dc3232; }

.ptbm-save-all {
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 22px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.ptbm-save-all:hover    { background: #005f8a; }
.ptbm-save-all:disabled { background: #aaa; cursor: not-allowed; }

/* Highlight override for containers — box outline instead of background tint */
body.polytrans-translate-mode .pt-highlight {
    outline: 2px dashed #0073aa !important;
    outline-offset: 4px !important;
    background-color: rgba(0, 115, 170, 0.04) !important;
}
