/* ===============================================================================
   TL-TOOLS.CSS - Code Blocks, Syntax Highlighting, Compiler/Editor UI
   =============================================================================== */

/* =============================================================================
 * 21. TL CODE BLOCK
 * VS Code Dark+ style - multi-file tabbed code viewer
 * High-contrast token colors for maximum readability
 * ============================================================================= */

/* --- Container --- */
.tl-code-block {
    container-type: inline-size;
    border-radius: var(--tl-radius-md);
    overflow: hidden;
    border: 1px solid #1a1a1a;
    background: #1e1e1e;
    margin-bottom: 1.75rem;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    font-family: "Cascadia Code", "Fira Code", "Consolas", "Monaco", "Courier New", monospace;
}

/* --- Title bar (traffic lights + title + copy) --- */
.tl-code-titlebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: #2d2d2d;
    border-bottom: 1px solid #1a1a1a;
    min-height: 38px;
}

.tl-code-dots {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.tl-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.tl-dot-red    { background: #ff5f57; }
.tl-dot-yellow { background: #febc2e; }
.tl-dot-green  { background: #28c840; }

.tl-code-title {
    flex: 1;
    font-size: 0.75rem;
    color: #858585;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
}

.tl-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid #4a4a4a;
    color: #858585;
    border-radius: 4px;
    padding: 3px 9px;
    font-size: 0.72rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    transition: background var(--tl-duration-fast), color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.tl-copy-btn:hover {
    background: #3a3a3a;
    color: #cccccc;
    border-color: #666;
}

.tl-copy-btn.copied {
    background: #1a4a2a;
    border-color: #28a745;
    color: #4ec94e;
}

/* --- Edit & Run button --- */
.tl-run-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid #2a6a3a;
    color: #4ec94e;
    border-radius: 4px;
    padding: 3px 9px;
    font-size: 0.72rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    transition: background var(--tl-duration-fast), color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
    text-decoration: none;
}

.tl-run-btn:hover {
    background: #1a4a2a;
    color: #7dde7d;
    border-color: #4ec94e;
}

@container (max-width: 480px) {
    .tl-code-titlebar {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 8px;
    }

    .tl-code-title {
        min-width: 0;
    }

    .tl-code-titlebar > .tl-run-btn,
    .tl-code-titlebar > .tl-copy-btn,
    .tl-code-actions {
        grid-column: 1 / -1;
    }

    .tl-code-actions {
        display: flex;
        min-width: 0;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .tl-code-actions::-webkit-scrollbar {
        display: none;
    }

    .tl-code-titlebar > .tl-run-btn,
    .tl-code-titlebar > .tl-copy-btn,
    .tl-code-actions > button,
    .tl-code-actions > .tl-run-btn {
        position: relative;
        flex: 0 0 auto;
        width: 34px;
        min-width: 34px;
        min-height: 32px;
        padding-right: 0;
        padding-left: 0;
        gap: 0;
        font-size: 0;
        justify-content: center;
    }

    .tl-code-titlebar > .tl-run-btn i,
    .tl-code-titlebar > .tl-copy-btn i,
    .tl-code-actions > button i,
    .tl-code-actions > .tl-run-btn i {
        font-size: 0.86rem;
    }

    .tl-code-titlebar > .tl-run-btn span,
    .tl-code-titlebar > .tl-copy-btn span,
    .tl-code-actions > button span,
    .tl-code-actions > .tl-run-btn span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }
}

/* --- Tab bar --- */
.tl-code-tabs {
    display: flex;
    overflow-x: auto;
    background: #252526;
    border-bottom: 1px solid #1a1a1a;
    scrollbar-width: none;
}

.tl-code-tabs::-webkit-scrollbar {
    display: none;
}

.tl-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: #2d2d2d;
    border: none;
    border-right: 1px solid #1a1a1a;
    border-top: 2px solid transparent;
    border-bottom: 1px solid #1a1a1a;
    color: #858585;
    font-size: 0.8rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--tl-duration-fast), color 0.15s;
    outline: none;
    letter-spacing: 0.01em;
}

.tl-tab:hover {
    background: #2a2d2e;
    color: #cccccc;
}

.tl-tab.active {
    background: #1e1e1e;
    color: #ffffff;
    border-top-color: #e84c3d;
    border-bottom-color: #1e1e1e;
}

/* --- Tab icon colors by file type --- */
.tl-tab-icon { font-size: 0.72rem; }
.tl-tab-icon.ts   { color: #3b8eea; }
.tl-tab-icon.html { color: #e8714a; }
.tl-tab-icon.css  { color: #519aba; }
.tl-tab-icon.spec { color: #c586c0; }
.tl-tab-icon.js   { color: #cbcb41; }
.tl-tab-icon.py   { color: #4b8bbe; }
.tl-tab-icon.java { color: #cc9a3c; }
.tl-tab-icon.php  { color: #8892be; }
.tl-tab-icon.sql  { color: #e38c00; }
.tl-tab-icon.sh   { color: #89e051; }
.tl-tab-icon.git  { color: #f14e32; }

/* --- Code panels --- */
.tl-code-panels {
    background: #1e1e1e;
    position: relative;
}

.tl-panel {
    display: none;
}

.tl-panel.active {
    display: block;
}

/* =============================================================================
 * TL CODE BLOCK - Prism VS Code Dark+ Token Colors
 * Overrides default Prism theme for high-contrast readability
 * ============================================================================= */

/* Base pre/code reset */
.tl-code-block pre[class*="language-"],
.tl-code-block pre.language-git,
.tl-code-block pre.language-typescript,
.tl-code-block pre.language-html,
.tl-code-block pre.language-css {
    margin: 0;
    border-radius: 0;
    border: none;
    background: #1e1e1e;
    padding: 22px 26px;
    font-size: 0.9rem;
    line-height: 1.75;
    overflow-x: auto;
    max-height: 500px;
    tab-size: 4;
    -moz-tab-size: 4;
    /* Thin custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #444 #1e1e1e;
}

.tl-code-block pre[class*="language-"]::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.tl-code-block pre[class*="language-"]::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.tl-code-block pre[class*="language-"]::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* Base text - bright white for readability */
.tl-code-block code[class*="language-"],
.tl-code-block pre[class*="language-"] {
    background: none;
    font-family: "Cascadia Code", "Fira Code", "Consolas", "Monaco", "Courier New", monospace;
    font-size: inherit;
    color: #d4d4d4;
    text-shadow: none;
    word-spacing: normal;
    word-break: normal;
    white-space: pre;
}

/* --- VS Code Dark+ Token Colors --- */

/* Keywords: if, import, export, class, const, let, var, return, from */
.tl-code-block .token.keyword {
    color: #569cd6;
    font-style: normal;
}

/* Strings: 'value', "value", `template` */
.tl-code-block .token.string,
.tl-code-block .token.attr-value {
    color: #ce9178;
}

/* Numbers */
.tl-code-block .token.number,
.tl-code-block .token.boolean {
    color: #b5cea8;
}

/* Comments */
.tl-code-block .token.comment,
.tl-code-block .token.prolog,
.tl-code-block .token.doctype {
    color: #6a9955;
    font-style: italic;
}

/* Class names, types, decorators */
.tl-code-block .token.class-name,
.tl-code-block .token.maybe-class-name {
    color: #4ec9b0;
}

/* Functions */
.tl-code-block .token.function {
    color: #dcdcaa;
}

/* Operators: =, +, -, *, /, =>, : */
.tl-code-block .token.operator {
    color: #d4d4d4;
    background: none;
}

/* Punctuation: { } ( ) [ ] ; , . */
.tl-code-block .token.punctuation {
    color: #d4d4d4;
}

/* HTML tags */
.tl-code-block .token.tag .token.tag,
.tl-code-block .token.tag > .token.punctuation {
    color: #4ec9b0;
}

/* HTML attributes */
.tl-code-block .token.attr-name {
    color: #9cdcfe;
}

/* CSS properties */
.tl-code-block .token.property {
    color: #9cdcfe;
}

/* CSS selectors */
.tl-code-block .token.selector {
    color: #d7ba7d;
}

/* CSS values / units */
.tl-code-block .token.unit,
.tl-code-block .token.color {
    color: #b5cea8;
}

/* Variables */
.tl-code-block .token.variable {
    color: #9cdcfe;
}

/* Regex */
.tl-code-block .token.regex {
    color: #d16969;
}

/* Decorators (@Component, @NgModule) */
.tl-code-block .token.decorator,
.tl-code-block .token.atrule {
    color: #c586c0;
}

/* Imports / namespaces */
.tl-code-block .token.namespace {
    color: #4ec9b0;
}

/* Git/shell commands */
.tl-code-block .token.builtin {
    color: #dcdcaa;
}

/* --- Line number gutter (if enabled) --- */
.tl-code-block .line-numbers .line-numbers-rows {
    border-right: 1px solid #333;
}

.tl-code-block .line-numbers-rows > span::before {
    color: #495057;
}

/* --- Responsive --- */
@media (max-width: 575.98px) {
    .tl-code-titlebar {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 8px;
    }
    .tl-code-title {
        font-size: 0.7rem;
        min-width: 0;
    }
    .tl-code-titlebar > .tl-run-btn,
    .tl-code-titlebar > .tl-copy-btn,
    .tl-code-actions {
        grid-column: 1 / -1;
    }
    .tl-code-titlebar > .tl-run-btn,
    .tl-code-titlebar > .tl-copy-btn {
        justify-self: start;
        gap: 0;
        font-size: 0;
    }
    .tl-code-titlebar > .tl-run-btn i,
    .tl-code-titlebar > .tl-copy-btn i {
        font-size: 0.86rem;
    }
    .tl-tab {
        padding: 7px 10px;
        font-size: 0.75rem;
    }
    .tl-code-block pre[class*="language-"] {
        font-size: 0.82rem;
        padding: 16px 16px;
    }
}



/* Shared Online Editor Layout */
.tl-editor-top-menu {
    height: 50px;
    padding-left: 10px;
    padding-right: 10px;
    border-top: 1px solid #e84c3d;
    overflow: hidden;
    min-width: 380px;
    position: absolute;
    width: 100%;
    top: 89px;
}
#code-container {
    background-color: #f1f1f1;
    width: 100%;
    overflow: auto;
    position: absolute;
    top: 138px;
    bottom: 0;
    height: auto;
}
#ide-input,
#ide-output {
    float: left;
    height: 100%;
    width: 50%;
}
#textarea,
#iframe {
    height: 100%;
    width: 100%;
    padding-bottom: 10px;
    padding-top: 1px;
}
#textarea {
    padding-left: 10px;
    padding-right: 5px;
}
#iframe {
    padding-left: 5px;
    padding-right: 10px;
}
#textareawrapper {
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
#iframewrapper {
    font-size: 15px;
    padding: 8px;
    resize: none;
    border: none;
    line-height: normal;
    width: 100%;
    height: 100%;
    -webkit-overflow-scrolling: touch;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
#textareaCode {
    background-color: #ffffff;
    font-family: consolas, "courier new", monospace;
    font-size: 15px;
    height: 100%;
    width: 100%;
    padding: 8px;
    resize: none;
    border: none;
    line-height: normal;
}
#iframeResult,
#iframeSource {
    background-color: #ffffff;
    height: 100%;
    width: 100%;
}
#textarea.horizontal {
    height: 100%;
    padding-left: 10px;
    padding-right: 10px;
}
#iframe.horizontal {
    height: 100%;
    padding-right: 10px;
    padding-bottom: 10px;
    padding-left: 10px;
}
.tl-nav-text {
    color: white;
    font-size: 16px;
    margin-left: 20px;
}
@media screen and (max-width: 727px) {
    .tl-editor-top-menu {
        top: 70px;
    }
    #code-container {
        top: 108px;
    }
}
@media screen and (max-width: 467px) {
    .tl-editor-top-menu {
        top: 60px;
    }
    #code-container {
        top: 98px;
    }
    .tl-dropdown-content {
        width: 100%;
    }
}
@media only screen and (max-device-width: 768px) {
    #iframewrapper {
        overflow: auto;
    }
    #code-container {
        min-width: 320px;
    }
    .tl-stack {
        display: none;
    }
    #tryhome {
        display: block;
    }
}


