/* === Toolbar === */
trix-toolbar * {
  box-sizing: border-box;
}

trix-toolbar {
  display: block;
  background: #fff;
  border-top: 1px solid #d1d5db;
  border-right: 1px solid #d1d5db;
  border-left: 1px solid #d1d5db;
  border-radius: 0.5rem 0.5rem 0 0;
}

.trix-button-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  padding: 4px;
}

.trix-button-group {
  display: flex;
  gap: 4px;
}

/* === Toolbar Buttons === */
.trix-button--icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: color 150ms ease-in-out, background-color 150ms ease-in-out;
  outline: none;
  flex-shrink: 0;
}

.trix-button--icon:hover:not(:disabled) {
  color: #111827;
  background: #f9fafb;
}

.trix-button--icon.trix-active {
  background: #f3f4f6;
  color: #111827;
}

.trix-button--icon:disabled {
  opacity: 0.4;
  cursor: default;
}

.trix-button--icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.trix-button--icon::before {
  display: none;
}

/* === Separator === */
.trix-separator {
  width: 1px;
  background: #e5e7eb;
  margin-top: 4px;
  margin-bottom: 4px;
  align-self: stretch;
  flex-shrink: 0;
}

/* === Undo/Redo rechts === */
.trix-button-group--history-tools {
  margin-left: auto;
}

/* === Editor body === */
trix-editor {
  display: block;
  outline: none;
}

/* Tailwind's CSS reset strips list-style and padding from ul/ol everywhere.
   Restore them inside the editor and the rendered output. */
trix-editor ul,
.trix-content ul {
  list-style-type: disc;
  padding-left: 1.5em;
}

trix-editor ol,
.trix-content ol {
  list-style-type: decimal;
  padding-left: 1.5em;
}

trix-editor a,
.trix-content a {
  text-decoration: underline;
}

/* === Link Dialog === */
trix-toolbar .trix-dialogs {
  position: relative;
}

