/**
 * KannadaLipi - Editor Styles
 * Styles for the code editor with syntax highlighting
 */

/* Editor Container */
.editor-wrapper {
    display: flex;
    height: 100%;
    min-height: 400px;
    background: var(--bg-base);
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1.6;
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* Line Numbers */
.line-numbers {
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    padding: var(--gap-md) var(--gap-sm);
    text-align: right;
    user-select: none;
    min-width: 50px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.line-number {
    height: 1.6em;
    padding-right: var(--gap-sm);
    font-size: 14px;
}

/* Editor Content Area */
.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Highlight Layer (behind textarea) */
.highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: var(--gap-md);
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 1;
}

/* Textarea (on top, transparent text - only caret visible) */
#codeInput,
.editor-textarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: var(--gap-md);
    margin: 0;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: transparent;
    caret-color: var(--accent);
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    z-index: 2;
    overflow: auto;
    -webkit-text-fill-color: transparent;
}

/* Text selection visibility fix - show selection on transparent text */
#codeInput::selection,
.editor-textarea::selection {
    background: rgba(255, 215, 0, 0.4);
    color: transparent;
    -webkit-text-fill-color: transparent;
}

#codeInput::-moz-selection,
.editor-textarea::-moz-selection {
    background: rgba(255, 215, 0, 0.4);
    color: transparent;
    -webkit-text-fill-color: transparent;
}

#codeInput:focus,
.editor-textarea:focus {
    outline: none;
}

/* Syntax Highlighting Classes */
.hl-keyword-control {
    color: var(--hl-keyword);
    font-weight: 600;
}

.hl-keyword-function {
    color: var(--hl-func);
    font-weight: 600;
}

.hl-builtin {
    color: var(--hl-func);
    font-weight: 500;
}

.hl-string {
    color: var(--hl-str);
}

.hl-number {
    color: var(--hl-num);
}

.hl-comment {
    color: var(--hl-comment);
    font-style: italic;
}

.hl-operator {
    color: var(--text-primary);
}

.hl-punctuation {
    color: var(--text-secondary);
}

.hl-boolean {
    color: var(--hl-keyword);
    font-weight: 600;
}

/* ============================================
   Virtual Keyboard - Modern Floating Design
   ============================================ */
.virtual-keyboard {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    padding: var(--gap-sm);
    transition: all 0.3s ease;
    overflow: hidden;
}

.virtual-keyboard.hidden {
    transform: translateX(-50%) translateY(120%);
    opacity: 0;
}

.keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gap-xs) var(--gap-sm);
    margin-bottom: var(--gap-xs);
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.1), rgba(215, 25, 32, 0.1));
    border-radius: var(--radius-sm);
}

.keyboard-title {
    font-weight: 600;
    color: var(--accent);
    font-size: 0.85rem;
}

.keyboard-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.keyboard-close:hover {
    background: var(--k-red);
    color: white;
}

.keyboard-tabs {
    display: flex;
    gap: 4px;
    padding: var(--gap-xs);
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    margin-bottom: var(--gap-sm);
    overflow-x: auto;
    scrollbar-width: none;
}

.keyboard-tabs::-webkit-scrollbar {
    display: none;
}

.keyboard-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.7rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.keyboard-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.keyboard-tab.active {
    background: var(--accent);
    color: var(--bg-base);
    font-weight: 600;
}

.keyboard-keys {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(36px, 1fr));
    gap: 4px;
    padding: var(--gap-xs);
    max-height: 140px;
    overflow-y: auto;
}

.keyboard-row {
    display: contents;
}

.keyboard-key {
    background: var(--bg-surface-elevated);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    min-width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 1rem;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.keyboard-key:hover {
    background: var(--accent);
    color: var(--bg-base);
    border-color: var(--accent);
}

.keyboard-key:active {
    transform: scale(0.95);
}

.keyboard-key.keyword-key {
    grid-column: span 2;
    min-width: auto;
    padding: 0 8px;
    font-size: 0.7rem;
    font-family: var(--font-main);
}

.keyboard-actions {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: var(--gap-xs);
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    margin-top: var(--gap-xs);
}

.keyboard-action {
    background: var(--bg-surface-elevated);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.8rem;
    transition: all 0.2s ease;
    flex: 1;
    max-width: 120px;
}

.keyboard-action:hover {
    background: var(--accent);
    color: var(--bg-base);
    border-color: var(--accent);
}

/* Editor Status Bar */
.editor-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gap-xs) var(--gap-md);
    background: var(--bg-surface-elevated);
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.status-item {
    display: flex;
    align-items: center;
    gap: var(--gap-xs);
}

/* Responsive - Smaller keyboard on mobile */
@media (max-width: 768px) {
    .editor-wrapper {
        min-height: 300px;
    }

    .virtual-keyboard {
        width: 95%;
        bottom: 10px;
        padding: var(--gap-xs);
    }

    .keyboard-keys {
        grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
        max-height: 120px;
    }

    .keyboard-key {
        min-width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .keyboard-key.keyword-key {
        font-size: 0.65rem;
        padding: 0 6px;
    }

    .keyboard-tab {
        padding: 4px 8px;
        font-size: 0.65rem;
    }

    .keyboard-action {
        padding: 6px 14px;
        font-size: 0.75rem;
    }

    .line-numbers {
        min-width: 40px;
        font-size: 12px;
    }

    .keyboard-title {
        font-size: 0.8rem;
    }

    .keyboard-header {
        padding: 4px var(--gap-xs);
    }
}

@media (max-width: 480px) {
    .virtual-keyboard {
        width: 98%;
        bottom: 5px;
        border-radius: var(--radius-md);
    }

    .keyboard-keys {
        grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
        max-height: 100px;
        gap: 3px;
    }

    .keyboard-key {
        min-width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .keyboard-key.keyword-key {
        font-size: 0.6rem;
        padding: 0 4px;
    }

    .keyboard-tabs {
        gap: 2px;
        padding: 4px;
    }

    .keyboard-tab {
        padding: 3px 6px;
        font-size: 0.6rem;
    }

    .keyboard-action {
        padding: 5px 10px;
        font-size: 0.7rem;
        max-width: 80px;
    }

    .keyboard-actions {
        gap: 3px;
    }
}

/* Code Examples in panels */
.code-example {
    background: var(--bg-base);
    border-radius: var(--radius-md);
    padding: var(--gap-md);
    margin: var(--gap-md) 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.code-example pre {
    margin: 0;
    white-space: pre-wrap;
}

/* Editor panel body fix */
.panel-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-base);
}

#editor {
    height: 100%;
    min-height: 400px;
}