/* TL Compiler Feature Overlays */
/* ===========================================================
   Compiler Enhanced Features Styles
   =========================================================== */

/* Toolbar Buttons */
.tl-btn-templates,
.tl-btn-recent,
.tl-btn-share {
    background: #2d3748;
    color: #a0aec0;
    border: 1px solid #4a5568;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-right: 2px;
    min-width: 36px;
    height: 36px;
}

.tl-btn-templates:hover,
.tl-btn-recent:hover,
.tl-btn-share:hover {
    background: #4a5568;
    color: #fff;
}

.tl-btn-templates i,
.tl-btn-recent i,
.tl-btn-share i {
    font-size: 1rem;
}

/* Add spacing to file label */
.editor-toolbar .file-label {
    margin-right: 2px;
}

/* Add spacing to clear button */
.tl-btn-clear-editor {
    margin-right: 2px !important;
}

/* Modal */
.tl-compiler-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tl-compiler-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.tl-compiler-modal-content {
    position: relative;
    background: #16213e;
    border: 1px solid #2d3748;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tl-compiler-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #2d3748;
}

.tl-compiler-modal-header h3 {
    color: #e2e8f0;
    font-size: 1.2rem;
    margin: 0;
    font-weight: 600;
}

.tl-compiler-modal-header button {
    background: transparent;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    padding: 8px;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.tl-compiler-modal-header button:hover {
    color: #e2e8f0;
}

.tl-compiler-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Template/Recent Item */
.template-item {
    background: #0d1117;
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.template-item:hover {
    background: #1a202c;
    border-color: #9333ea;
    transform: translateX(4px);
}

.template-item i {
    color: #9333ea;
    font-size: 1.2rem;
}

.template-item span {
    color: #e2e8f0;
    font-weight: 500;
    flex: 1;
}

/* Keyboard Shortcuts */
.keyboard-shortcuts-hint {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
}

.keyboard-shortcuts-hint button {
    background: rgba(147, 51, 234, 0.9);
    color: #fff;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.4);
    transition: all 0.3s ease;
}

.keyboard-shortcuts-hint button:hover {
    background: rgba(147, 51, 234, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(147, 51, 234, 0.5);
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #0d1117;
    border-radius: 6px;
}

.shortcut-item kbd {
    background: #2d3748;
    color: #9333ea;
    padding: 6px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid #4a5568;
}

.shortcut-item span {
    color: #e2e8f0;
    font-size: 0.9rem;
}

/* Notification */
.compiler-notification {
    position: fixed;
    top: 80px;
    right: -300px;
    background: rgba(22, 33, 62, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    color: #e2e8f0;
    font-size: 0.9rem;
    max-width: 300px;
    transition: right 0.3s ease;
}

.compiler-notification.show {
    right: 20px;
}

.compiler-notification.success {
    border-left: 4px solid #38a169;
}

.compiler-notification.error {
    border-left: 4px solid #e53e3e;
}

.compiler-notification.info {
    border-left: 4px solid #9333ea;
}

/* Responsive */
@media (max-width: 768px) {
    .tl-compiler-modal-content {
        max-width: 95%;
        max-height: 90vh;
    }

    .tl-btn-templates span,
    .tl-btn-recent span,
    .tl-btn-share span {
        display: none;
    }

    .tl-btn-templates,
    .tl-btn-recent,
    .tl-btn-share {
        padding: 6px 10px;
    }

    .keyboard-shortcuts-hint {
        bottom: 80px;
        left: 16px;
    }

    .keyboard-shortcuts-hint button {
        width: 44px;
        height: 44px;
    }
}

/* Hide on print */
@media print {
    .tl-btn-templates,
    .tl-btn-recent,
    .tl-btn-share,
    .tl-compiler-modal,
    .keyboard-shortcuts-hint,
    .compiler-notification {
        display: none !important;
    }
}
