/* ==========================================================================
   Code Block - GeeksForGeeks Style
   Standalone CSS for code blocks in student-facing course content.
   Wraps <pre> elements with language header, copy button, line numbers,
   and Prism.js syntax highlighting.

   This is extracted from studio.css so it can be loaded independently
   without pulling in the full CMS/admin theme.
   ========================================================================== */

.code-block-wrapper {
    position: relative;
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #3d3d3d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    background: linear-gradient(135deg, #1a5c2a 0%, #2f8d46 100%);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    min-height: 32px;
}

.code-block-header .language-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

.code-block-header .copy-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 2px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.code-block-header .copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.6);
}

.code-block-header .copy-btn.copied {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.8);
}

.code-block-body {
    background: #2b2b2b;
    overflow-x: auto;
}

.code-block-body pre {
    margin: 0 !important;
    padding: 1rem !important;
    background: transparent !important;
    color: #f8f8f2 !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'Source Code Pro', 'Consolas', 'Monaco', monospace !important;
    font-size: 0.875rem !important;
    line-height: 1.6 !important;
    tab-size: 4;
    border: none !important;
    border-radius: 0 !important;
    overflow-x: auto;
    white-space: pre;
    word-wrap: normal;
}

.code-block-body pre code {
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    color: inherit;
    white-space: pre;
    word-wrap: normal;
}

/* Line numbers gutter */
.code-block-body pre.has-line-numbers {
    padding-left: 3.8rem !important;
    position: relative;
}

.code-line-numbers {
    position: absolute;
    left: 0;
    top: 1rem;
    width: 3rem;
    padding-right: 0.75rem;
    text-align: right;
    color: #636d83;
    font-family: 'JetBrains Mono', 'Fira Code', 'Source Code Pro', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    user-select: none;
    pointer-events: none;
    border-right: 1px solid #3d3d3d;
    white-space: pre;
}

/* Override Quill's default code-block styling when enhanced */
.code-block-body pre.ql-syntax.code-enhanced {
    background: transparent !important;
    color: #f8f8f2 !important;
    border: none !important;
    border-radius: 0 !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'Source Code Pro', 'Consolas', monospace !important;
    font-size: 0.875rem !important;
    line-height: 1.6 !important;
}

/* Line numbers padding must win over all other padding rules */
.code-block-body pre.has-line-numbers.code-enhanced {
    padding-left: 3.8rem !important;
}

/* Prism.js theme overrides for dark code blocks */
.code-block-body .token.comment,
.code-block-body .token.prolog,
.code-block-body .token.doctype,
.code-block-body .token.cdata {
    color: #6a9955;
}

.code-block-body .token.punctuation {
    color: #d4d4d4;
}

.code-block-body .token.property,
.code-block-body .token.tag,
.code-block-body .token.boolean,
.code-block-body .token.number,
.code-block-body .token.constant,
.code-block-body .token.symbol {
    color: #b5cea8;
}

.code-block-body .token.selector,
.code-block-body .token.attr-name,
.code-block-body .token.string,
.code-block-body .token.char,
.code-block-body .token.builtin {
    color: #ce9178;
}

.code-block-body .token.operator,
.code-block-body .token.entity,
.code-block-body .token.url {
    color: #d4d4d4;
}

.code-block-body .token.atrule,
.code-block-body .token.attr-value,
.code-block-body .token.keyword {
    color: #569cd6;
}

.code-block-body .token.function,
.code-block-body .token.class-name {
    color: #dcdcaa;
}

.code-block-body .token.regex,
.code-block-body .token.important,
.code-block-body .token.variable {
    color: #d16969;
}

/* Scrollbar styling for code blocks */
.code-block-body::-webkit-scrollbar,
.code-block-body pre::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.code-block-body::-webkit-scrollbar-track,
.code-block-body pre::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.code-block-body::-webkit-scrollbar-thumb,
.code-block-body pre::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.code-block-body::-webkit-scrollbar-thumb:hover,
.code-block-body pre::-webkit-scrollbar-thumb:hover {
    background: #777;
}