trix-toolbar .trix-dialog {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  font-size: 0.875em;
  padding: 12px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-top: 2px solid #374151;
  border-radius: 0 0 0.5rem 0.5rem;
  z-index: 5;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

trix-toolbar .trix-dialog--link {
  max-width: 600px;
}

trix-toolbar .trix-dialog__link-fields {
  display: flex;
  align-items: center;
  gap: 8px;
}

trix-toolbar .trix-input--dialog {
  flex: 1;
  font-size: inherit;
  padding: 6px 10px;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

trix-toolbar .trix-input--dialog.validate:invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px #ef4444;
}

trix-toolbar .trix-button--dialog {
  padding: 6px 12px;
  font-size: inherit;
  font-weight: 500;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  cursor: pointer;
}

trix-toolbar .trix-button--dialog:hover {
  background: #f9fafb;
}

/* === Dark Mode — Toolbar === */
html.dark trix-toolbar {
  background: #1f2937;
  border-color: #374151;
}

html.dark .trix-button--icon {
  color: #9ca3af;
}

html.dark .trix-button--icon:hover:not(:disabled) {
  color: #f9fafb;
  background: #374151;
}

html.dark .trix-button--icon.trix-active {
  background: #374151;
  color: #f9fafb;
}

html.dark .trix-separator {
  background: #374151;
}

html.dark trix-toolbar .trix-dialog {
  display: none;
  background: #1f2937;
  border-color: #374151;
  border-top-color: #6b7280;
  color: #f9fafb;
}

html.dark trix-toolbar .trix-input--dialog {
  background: #111827;
  border-color: #374151;
  color: #f9fafb;
}

html.dark trix-toolbar .trix-button--dialog {
  background: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

html.dark trix-toolbar .trix-button--dialog:hover {
  background: #4b5563;
}

/* === Dark Mode — Editor === */
html.dark trix-editor {
  background-color: #1f2937;
  color: #f9fafb;
  border-color: #374151;
}

html.dark trix-editor:hover {
  border-color: #6b7280;
}

html.dark trix-editor:focus {
  border-color: #f3f4f6;
  box-shadow: 0 0 0 3px rgb(75 85 99);
}

html.dark .trix-content {
  color: #f9fafb;
}

/* === Attachment styles (ActionText) === */
trix-editor [data-trix-mutable]:not(.attachment__caption-editor) {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

trix-editor [data-trix-mutable]::-moz-selection,
trix-editor [data-trix-cursor-target]::-moz-selection,
trix-editor [data-trix-mutable] ::-moz-selection {
  background: none;
}

trix-editor [data-trix-mutable]::selection,
trix-editor [data-trix-cursor-target]::selection,
trix-editor [data-trix-mutable] ::selection {
  background: none;
}

trix-editor .attachment__caption-editor:focus[data-trix-mutable]::-moz-selection {
  background: highlight;
}

trix-editor .attachment__caption-editor:focus[data-trix-mutable]::selection {
  background: highlight;
}

trix-editor [data-trix-mutable].attachment.attachment--file {
  box-shadow: 0 0 0 2px highlight;
  border-color: transparent;
}

trix-editor [data-trix-mutable].attachment img {
  box-shadow: 0 0 0 2px highlight;
}

trix-editor .attachment {
  position: relative;
}

trix-editor .attachment:hover {
  cursor: default;
}

trix-editor .attachment--preview .attachment__caption:hover {
  cursor: text;
}

trix-editor .attachment__progress {
  position: absolute;
  z-index: 1;
  height: 20px;
  top: calc(50% - 10px);
  left: 5%;
  width: 90%;
  opacity: 0.9;
  transition: opacity 200ms ease-in;
}

trix-editor .attachment__progress[value="100"] {
  opacity: 0;
}

trix-editor .attachment__caption-editor {
  display: inline-block;
  width: 100%;
  margin: 0;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  color: inherit;
  text-align: center;
  vertical-align: top;
  border: none;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

trix-editor .attachment__toolbar {
  position: absolute;
  z-index: 1;
  top: -0.9em;
  left: 0;
  width: 100%;
  text-align: center;
}

trix-editor .trix-button-group {
  display: inline-flex;
}

trix-editor .trix-button {
  position: relative;
  float: left;
  color: #666;
  white-space: nowrap;
  font-size: 80%;
  padding: 0 0.8em;
  margin: 0;
  outline: none;
  border: none;
  border-radius: 0;
  background: transparent;
}

trix-editor .trix-button:not(:first-child) {
  border-left: 1px solid #ccc;
}

trix-editor .trix-button.trix-active {
  background: #cbeefa;
}

trix-editor .trix-button:not(:disabled) {
  cursor: pointer;
}

trix-editor .trix-button--remove {
  text-indent: -9999px;
  display: inline-block;
  padding: 0;
  outline: none;
  width: 1.8em;
  height: 1.8em;
  line-height: 1.8em;
  border-radius: 50%;
  background-color: #fff;
  border: 2px solid highlight;
  box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.25);
}

trix-editor .trix-button--remove::before {
  display: inline-block;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0.7;
  content: "";
  background-image: url("data:image/svg+xml,%3Csvg%20height%3D%2224%22%20width%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M19%206.41%2017.59%205%2012%2010.59%206.41%205%205%206.41%2010.59%2012%205%2017.59%206.41%2019%2012%2013.41%2017.59%2019%2019%2017.59%2013.41%2012z%22%2F%3E%3Cpath%20d%3D%22M0%200h24v24H0z%22%20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 90%;
}

trix-editor .trix-button--remove:hover {
  border-color: #333;
}

trix-editor .trix-button--remove:hover::before {
  opacity: 1;
}

trix-editor .attachment__metadata-container {
  position: relative;
}

trix-editor .attachment__metadata {
  position: absolute;
  left: 50%;
  top: 2em;
  transform: translate(-50%, 0);
  max-width: 90%;
  padding: 0.1em 0.6em;
  font-size: 0.8em;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 3px;
}

trix-editor .attachment__metadata .attachment__name {
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

trix-editor .attachment__metadata .attachment__size {
  margin-left: 0.2em;
  white-space: nowrap;
}

/* === Content styles (.trix-content) === */
.trix-content {
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}

.trix-content * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Paragraph spacing */
.trix-content p + p {
  margin-top: 0.5rem;
}

/* Bold & italic */
.trix-content strong { font-weight: 600; }
.trix-content em     { font-style: italic; }

/* Links */
.trix-content a {
  text-decoration: underline;
  color: inherit;
}
.trix-content a:hover {
  text-decoration: none;
}

/* Headings */
.trix-content h1 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.375rem;
}

/* Blockquote */
.trix-content blockquote {
  border: 0 solid #d1d5db;
  border-left-width: 3px;
  margin-left: 0;
  padding-left: 0.75rem;
  color: #6b7280;
}

/* Code */
.trix-content pre {
  background-color: #f3f4f6;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875em;
  overflow-x: auto;
}

/* Dark Mode */
html.dark .trix-content a        { color: inherit; }
html.dark .trix-content blockquote {
  border-color: #374151;
  color: #9ca3af;
}
html.dark .trix-content pre {
  background-color: #1f2937;
  color: #f9fafb;
}

.trix-content [dir=rtl] blockquote,
.trix-content blockquote[dir=rtl] {
  border-width: 0;
  border-right-width: 0.3em;
  margin-right: 0.3em;
  padding-right: 0.6em;
}

.trix-content li {
  margin-left: 1em;
}

.trix-content [dir=rtl] li {
  margin-right: 1em;
}

.trix-content pre {
  display: inline-block;
  width: 100%;
  vertical-align: top;
  font-family: monospace;
  font-size: 0.9em;
  padding: 0.5em;
  white-space: pre;
  background-color: #eee;
  overflow-x: auto;
}

.trix-content img {
  max-width: 100%;
  height: auto;
}

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

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

.trix-content .attachment a:hover,
.trix-content .attachment a:visited:hover {
  color: inherit;
}

.trix-content .attachment__caption {
  text-align: center;
}

.trix-content .attachment__caption .attachment__name + .attachment__size::before {
  content: ' \2022 ';
}

.trix-content .attachment--preview {
  width: 100%;
  text-align: center;
}

.trix-content .attachment--preview .attachment__caption {
  color: #666;
  font-size: 0.9em;
  line-height: 1.2;
}

.trix-content .attachment--file {
  color: #333;
  line-height: 1;
  margin: 0 2px 2px 2px;
  padding: 0.4em 1em;
  border: 1px solid #bbb;
  border-radius: 5px;
}

.trix-content .attachment-gallery {
  display: flex;
  flex-wrap: wrap;
  position: relative;
}

.trix-content .attachment-gallery .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}

.trix-content .attachment-gallery.attachment-gallery--2 .attachment,
.trix-content .attachment-gallery.attachment-gallery--4 .attachment {
  flex-basis: 50%;
  max-width: 50%;
}

/*
 * Override trix.css gallery styles for <action-text-attachment> wrapper.
 */
.trix-content .attachment-gallery > action-text-attachment,
.trix-content .attachment-gallery > .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}

.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--2 > .attachment,
.trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
  flex-basis: 50%;
  max-width: 50%;
}

.trix-content action-text-attachment .attachment {
  padding: 0 !important;
  max-width: 100% !important;
}
