/**
 * Elementor Toolkit - Code Block Widget Styles
 */

.etk-code-block-wrapper {
    border-radius: 8px;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

/* Header */
.etk-code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    user-select: none;
}

.etk-code-block-label {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.8;
}

/* Copy Button */
.etk-code-copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid transparent;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.etk-code-copy-btn svg {
    flex-shrink: 0;
}

/* Pre / Code */
.etk-code-block-pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    tab-size: 4;
    background: none;
}

.etk-code-block-wrapper pre[class*="language-"],
.etk-code-block-pre {
    background: none;
    margin: 0;
    text-shadow: none;
}

.etk-code-block-pre code,
.etk-code-block-pre code[class*="language-"] {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, 'Courier New', monospace;
    font-size: inherit;
    line-height: inherit;
    background: none !important;
    padding: 0 !important;
    border: none !important;
    white-space: pre;
    word-wrap: normal;
    text-shadow: none;
    color: inherit;
}

/* Line Numbers */
.etk-code-line-numbers .etk-code-block-pre {
    position: relative;
    padding-left: 3.8em;
}

.etk-code-line-numbers .etk-code-block-pre code {
    display: block;
}

.etk-line-numbers-rows {
    position: absolute;
    top: 16px;
    left: 0;
    width: 3em;
    pointer-events: none;
    user-select: none;
    counter-reset: linenumber;
    font-size: inherit;
    line-height: inherit;
    letter-spacing: -1px;
    text-align: right;
}

.etk-line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
}

.etk-line-numbers-rows > span::before {
    content: counter(linenumber);
    display: block;
    padding-right: 0.8em;
    opacity: 0.4;
}

.etk-code-theme-dark .etk-line-numbers-rows {
    color: #6c7086;
}

.etk-code-theme-light .etk-line-numbers-rows {
    color: #a0a1a7;
}

/* ---- Dark Theme ---- */
.etk-code-theme-dark {
    background-color: #1e1e2e;
    color: #cdd6f4;
}

.etk-code-theme-dark .etk-code-block-header {
    background-color: #181825;
    color: #a6adc8;
    border-bottom: 1px solid #313244;
}

.etk-code-theme-dark .etk-code-copy-btn {
    color: #a6adc8;
}

.etk-code-theme-dark .etk-code-copy-btn:hover {
    background: #313244;
    color: #cdd6f4;
    border-color: #45475a;
}

.etk-code-theme-dark .etk-code-copy-btn.etk-copied {
    color: #a6e3a1;
    border-color: #a6e3a1;
}

/* Syntax - Dark */
.etk-code-theme-dark .token.comment,
.etk-code-theme-dark .token.prolog,
.etk-code-theme-dark .token.doctype,
.etk-code-theme-dark .token.cdata {
    color: #6c7086;
}

.etk-code-theme-dark .token.punctuation { color: #bac2de; }
.etk-code-theme-dark .token.property,
.etk-code-theme-dark .token.tag,
.etk-code-theme-dark .token.boolean,
.etk-code-theme-dark .token.number,
.etk-code-theme-dark .token.constant,
.etk-code-theme-dark .token.symbol { color: #fab387; }
.etk-code-theme-dark .token.selector,
.etk-code-theme-dark .token.attr-name,
.etk-code-theme-dark .token.string,
.etk-code-theme-dark .token.char,
.etk-code-theme-dark .token.builtin { color: #a6e3a1; }
.etk-code-theme-dark .token.operator,
.etk-code-theme-dark .token.entity,
.etk-code-theme-dark .token.url { color: #89dceb; }
.etk-code-theme-dark .token.atrule,
.etk-code-theme-dark .token.attr-value,
.etk-code-theme-dark .token.keyword { color: #cba6f7; }
.etk-code-theme-dark .token.function,
.etk-code-theme-dark .token.class-name { color: #89b4fa; }
.etk-code-theme-dark .token.regex,
.etk-code-theme-dark .token.important,
.etk-code-theme-dark .token.variable { color: #f38ba8; }

/* ---- Light Theme ---- */
.etk-code-theme-light {
    background-color: #f8f9fa;
    color: #383a42;
    border: 1px solid #e1e4e8;
}

.etk-code-theme-light .etk-code-block-header {
    background-color: #f1f3f5;
    color: #656d76;
    border-bottom: 1px solid #e1e4e8;
}

.etk-code-theme-light .etk-code-copy-btn {
    color: #656d76;
}

.etk-code-theme-light .etk-code-copy-btn:hover {
    background: #e1e4e8;
    color: #383a42;
    border-color: #d0d7de;
}

.etk-code-theme-light .etk-code-copy-btn.etk-copied {
    color: #1a7f37;
    border-color: #1a7f37;
}

/* Syntax - Light */
.etk-code-theme-light .token.comment,
.etk-code-theme-light .token.prolog,
.etk-code-theme-light .token.doctype,
.etk-code-theme-light .token.cdata {
    color: #a0a1a7;
}

.etk-code-theme-light .token.punctuation { color: #383a42; }
.etk-code-theme-light .token.property,
.etk-code-theme-light .token.tag,
.etk-code-theme-light .token.boolean,
.etk-code-theme-light .token.number,
.etk-code-theme-light .token.constant,
.etk-code-theme-light .token.symbol { color: #986801; }
.etk-code-theme-light .token.selector,
.etk-code-theme-light .token.attr-name,
.etk-code-theme-light .token.string,
.etk-code-theme-light .token.char,
.etk-code-theme-light .token.builtin { color: #50a14f; }
.etk-code-theme-light .token.operator,
.etk-code-theme-light .token.entity,
.etk-code-theme-light .token.url { color: #0184bc; }
.etk-code-theme-light .token.atrule,
.etk-code-theme-light .token.attr-value,
.etk-code-theme-light .token.keyword { color: #a626a4; }
.etk-code-theme-light .token.function,
.etk-code-theme-light .token.class-name { color: #4078f2; }
.etk-code-theme-light .token.regex,
.etk-code-theme-light .token.important,
.etk-code-theme-light .token.variable { color: #e45649; }

/* Inline Code (code not inside pre) */
code:not(pre code):not(.etk-md-inline-code) {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, 'Courier New', monospace;
    font-size: 0.875em;
    padding: 0.2em 0.45em;
    border-radius: 4px;
    white-space: nowrap;
    background-color: rgba(27, 31, 35, 0.06);
    color: #e53e3e;
}

body.etk-code-theme-dark-inline code:not(pre code):not(.etk-md-inline-code) {
    background-color: #313244;
    color: #cdd6f4;
}

/* Scrollbar */
.etk-code-block-pre::-webkit-scrollbar {
    height: 6px;
}

.etk-code-theme-dark .etk-code-block-pre::-webkit-scrollbar-track {
    background: #181825;
}

.etk-code-theme-dark .etk-code-block-pre::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 3px;
}

.etk-code-theme-light .etk-code-block-pre::-webkit-scrollbar-track {
    background: #f1f3f5;
}

.etk-code-theme-light .etk-code-block-pre::-webkit-scrollbar-thumb {
    background: #d0d7de;
    border-radius: 3px;
}
