/* Lexxy Editor Styles (Fizzy-style, adapted for DCAlytics)
 * ------------------------------------------------------------------------ */

/* Editor Container */
lexxy-editor {
  display: block;
  position: relative;
  overflow: visible;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background-color: white;
}

.dark lexxy-editor {
  border-color: #4b5563;
  background-color: #1e293b;
}

lexxy-editor figure.node--selected,
lexxy-editor div.node--selected {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

lexxy-editor figure.node--selected img,
lexxy-editor div.node--selected img {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Table Wrapper */
.lexxy-content__table-wrapper {
  margin: 0;
  margin-block: 1ch;
  overflow-x: auto;
}

table th.table-cell--selected,
table td.table-cell--selected {
  background-color: #dbeafe;
}

.dark table th.table-cell--selected,
.dark table td.table-cell--selected {
  background-color: #1e3a5f;
}

table th.lexxy-content__table-cell--selected,
table td.lexxy-content__table-cell--selected {
  background-color: #bfdbfe;
  border-color: #60a5fa;
}

.dark table th.lexxy-content__table-cell--selected,
.dark table td.lexxy-content__table-cell--selected {
  background-color: #1e40af;
  border-color: #3b82f6;
}

table.lexxy-content__table--selection ::selection {
  background: transparent;
}

/* Empty Editor Placeholder */
.lexxy-editor--empty .lexxy-editor__content:not(:has(ul, ol))::before {
  content: attr(placeholder);
  color: currentColor;
  cursor: text;
  opacity: 0.5;
  pointer-events: none;
  position: absolute;
  white-space: pre-line;
}

/* Editor Content Area */
.lexxy-editor__content {
  margin-block-start: 0.5rem;
  min-block-size: 12rem;
  outline: 0;
  padding: 1rem;
  line-height: 1.6;
}

.lexxy-editor__content ::selection {
  background: rgba(59, 130, 246, 0.3);
}

.lexxy-editor__content > :last-child {
  margin-block-end: 0;
}

/* Drag and Drop State */
.lexxy-editor--drag-over {
  background-color: #dbeafe;
  border-radius: 4px;
  outline: 2px dashed #3b82f6;
}

.dark .lexxy-editor--drag-over {
  background-color: #1e3a5f;
  outline-color: #60a5fa;
}

/* Code Language Picker */
.lexxy-code-language-picker {
  -webkit-appearance: none;
  appearance: none;
  background-color: white;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m12 19.5c-.7 0-1.3-.3-1.7-.8l-9.8-11.1c-.7-.8-.6-1.9.2-2.6.8-.6 1.9-.6 2.5.2l8.6 9.8c0 .1.2.1.4 0l8.6-9.8c.7-.8 1.8-.9 2.6-.2s.9 1.8.2 2.6l-9.8 11.1c-.4.5-1.1.8-1.7.8z' fill='%23374151'/%3E%3C/svg%3E");
  background-position: center right 0.9em;
  background-repeat: no-repeat;
  background-size: 0.5em;
  border: 1px solid #d1d5db;
  border-radius: 99rem;
  color: #374151;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  inset-inline-end: 0;
  line-height: 1.15;
  margin: 0.75ch 0.75ch 0 0;
  padding-inline: 1.5ch 1.8em;
  text-align: start;
}

.dark .lexxy-code-language-picker {
  background-color: #1e293b;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m12 19.5c-.7 0-1.3-.3-1.7-.8l-9.8-11.1c-.7-.8-.6-1.9.2-2.6.8-.6 1.9-.6 2.5.2l8.6 9.8c0 .1.2.1.4 0l8.6-9.8c.7-.8 1.8-.9 2.6-.2s.9 1.8.2 2.6l-9.8 11.1c-.4.5-1.1.8-1.7.8z' fill='%23e5e7eb'/%3E%3C/svg%3E");
  border-color: #4b5563;
  color: #e5e7eb;
}

.lexxy-code-language-picker option {
  background-color: white;
  color: #374151;
}

.dark .lexxy-code-language-picker option {
  background-color: #1e293b;
  color: #e5e7eb;
}

/* Toolbar
 * ------------------------------------------------------------------------ */

/* Hide table button (optional - remove if you want table support) */
button[name="table"] {
  display: none;
}

lexxy-toolbar {
  --lexxy-toolbar-icon-size: 1em;
  --lexxy-toolbar-gap: 2px;

  background-color: #f9fafb;
  border-block-end: 1px solid #e5e7eb;
  border-radius: 0.5rem 0.5rem 0 0;
  color: currentColor;
  display: flex;
  font-size: inherit;
  gap: var(--lexxy-toolbar-gap);
  margin: 0;
  max-inline-size: 100%;
  padding: 2px;
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.dark lexxy-toolbar {
  background-color: #1e293b;
  border-color: #4b5563;
}

/* Reset .prose details styles that leak into toolbar dropdowns */
.prose lexxy-toolbar details,
lexxy-toolbar details.lexxy-editor__toolbar-dropdown {
  margin: 0;
  margin-bottom: 0;
  border-radius: 0;
}

.lexxy-editor__toolbar-button {
  --toolbar-button-size: 44px;

  appearance: none;
  aspect-ratio: 1;
  background-color: transparent;
  block-size: var(--toolbar-button-size);
  border: none;
  border-radius: 0.375rem;
  color: #6b7280;
  cursor: pointer;
  display: grid;
  font-size: inherit;
  place-items: center;
}

.dark .lexxy-editor__toolbar-button {
  color: #9ca3af;
}

.lexxy-editor__toolbar-button:focus,
.lexxy-editor__toolbar-button:hover {
  background-color: #e5e7eb;
  box-shadow: none;
}

.dark .lexxy-editor__toolbar-button:focus,
.dark .lexxy-editor__toolbar-button:hover {
  background-color: #374151;
}

.lexxy-editor__toolbar-button:active,
.lexxy-editor__toolbar-button[aria-pressed="true"] {
  background-color: #dbeafe;
  color: #2563eb;
}

.dark .lexxy-editor__toolbar-button:active,
.dark .lexxy-editor__toolbar-button[aria-pressed="true"] {
  background-color: #1e3a5f;
  color: #60a5fa;
}

.lexxy-editor__toolbar-button svg {
  -webkit-touch-callout: none;
  block-size: var(--lexxy-toolbar-icon-size);
  fill: currentColor;
  grid-area: 1/1;
  inline-size: var(--lexxy-toolbar-icon-size);
  user-select: none;
}

@media (min-width: 640px) {
  .lexxy-editor__toolbar-button {
    --toolbar-button-size: 2em;
  }
}

.lexxy-editor__toolbar-overflow-menu {
  background-color: white;
  border-radius: 0.5ch;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-wrap: wrap;
  inset-inline-end: 0;
  padding: 4px;
  position: absolute;
  z-index: 2;
}

.dark .lexxy-editor__toolbar-overflow-menu {
  background-color: #1e293b;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.lexxy-editor__toolbar-spacer {
  flex: 1;
}

/* Dropdowns
 * ------------------------------------------------------------------------ */

.lexxy-editor__toolbar-dropdown-content {
  --lexxy-dropdown-padding: 0.75rem;
  --lexxy-dropdown-btn-size: 2rem;

  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5em;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  color: #374151;
  font-size: 0.875rem;
  padding: var(--lexxy-dropdown-padding);
  position: absolute;
  z-index: 2;
}

.dark .lexxy-editor__toolbar-dropdown-content {
  background-color: #1e293b;
  border-color: #4b5563;
  color: #e5e7eb;
}

.lexxy-editor__toolbar-dropdown-content button {
  block-size: var(--lexxy-dropdown-btn-size);
}

.lexxy-editor__toolbar-dropdown-actions {
  display: flex;
  font-size: 0.75rem;
  flex: 1 1 0%;
  gap: var(--lexxy-dropdown-padding);
  margin-block-start: var(--lexxy-dropdown-padding);
}

.lexxy-editor__toolbar-dropdown-actions .btn {
  border-radius: 99rem;
  inline-size: 100%;
}

.lexxy-editor__toolbar-dropdown-actions .btn[type="submit"] {
  background-color: #2563eb;
  color: white;
}

.lexxy-editor__toolbar-dropdown-actions .btn[type="submit"]:hover {
  background-color: #1d4ed8;
}

.lexxy-editor__toolbar-dropdown-actions span {
  inline-size: 100%;
}

lexxy-link-dropdown .input {
  min-inline-size: 30ch;
}

lexxy-highlight-dropdown {
  --gap: 0.5ch;
}

lexxy-highlight-dropdown [data-button-group] {
  display: flex;
  flex-direction: row;
  gap: 0.5ch;
}

lexxy-highlight-dropdown [data-button-group] + [data-button-group] {
  margin-block-start: 0.5ch;
}

@media (max-width: 639px) {
  lexxy-highlight-dropdown [data-button-group] {
    flex-wrap: wrap;
  }
}

.lexxy-highlight-button {
  appearance: none;
  background: white;
  border: none;
  border-radius: 0.5ch;
  color: inherit;
  display: grid;
  font-weight: 500;
  inline-size: 2rem;
  place-content: center;
  position: relative;
  outline: none;
}

.dark .lexxy-highlight-button {
  background: #374151;
}

.lexxy-highlight-button:after {
  content: "Aa";
}

.lexxy-highlight-button:hover,
.lexxy-highlight-button[aria-pressed="true"] {
  box-shadow: 0 0 0 1px white, 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.lexxy-highlight-button[aria-pressed="true"] {
  box-shadow: 0 0 0 1px white, 0 0 0 3px #3b82f6;
}

.lexxy-highlight-button[aria-pressed="true"]:after {
  content: "\2713";
}

.lexxy-editor__toolbar-dropdown-reset {
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 99rem;
  inline-size: 100%;
  margin-block-start: var(--lexxy-dropdown-padding);
}

.dark .lexxy-editor__toolbar-dropdown-reset {
  background: #374151;
  border-color: #4b5563;
}

.lexxy-editor__toolbar-dropdown-reset[disabled] {
  display: none;
}

/* Prompt Menu (@mentions, etc.)
 * ------------------------------------------------------------------------ */

.lexxy-prompt-menu {
  --lexxy-prompt-avatar-size: 24px;
  --lexxy-prompt-min-width: 20ch;
  --lexxy-prompt-padding: 0.5ch;

  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  color: #374151;
  font-family: inherit;
  font-size: 0.875rem;
  list-style: none;
  margin: 0;
  max-height: 200px;
  min-inline-size: var(--lexxy-prompt-min-width);
  overflow: auto;
  padding: var(--lexxy-prompt-padding);
  visibility: hidden;
  z-index: 50;
}

.dark .lexxy-prompt-menu {
  background-color: #1e293b;
  color: #e5e7eb;
}

.lexxy-prompt-menu--visible {
  visibility: initial;
}

.lexxy-prompt-menu__item {
  align-items: center;
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  gap: var(--lexxy-prompt-padding);
  padding: var(--lexxy-prompt-padding);
  white-space: nowrap;
}

.lexxy-prompt-menu__item:hover {
  background-color: #f3f4f6;
}

.dark .lexxy-prompt-menu__item:hover {
  background-color: #374151;
}

.lexxy-prompt-menu__item[aria-selected] {
  background-color: #dbeafe;
}

.dark .lexxy-prompt-menu__item[aria-selected] {
  background-color: #1e3a5f;
}

.lexxy-prompt-menu__item img {
  block-size: var(--lexxy-prompt-avatar-size);
  border-radius: 50%;
  flex-shrink: 0;
  inline-size: var(--lexxy-prompt-avatar-size);
  margin: 0;
}

.lexxy-prompt-menu__item + .lexxy-prompt-menu__item {
  margin-top: 2px;
}

.lexxy-prompt-menu__item code {
  background-color: #f3f4f6;
  border-radius: 0.25ch;
  font-size: 0.95em;
  padding-inline: 0.5ch;
}

.dark .lexxy-prompt-menu__item code {
  background-color: #374151;
}

.lexxy-prompt-menu__item--empty {
  color: #9ca3af;
  padding: var(--lexxy-prompt-padding);
}

/* Rich Text Content Display
 * ------------------------------------------------------------------------ */

.lexxy-content {
  line-height: 1.6;
  overflow-wrap: break-word;
  word-break: break-word;
}

.lexxy-content * {
  box-sizing: border-box;
}

.lexxy-content h1 {
  font-size: 1.5em;
  font-weight: 600;
  line-height: 1.3;
  margin-block: 1em 0.5em;
}

.lexxy-content h2 {
  font-size: 1.25em;
  font-weight: 600;
  line-height: 1.3;
  margin-block: 1em 0.5em;
}

.lexxy-content p {
  margin-block: 0.5em;
}

.lexxy-content blockquote {
  border: 0 solid #d1d5db;
  border-left-width: 0.3em;
  margin-left: 0.3em;
  padding-left: 0.6em;
  color: #6b7280;
}

.dark .lexxy-content blockquote {
  border-color: #4b5563;
  color: #9ca3af;
}

.lexxy-content ul,
.lexxy-content ol {
  padding-left: 1.5em;
  margin-block: 0.5em;
}

.lexxy-content li {
  margin-block: 0.25em;
}

.lexxy-content pre {
  display: block;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
  padding: 1em;
  white-space: pre;
  background-color: #f3f4f6;
  border-radius: 0.375rem;
  overflow-x: auto;
  margin-block: 0.5em;
}

.dark .lexxy-content pre {
  background-color: #1f2937;
}

.lexxy-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background-color: #f3f4f6;
  padding: 0.125em 0.25em;
  border-radius: 0.25em;
}

.dark .lexxy-content code {
  background-color: #374151;
}

.lexxy-content pre code {
  background: none;
  padding: 0;
}

.lexxy-content a {
  color: #2563eb;
  text-decoration: underline;
}

.dark .lexxy-content a {
  color: #60a5fa;
}

.lexxy-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
}

.lexxy-content .attachment {
  display: inline-block;
  position: relative;
  max-width: 100%;
}

.lexxy-content .attachment a {
  color: inherit;
  text-decoration: none;
}

.lexxy-content .attachment__caption {
  text-align: center;
  font-size: 0.875em;
  color: #6b7280;
}

.dark .lexxy-content .attachment__caption {
  color: #9ca3af;
}

.lexxy-content .attachment--file {
  color: #374151;
  line-height: 1;
  margin: 0 2px 2px 2px;
  padding: 0.4em 1em;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
}

.dark .lexxy-content .attachment--file {
  color: #e5e7eb;
  border-color: #4b5563;
}
