.cm-editor {
  height: 100%;
  font-family: monospace;
  border-radius: 4px;
  overflow: hidden;
}

.cm-scroller {
  overflow: auto;
}

.cm-content {
  padding: 10px;
}

.cm-line {
  padding: 0 4px;
  line-height: 1.6;
}

.cm-activeLineGutter {
  background-color: rgba(0, 0, 0, 0.1);
}

.cm-gutters {
  border-right: 1px solid var(--color-border);
  background-color: var(--color-code-background);
  color: var(--color-text-3);
}

.cm-gutterElement {
  padding: 0 3px 0 5px;
}

/* Dark theme specific styles */
.dark-theme .cm-editor {
  background-color: #282c34;
  color: #abb2bf;
}

.dark-theme .cm-gutters {
  background-color: #21252b;
  color: #636d83;
}

.dark-theme .cm-activeLineGutter {
  background-color: rgba(255, 255, 255, 0.1);
}

/* 自动补全样式 */
.cm-tooltip {
  border: 1px solid var(--color-border);
  background-color: var(--color-background);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.cm-tooltip.cm-tooltip-autocomplete {
  min-width: 200px;
}

.cm-tooltip-autocomplete ul {
  font-family: monospace;
  padding: 0;
  margin: 0;
}

.cm-tooltip-autocomplete li {
  padding: 4px 8px;
  cursor: pointer;
}

.cm-tooltip-autocomplete li:hover {
  background-color: var(--color-hover);
}

.cm-tooltip-autocomplete .cm-completionLabel {
  color: var(--color-text);
}

.cm-tooltip-autocomplete .cm-completionDetail {
  color: var(--color-text-3);
  font-size: 0.9em;
  margin-left: 8px;
}

.cm-tooltip-autocomplete .cm-completionIcon {
  display: none;
}

.cm-tooltip-autocomplete .cm-completionMatchedText {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: bold;
}

.dark-theme .cm-tooltip {
  background-color: #282c34;
  border-color: #3e4451;
}

.dark-theme .cm-tooltip-autocomplete .cm-completionLabel {
  color: #abb2bf;
}

.dark-theme .cm-tooltip-autocomplete .cm-completionDetail {
  color: #636d83;
}

.dark-theme .cm-tooltip-autocomplete .cm-completionMatchedText {
  color: #61afef;
}

.dark-theme .cm-tooltip-autocomplete li:hover {
  background-color: #3e4451;
}

/* 查找和替换面板样式 */
.cm-search {
  max-width: 300px;
  display: flex;
  flex-direction: column;
  padding: 8px;
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 200;
}

.cm-search input {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  background-color: var(--color-background);
  color: var(--color-text);
}

.cm-search button {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 8px;
  margin: 2px;
  background-color: var(--color-background);
  color: var(--color-text);
  cursor: pointer;
}

.cm-search button:hover {
  background-color: var(--color-hover);
}

.cm-search label {
  display: flex;
  align-items: center;
  margin: 2px 0;
  font-size: 0.9em;
  color: var(--color-text);
}

.cm-search input[type="checkbox"] {
  margin-right: 4px;
}

.cm-searchMatch {
  background-color: rgba(250, 166, 26, 0.2);
}

.cm-searchMatch-selected {
  background-color: rgba(250, 166, 26, 0.5);
}

.dark-theme .cm-search {
  background-color: #282c34;
  border-color: #3e4451;
}

.dark-theme .cm-search input {
  background-color: #21252b;
  border-color: #3e4451;
  color: #abb2bf;
}

.dark-theme .cm-search button {
  background-color: #21252b;
  border-color: #3e4451;
  color: #abb2bf;
}

.dark-theme .cm-search button:hover {
  background-color: #3e4451;
}

.dark-theme .cm-search label {
  color: #abb2bf;
}

.dark-theme .cm-searchMatch {
  background-color: rgba(229, 192, 123, 0.3);
}

.dark-theme .cm-searchMatch-selected {
  background-color: rgba(229, 192, 123, 0.6);
}

/* 中文搜索面板样式覆盖 */
.cm-panel.cm-search {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.cm-panel.cm-search input[name="search"] {
  width: 10em;
}

.cm-panel.cm-search input[name="replace"] {
  width: 10em;
}

.cm-panel.cm-search button[name="find"] {
  content: '查找';
}

.cm-panel.cm-search button[name="next"] {
  content: '下一个';
}

.cm-panel.cm-search button[name="prev"] {
  content: '上一个';
}

.cm-panel.cm-search button[name="replace"] {
  content: '替换';
}

.cm-panel.cm-search button[name="replaceAll"] {
  content: '全部替换';
}

.cm-panel.cm-search label[for="case"] {
  content: '区分大小写';
}

.cm-panel.cm-search label[for="regexp"] {
  content: '正则表达式';
}

.cm-panel.cm-search label[for="word"] {
  content: '全词匹配';
}

/* 修改按钮文本 */
.cm-panel.cm-search button[name="find"]::before {
  content: '查找';
}

.cm-panel.cm-search button[name="next"]::before {
  content: '下一个';
}

.cm-panel.cm-search button[name="prev"]::before {
  content: '上一个';
}

.cm-panel.cm-search button[name="replace"]::before {
  content: '替换';
}

.cm-panel.cm-search button[name="replaceAll"]::before {
  content: '全部替换';
}

/* 修改标签文本 */
.cm-panel.cm-search label[for="case"]::after {
  content: '区分大小写';
}

.cm-panel.cm-search label[for="regexp"]::after {
  content: '正则表达式';
}

.cm-panel.cm-search label[for="word"]::after {
  content: '全词匹配';
}

/* 添加自定义主题样式，确保针对不同代码风格的样式能被正确应用 */

/* Ayu Dark 主题 */
.ayu-dark-theme .cm-editor {
  background-color: #0F1419;
  color: #E6E1CF;
}
.ayu-dark-theme .cm-gutters {
  background-color: #0F1419;
  color: #5C6773;
  border-right: 1px solid #5C677333;
}
.ayu-dark-theme .cm-activeLineGutter {
  background-color: #E6E1CF0F;
}
.ayu-dark-theme .cm-cursor {
  border-left-color: #E6E1CF;
}
.ayu-dark-theme .cm-selectionBackground {
  background-color: #E6E1CF33;
}

/* Andromeda 主题 */
.andromeda-theme .cm-editor {
  background-color: #23262E;
  color: #D5CED9;
}
.andromeda-theme .cm-gutters {
  background-color: #23262E;
  color: #6C6F93;
  border-right: 1px solid #6C6F9333;
}
.andromeda-theme .cm-activeLineGutter {
  background-color: #D5CED90F;
}
.andromeda-theme .cm-cursor {
  border-left-color: #D5CED9;
}
.andromeda-theme .cm-selectionBackground {
  background-color: #D5CED933;
}

/* Aurora X 主题 */
.aurora-x-theme .cm-editor {
  background-color: #011627;
  color: #D6DEEB;
}
.aurora-x-theme .cm-gutters {
  background-color: #011627;
  color: #637777;
  border-right: 1px solid #63777733;
}
.aurora-x-theme .cm-activeLineGutter {
  background-color: #D6DEEB0F;
}
.aurora-x-theme .cm-cursor {
  border-left-color: #D6DEEB;
}
.aurora-x-theme .cm-selectionBackground {
  background-color: #D6DEEB33;
}

/* Catppuccin Frappe 主题 */
.catppuccin-frappe-theme .cm-editor {
  background-color: #303446;
  color: #C6D0F5;
}
.catppuccin-frappe-theme .cm-gutters {
  background-color: #303446;
  color: #838BA7;
  border-right: 1px solid #838BA733;
}
.catppuccin-frappe-theme .cm-activeLineGutter {
  background-color: #C6D0F50F;
}
.catppuccin-frappe-theme .cm-cursor {
  border-left-color: #C6D0F5;
}
.catppuccin-frappe-theme .cm-selectionBackground {
  background-color: #C6D0F533;
}

/* Catppuccin Macchiato 主题 */
.catppuccin-macchiato-theme .cm-editor {
  background-color: #24273A;
  color: #CAD3F5;
}
.catppuccin-macchiato-theme .cm-gutters {
  background-color: #24273A;
  color: #8087A2;
  border-right: 1px solid #8087A233;
}
.catppuccin-macchiato-theme .cm-activeLineGutter {
  background-color: #CAD3F50F;
}
.catppuccin-macchiato-theme .cm-cursor {
  border-left-color: #CAD3F5;
}
.catppuccin-macchiato-theme .cm-selectionBackground {
  background-color: #CAD3F533;
}

/* Catppuccin Mocha 主题 */
.catppuccin-mocha-theme .cm-editor {
  background-color: #1E1E2E;
  color: #CDD6F4;
}
.catppuccin-mocha-theme .cm-gutters {
  background-color: #1E1E2E;
  color: #7F849C;
  border-right: 1px solid #7F849C33;
}
.catppuccin-mocha-theme .cm-activeLineGutter {
  background-color: #CDD6F40F;
}
.catppuccin-mocha-theme .cm-cursor {
  border-left-color: #CDD6F4;
}
.catppuccin-mocha-theme .cm-selectionBackground {
  background-color: #CDD6F433;
}

/* Catppuccin Latte 主题（亮色） */
.catppuccin-latte-theme .cm-editor {
  background-color: #EFF1F5;
  color: #4C4F69;
}
.catppuccin-latte-theme .cm-gutters {
  background-color: #EFF1F5;
  color: #ACB0BE;
  border-right: 1px solid #ACB0BE33;
}
.catppuccin-latte-theme .cm-activeLineGutter {
  background-color: #4C4F690F;
}
.catppuccin-latte-theme .cm-cursor {
  border-left-color: #4C4F69;
}
.catppuccin-latte-theme .cm-selectionBackground {
  background-color: #4C4F6933;
}
