/*
 * Elementor Safe Code Highlighter
 *
 * IMPORTANT:
 * All CSS is scoped below .esch-widget.
 * No generic pre, code, button, body, a, typography, or Elementor selectors
 * are modified. This prevents theme/plugin collisions.
 */

.esch-widget {
    --esch-bg: #1e1e1e;
    --esch-text: #d4d4d4;
    --esch-border: #343434;
    --esch-header-bg: #181818;
    --esch-muted: #a1a1aa;
    --esch-accent: #38bdf8;

    width: 100%;
    min-width: 0;
    position: relative;
}

.esch-widget .esch-code-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--esch-border);
    border-radius: 10px;
    background: var(--esch-bg);
    color: var(--esch-text);
    box-sizing: border-box;
    isolation: isolate;
}

.esch-widget .esch-code-container *,
.esch-widget .esch-code-container *::before,
.esch-widget .esch-code-container *::after {
    box-sizing: border-box;
}

.esch-widget .esch-code-header {
    min-height: 44px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px 8px 14px;
    border-bottom: 1px solid var(--esch-border);
    background: var(--esch-header-bg);
}

.esch-widget .esch-code-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 9px;
    border-left: 3px solid var(--esch-accent);
    color: var(--esch-muted);
    font: 600 13px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.esch-widget .esch-copy-button {
    flex: 0 0 auto;
    appearance: none;
    border: 1px solid var(--esch-border);
    border-radius: 6px;
    margin: 0;
    padding: 6px 10px;
    background: transparent;
    color: #d4d4d4;
    cursor: pointer;
    font: 600 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.esch-widget .esch-copy-button:hover,
.esch-widget .esch-copy-button:focus-visible {
    background: rgba(255,255,255,.06);
    outline: none;
}

.esch-widget .esch-copy-button.esch-copied {
    color: var(--esch-accent);
}

.esch-widget .esch-code-box {
    width: 100%;
    max-width: 100%;
    margin: 0 !important;
    border: 0 !important;
    outline: 0;
    background: transparent !important;
    color: var(--esch-text);
    overflow: auto;
    white-space: pre;
    text-align: left;
    tab-size: 4;
    -moz-tab-size: 4;
    -webkit-overflow-scrolling: touch;
}

.esch-widget .esch-code-box code {
    display: block;
    margin: 0;
    padding: 0;
    border: 0 !important;
    outline: 0;
    background: transparent !important;
    color: inherit;
    text-align: left;
    white-space: inherit;
    text-shadow: none;
}

/* Long-line wrapping is opt-in. Default behavior is horizontal scrolling. */
.esch-widget .esch-wrap-lines .esch-code-box,
.esch-widget .esch-wrap-lines .esch-code-box code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Scoped line numbers. No global counters/selectors. */
.esch-widget .esch-has-line-numbers .esch-code-box {
    padding-left: 52px !important;
    counter-reset: esch-line;
}

.esch-widget .esch-has-line-numbers .esch-code-box code {
    counter-reset: esch-line;
}

.esch-widget .esch-has-line-numbers .esch-code-box .esch-line {
    display: block;
    min-height: 1.6em;
    counter-increment: esch-line;
}

.esch-widget .esch-has-line-numbers .esch-code-box .esch-line::before {
    content: counter(esch-line);
    display: inline-block;
    width: 34px;
    margin-left: -43px;
    margin-right: 9px;
    color: #666;
    text-align: right;
    user-select: none;
    pointer-events: none;
}

/* Prism token styling is also scoped only to this widget. */
.esch-widget .token.comment,
.esch-widget .token.prolog,
.esch-widget .token.doctype,
.esch-widget .token.cdata {
    color: #6a9955;
}

.esch-widget .token.punctuation {
    color: #d4d4d4;
}

.esch-widget .token.property,
.esch-widget .token.tag,
.esch-widget .token.boolean,
.esch-widget .token.number,
.esch-widget .token.constant,
.esch-widget .token.symbol {
    color: #b5cea8;
}

.esch-widget .token.selector,
.esch-widget .token.attr-name,
.esch-widget .token.string,
.esch-widget .token.char,
.esch-widget .token.builtin {
    color: #ce9178;
}

.esch-widget .token.operator,
.esch-widget .token.entity,
.esch-widget .token.url {
    color: #d4d4d4;
}

.esch-widget .token.atrule,
.esch-widget .token.attr-value,
.esch-widget .token.keyword {
    color: #569cd6;
}

.esch-widget .token.function,
.esch-widget .token.class-name {
    color: #dcdcaa;
}

.esch-widget .token.regex,
.esch-widget .token.important,
.esch-widget .token.variable {
    color: #d16969;
}

@media (max-width: 767px) {
    .esch-widget .esch-code-box {
        font-size: 13px;
    }

    .esch-widget .esch-code-header {
        min-height: 40px;
    }
}
