/* Butterscript CodeMirror Theme
   Custom syntax highlighting theme that matches the butterscript UI
   Primary accent color: #F5E985 (yellow)
   Background: #1c1c1e (dark gray)
*/

/* Main editor container */
.CodeMirror {
    height: 100%;
    font-family: 'IBM Plex Mono', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.7;
    color: #ffffff;
    background: #1c1c1e;
    border: none;
    padding: 24px;
}

/* Set the cursor color to match the accent */
.CodeMirror-cursor {
    border-left: 2px solid #F5E985;
}

/* Highlighted active line */
.CodeMirror-activeline-background {
    background: rgba(245, 233, 133, 0.05);
}

/* Selection styling */
.CodeMirror-selected {
    background: rgba(245, 233, 133, 0.3);
}
.CodeMirror-focused .CodeMirror-selected {
    background: rgba(245, 233, 133, 0.3);
}

/* Matching bracket highlighting */
.CodeMirror-matchingbracket {
    color: #F5E985 !important;
    text-decoration: underline;
    font-weight: bold;
    background: rgba(245, 233, 133, 0.1);
    border-radius: 3px;
}

/* Gutters and line numbers (if enabled) */
.CodeMirror-gutters {
    background: #1c1c1e;
    border-right: 1px solid #2c2c2e;
}
.CodeMirror-linenumber {
    color: #8e8e93;
}

/* Scrollbars */
.CodeMirror-vscrollbar::-webkit-scrollbar,
.CodeMirror-hscrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.CodeMirror-vscrollbar::-webkit-scrollbar-track,
.CodeMirror-hscrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.CodeMirror-vscrollbar::-webkit-scrollbar-thumb,
.CodeMirror-hscrollbar::-webkit-scrollbar-thumb {
    background: #48484a;
    border-radius: 4px;
}
.CodeMirror-vscrollbar::-webkit-scrollbar-thumb:hover,
.CodeMirror-hscrollbar::-webkit-scrollbar-thumb:hover {
    background: #F5E985;
}

/* Syntax highlighting colors */

/* CodeMirror simple mode token highlighting */
.cm-keyword {
    color: #F5E985;
    font-weight: 600;
}

.cm-bracket {
    color: #f0e270;
    font-weight: normal;
}

.cm-attribute {
    color: #bb9af7;
}

.cm-string {
    color: #7dcfff;
}

.cm-variable {
    color: #9ece6a;
}

.cm-comment {
    color: #565f89;
    font-style: italic;
}

.cm-error {
    color: #f7768e;
    text-decoration: wavy underline;
}

/* Elements (heading1, paragraph, list, etc.) */
.cm-butterscript-element {
    color: #F5E985;
    font-weight: 600;
}

/* Brackets and structural characters */
.cm-butterscript-bracket {
    color: #f0e270;
    font-weight: normal;
}

/* Parameters and attributes */
.cm-butterscript-param {
    color: #ff9e64;
}

/* Parameter values */
.cm-butterscript-paramValue {
    color: #7dcfff;
}

/* Modifiers (.bold, .italic, etc.) */
.cm-butterscript-modifier {
    color: #bb9af7;
}

/* Nested formatting content */
.cm-butterscript-content {
    color: #c0caf5;
}

/* Comments */
.cm-butterscript-comment {
    color: #565f89;
    font-style: italic;
}

/* Snippets */
.cm-butterscript-snippet {
    color: #9ece6a;
}

/* Variables or special constructs */
.cm-butterscript-variable {
    color: #ff9e64;
}

/* Error states */
.cm-butterscript-error {
    color: #f7768e;
    text-decoration: wavy underline;
    text-decoration-color: #f7768e;
}

/* CodeMirror Hints - Custom styling to match VSCode */
.CodeMirror-hints {
    position: fixed !important;
    z-index: 10000 !important;
    max-height: 200px;
    min-height: 50px;
    background: #252526 !important;
    border: 1px solid #F5E985 !important;
    border-radius: 3px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.8) !important;
    overflow-y: auto;
    width: auto;
    min-width: 280px;
    max-width: 350px;
    animation: fadeInAutocomplete 0.1s ease;
    backdrop-filter: blur(10px);
    font-family: 'IBM Plex Mono', monospace !important;
    font-size: 14px !important;
    padding: 2px 0 !important;
    margin: 0 !important;
    list-style: none !important;
    display: block !important;
    color: white !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Add a header to the hints panel like VSCode */
