/**
 * Code Block Container Styling
 * Professional code presentation for help.pricefy.io
 */

/* Force content area to respect parent width */
.content {
    max-width: 100%;
    overflow: hidden;
}

/* Custom code block wrapper */
.code-block-wrapper {
    margin: 1.5em 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.code-block-wrapper > pre[class*="language-"] {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: auto;
    max-width: 100%;
}

/* Ensure all pre elements in content area respect container width */
.content pre,
.content pre[class*="language-"] {
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

/* Code block header with language label and copy button */
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #21252b;
    padding: 10px 16px;
    border-bottom: 1px solid #181a1f;
}

.code-block-header .code-lang {
    color: #9da5b4;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-block-header .code-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #3a3f4b;
    color: #abb2bf;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.code-block-header .code-copy-btn:hover {
    background: #4b5263;
    color: #e5e5e5;
}

.code-block-header .code-copy-btn:active {
    transform: scale(0.98);
}

/* Legacy Prism toolbar support */
.code-toolbar {
    position: relative;
    margin: 1.5em 0;
}

.code-toolbar > pre[class*="language-"] {
    margin: 0;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.code-toolbar::before {
    content: attr(data-language);
    display: block;
    background: #21252b;
    color: #9da5b4;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    border-radius: 10px 10px 0 0;
    border-bottom: 1px solid #181a1f;
}

div.code-toolbar > .toolbar {
    position: absolute;
    top: 0;
    right: 0;
    padding: 8px 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.code-toolbar:hover > .toolbar {
    opacity: 1;
}

div.code-toolbar > .toolbar > .toolbar-item {
    display: inline-block;
}

div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > a,
div.code-toolbar > .toolbar > .toolbar-item > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #3a3f4b;
    color: #abb2bf;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

div.code-toolbar > .toolbar > .toolbar-item > button:hover,
div.code-toolbar > .toolbar > .toolbar-item > a:hover {
    background: #4b5263;
    color: #e5e5e5;
}

/* Standalone pre blocks (not in code-toolbar) */
pre:not(.code-toolbar > pre)[class*="language-"] {
    margin: 1.5em 0;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Gutenberg code block wrapper */
.wp-block-code {
    margin: 1.5em 0;
    background: transparent;
    padding: 0;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.wp-block-code pre {
    margin: 0;
    padding: 1.25em 1.5em;
    background: #282c34;
    border-radius: 10px;
}

.wp-block-code code {
    background: transparent;
    padding: 0;
    font-family: 'Fira Code', 'JetBrains Mono', 'SF Mono', Consolas, Monaco, monospace;
    font-size: 14px;
    line-height: 1.6;
}

/* Preformatted block */
.wp-block-preformatted {
    margin: 1.5em 0;
    padding: 1.25em 1.5em;
    background: #282c34;
    color: #abb2bf;
    font-family: 'Fira Code', 'JetBrains Mono', 'SF Mono', Consolas, Monaco, monospace;
    font-size: 14px;
    line-height: 1.6;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow-x: auto;
}

/* Inline code styling */
:not(pre) > code {
    background: #f0f2f5;
    color: #e06c75;
    font-family: 'Fira Code', 'JetBrains Mono', 'SF Mono', Consolas, Monaco, monospace;
    font-size: 0.9em;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    white-space: nowrap;
}

/* Dark mode inline code (if night mode is enabled) */
body.night-mode :not(pre) > code {
    background: #3a3f4b;
    color: #e06c75;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .code-toolbar > pre[class*="language-"],
    pre:not(.code-toolbar > pre)[class*="language-"],
    .wp-block-code pre,
    .wp-block-preformatted {
        font-size: 13px;
        padding: 1em 1.25em;
        border-radius: 8px;
    }

    .code-toolbar::before {
        font-size: 11px;
        padding: 8px 12px;
        border-radius: 8px 8px 0 0;
    }

    .code-toolbar > pre[class*="language-"] {
        border-radius: 0 0 8px 8px;
    }

    div.code-toolbar > .toolbar {
        opacity: 1;
    }

    div.code-toolbar > .toolbar > .toolbar-item > button,
    div.code-toolbar > .toolbar > .toolbar-item > a,
    div.code-toolbar > .toolbar > .toolbar-item > span {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* Print styles */
@media print {
    pre[class*="language-"],
    .wp-block-code pre,
    .wp-block-preformatted {
        background: #f5f5f5 !important;
        color: #333 !important;
        box-shadow: none !important;
        border: 1px solid #ddd;
    }

    .token.comment,
    .token.prolog,
    .token.doctype,
    .token.cdata {
        color: #666 !important;
    }

    .token.keyword,
    .token.atrule {
        color: #0066cc !important;
    }

    .token.string,
    .token.attr-value {
        color: #008800 !important;
    }

    .token.function,
    .token.class-name {
        color: #6600cc !important;
    }

    .token.number,
    .token.boolean {
        color: #cc6600 !important;
    }

    div.code-toolbar > .toolbar {
        display: none;
    }
}
