/**
 * JavaScriptEditor Component Styles
 * Uses design tokens for consistency with OpenNoodl design system
 */

.Root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background-color: var(--theme-color-bg-1);
  border: 1px solid var(--theme-color-border-default);
  border-radius: 6px;
  overflow: hidden;
}

/* Toolbar */
.Toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: var(--theme-color-bg-2);
  border-bottom: 1px solid var(--theme-color-border-default);
  min-height: 36px;
}

.ToolbarLeft,
.ToolbarRight {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ModeLabel {
  font-size: 12px;
  font-weight: 600;
  color: var(--theme-color-fg-default);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.StatusValid {
  font-size: 12px;
  font-weight: 500;
  color: var(--theme-color-success);
}

.StatusInvalid {
  font-size: 12px;
  font-weight: 500;
  color: var(--theme-color-error);
}

.FormatButton,
.SaveButton {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--theme-color-border-default);
  background-color: var(--theme-color-bg-3);
  color: var(--theme-color-fg-default);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover:not(:disabled) {
    background-color: var(--theme-color-bg-4);
    border-color: var(--theme-color-primary);
  }

  &:active:not(:disabled) {
    transform: translateY(1px);
  }

  &:disabled {
    cursor: not-allowed;
    opacity: 0.5;
  }
}

.SaveButton {
  background-color: var(--theme-color-primary);
  color: white;
  border-color: var(--theme-color-primary);

  &:hover:not(:disabled) {
    background-color: var(--theme-color-primary-hover, var(--theme-color-primary));
    border-color: var(--theme-color-primary-hover, var(--theme-color-primary));
  }
}

.CloseButton {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--theme-color-border-default);
  background-color: var(--theme-color-bg-4);
  color: var(--theme-color-fg-default);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    background-color: var(--theme-color-bg-5);
    border-color: var(--theme-color-fg-default-shy);
  }

  &:active {
    transform: translateY(1px);
  }
}

/* Editor Container with CodeMirror */
.EditorContainer {
  flex: 1;
  overflow: hidden;
  position: relative;
  background-color: var(--theme-color-bg-2);

  /* CodeMirror will fill this container */
  :global(.cm-editor) {
    height: 100%;
    font-family: var(--theme-font-mono, 'Monaco', 'Menlo', 'Courier New', monospace);
  }

  :global(.cm-scroller) {
    overflow: auto;
  }
}

/* Error Panel */
.ErrorPanel {
  padding: 12px 16px;
  background-color: #fef2f2;
  border-top: 1px solid #fecaca;
}

.ErrorHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ErrorIcon {
  font-size: 18px;
  line-height: 1;
}

.ErrorTitle {
  font-size: 13px;
  font-weight: 600;
  color: #dc2626;
}

.ErrorMessage {
  font-size: 13px;
  color: #7c2d12;
  line-height: 1.5;
  font-family: var(--theme-font-mono, 'Monaco', 'Menlo', 'Courier New', monospace);
  padding: 8px 12px;
  background-color: #fff;
  border: 1px solid #fecaca;
  border-radius: 4px;
  margin-bottom: 8px;
}

.ErrorSuggestion {
  font-size: 12px;
  color: #7c2d12;
  line-height: 1.4;
  padding: 8px 12px;
  background-color: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 4px;
  margin-bottom: 8px;

  strong {
    font-weight: 600;
  }
}

.ErrorLocation {
  font-size: 11px;
  color: #92400e;
  font-family: var(--theme-font-mono, 'Monaco', 'Menlo', 'Courier New', monospace);
  font-weight: 500;
}

/* Footer with resize grip */
.Footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background-color: var(--theme-color-bg-2);
  border-top: 1px solid var(--theme-color-border-default);
  min-height: 24px;
  flex-shrink: 0;
}

.FooterLeft,
.FooterRight {
  display: flex;
  align-items: center;
  gap: 8px;
}