.CodeMirror-hints::before {
    content: "Butterscript Suggestions";
    display: block;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #8e8e93;
    border-bottom: 1px solid #38383a;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.CodeMirror-hint {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 6px 12px !important;
    margin: 0 !important;
    white-space: nowrap !important;
    color: #ffffff !important;
    cursor: pointer !important;
    transition: background 0.1s, transform 0.1s !important;
    border-left: 3px solid transparent !important;
    background: transparent !important;
    font-family: 'IBM Plex Mono', monospace !important;
}

.CodeMirror-hint-active {
    background: #04395e !important;
    color: #ffffff !important;
    border-left-color: #F5E985 !important;
}

/* Material icons in hints */
.CodeMirror-hint .material-icons {
    font-size: 16px;
    opacity: 0.7;
}

.CodeMirror-hint-active .material-icons {
    color: #F5E985;
    opacity: 1;
}

.CodeMirror-hint .item-text {
    flex: 1;
}

.CodeMirror-hint .item-type {
    font-size: 11px;
    opacity: 0.7;
    padding: 2px 6px;
    background: #38383a;
    border-radius: 4px;
    font-family: 'IBM Plex Sans', sans-serif;
    letter-spacing: -0.2px;
    font-weight: 500;
}

/* Animation for autocomplete popup */
@keyframes fadeInAutocomplete {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide scrollbar when not needed */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar {
    display: block;
}

/* Completion details tooltip */
.butterscript-completion-details {
    position: absolute;
    z-index: 1100;
    background: #252526;
    border: 1px solid #454545;
    border-radius: 3px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    min-width: 300px;
    max-width: 400px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 13px;
    color: #ffffff;
    padding: 0;
    margin: 0;
    animation: fadeInTooltip 0.2s ease;
    backdrop-filter: blur(10px);
}

@keyframes fadeInTooltip {
    from {
        opacity: 0;
        transform: translateX(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #333336;
    border-bottom: 1px solid #454545;
}

.tooltip-header .material-icons {
    color: #F5E985;
    font-size: 18px;
}

.tooltip-title {
    flex: 1;
    font-weight: 600;
}

.tooltip-type {
    font-size: 11px;
    padding: 2px 6px;
    background: #38383a;
    border-radius: 4px;
    font-weight: 500;
}

.tooltip-description {
    padding: 10px 12px;
    line-height: 1.5;
    border-bottom: 1px solid #38383a;
    color: #cccccc;
}

.tooltip-snippet {
    padding: 10px 12px;
    background: #1e1e1e;
    font-family: 'IBM Plex Mono', monospace;
    color: #d7d7d7;
    font-size: 12px;
}

.tooltip-snippet code {
    display: block;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* Autocomplete status indicator in status bar */
.autocomplete-status {
    color: #F5E985;
    font-weight: 600;
    animation: pulse 2s infinite alternate;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

/* Basic styling for plain hints without custom rendering */
.CodeMirror-hint:not(:has(*)) {
    display: block !important;
    padding: 6px 12px !important;
    font-family: 'IBM Plex Mono', monospace !important;
    font-size: 14px !important;
    color: #ffffff !important;
}

/* Custom suggestions panel */
.custom-suggestions {
    position: fixed;
    z-index: 10000;
    max-height: 200px;
    min-width: 280px;
    max-width: 350px;
    background: #252526;
    border: 1px solid #F5E985;
    border-radius: 3px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    display: none;
    font-family: 'IBM Plex Mono', monospace;
    color: white;
    animation: fadeInAutocomplete 0.1s ease;
}

.suggestions-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    border-left: 3px solid transparent;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.suggestion-item:hover {
    background: #2a2d2e;
}

.suggestion-item.selected {
    background: #04395e;
    border-left-color: #F5E985;
}

.suggestion-icon {
    font-size: 16px;
    opacity: 0.7;
    flex-shrink: 0;
}

.suggestion-item.selected .suggestion-icon,
.suggestion-item:hover .suggestion-icon {
    color: #F5E985;
    opacity: 1;
}

.suggestion-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-type {
    font-size: 11px;
    opacity: 0.7;
    padding: 2px 6px;
    background: #38383a;
    border-radius: 4px;
    font-family: 'IBM Plex Sans', sans-serif;
    letter-spacing: -0.2px;
    font-weight: 500;
    flex-shrink: 0;
}

.suggestion-arrow {
    position: absolute;
    top: -5px;
    width: 10px;
    height: 5px;
    overflow: hidden;
}

.suggestion-arrow::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #252526;
    border-top: 1px solid #F5E985;
    border-left: 1px solid #F5E985;
    transform: rotate(45deg);
    top: 3px;
    left: 0;
}
