#rule-editor {
    position: relative;
}

#rule-editor #rule-editor-version {
    text-align: center;
}

#rule-editor .textbox-label {
    width: auto !important;
}

#rule-editor .editor-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

#rule-editor .editor-wrapper {
    position: relative;
    border: 2px solid #ccc;
    border-radius: 4px;
    background: white;
}

#rule-editor #editor {
    width: 100%;
    min-height: 40px;
    padding: 10px;
    border: none;
    outline: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    background: transparent;
    color: transparent;
    caret-color: black;
    position: relative;
    z-index: 2;
    box-sizing: border-box;
    resize: none;
    overflow: hidden;
}

#rule-editor #highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 10px;
    border: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
    box-sizing: border-box;
}

#rule-editor .function-name {
    color: #006400;
    font-weight: bold;
}

#rule-editor .variable {
    color: #7c37ef;
    font-weight: bold;
}

#rule-editor .number {
    color: #af6002;
}

#rule-editor .string-literal {
    color: #17726e;
}

#rule-editor .default-text {
    color: #31353e;
}

#rule-editor .unknown-function {
    color: #000000;
    font-weight: bold;
}

#rule-editor .unknown-variable {
    color: #000000;
    font-weight: bold;
}

#rule-editor .error-token {
    background-color: #ffcccc;
}

#rule-editor .checkbox-container {
    margin-bottom: 10px;
    text-align: center;
}

#rule-editor .checkbox-container label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

#rule-editor .checkbox-container input[type="checkbox"] {
    margin-right: 8px;
}

#rule-editor .visual-editor {
    background: white;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 10px;
}

#rule-editor .rule-item {
    position: relative;
}

#rule-editor .odd-group {
    background: #f3f3f3;
}

#rule-editor .even-group {
    background: #f8f8f8;
}

#rule-editor .rule-item.non-visual {
    background: #fff3cd;
    border-color: #ffeaa7;
}

#rule-editor .rule-item.non-visual::before {
    content: "Text-only rule";
    position: absolute;
    top: -10px;
    right: 10px;
    background: #ffc107;
    color: #856404;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
}

#rule-editor .visual-rule-builder {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#rule-editor .rule-type-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

#rule-editor .rule-type-selector select {
    padding: 5px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 14px;
}

#rule-editor .condition-group {
    padding: 10px;
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
}

#rule-editor .nested-group .condition-group {
    margin-bottom: 10px;
}

#rule-editor .add-group-btn {
    margin-left: 10px;
}

#rule-editor .condition-item {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 3px;
}

#rule-editor .condition-item:last-child {
    margin-bottom: 0;
}

#rule-editor .condition-item select,
#rule-editor .condition-item input {
    padding: 5px 3px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
}

#rule-editor .condition-item .variable-select {
    min-width: 120px;
}

#rule-editor .condition-item .operator-select {
    min-width: 60px;
}

#rule-editor .autocomplete-container {
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: none;
}

#rule-editor .autocomplete-container.visible {
    display: block;
}

#rule-editor .autocomplete-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

#rule-editor .autocomplete-item {
    padding: 8px 12px;
    margin: 4px 0;
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

#rule-editor .autocomplete-item:hover {
    background: #e8f4e8;
    border-color: #006400;
}

#rule-editor .autocomplete-function-name {
    color: #006400;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 4px;
}

#rule-editor .autocomplete-description {
    color: #666;
    font-size: 12px;
    margin-bottom: 4px;
    font-style: italic;
}

#rule-editor .autocomplete-example {
    color: #17726e;
    font-size: 11px;
    background: #f0f8f8;
    padding: 2px 4px;
    border-radius: 2px;
    border-left: 3px solid #17726e;
}

#rule-editor .autocomplete-variable-name {
    color: #7c37ef;
    font-weight: bold;
    font-size: 14px;
}

#rule-editor .error-container {
    margin-top: 10px;
    padding: 10px;
    background: #ffe6e6;
    border: 1px solid #ff9999;
    border-radius: 4px;
    display: none;
}

#rule-editor .error-container.visible {
    display: block;
}

#rule-editor .error-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #cc0000;
    font-size: 14px;
}

#rule-editor .error-item {
    padding: 2px 0;
    color: #cc0000;
    font-size: 13px;
    font-family: 'Courier New', monospace;
}


#rule-editor .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#rule-editor .loading-overlay.hidden {
    display: none;
}

#rule-editor .loading-overlay .spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

#rule-editor .loading-overlay .loading-text {
    font-size: 18px;
    color: #333;
    font-weight: 500;
}

#rule-editor .loading-overlay .loading-subtext {
    font-size: 14px;
    color: #666;
    margin-top: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
