/*
 * Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
 * the trix-editor content (whether displayed or under editing). Feel free to incorporate this
 * inclusion directly in any other asset bundle and remove this file.
 *
 *= require trix
*/

/*
 * We need to override trix.css’s image gallery styles to accommodate the
 * <action-text-attachment> element we wrap around attachments. Otherwise,
 * images in galleries will be squished by the max-width: 33%; rule.
*/
.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;
}

/* tailwind resets list style, so add it back for actiontext */
.trix-content ul {
  list-style: disc;
  padding-left: 12px;
}

.trix-content ol {
  list-style: decimal;
  padding-left: 12px;
}

.trix-content a {
  color: #3b82f6;
  text-decoration: underline;
}

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

.trix-content strong,
.trix-content b {
  color: #111827;
}

.dark .trix-content strong,
.dark .trix-content b {
  color: #f3f4f6;
}

.trix-content h1,
.trix-content h2,
.trix-content h3,
.trix-content h4,
.trix-content h5,
.trix-content h6 {
  color: #111827;
}

.dark .trix-content h1,
.dark .trix-content h2,
.dark .trix-content h3,
.dark .trix-content h4,
.dark .trix-content h5,
.dark .trix-content h6 {
  color: #f9fafb;
}

.trix-content {
  color: #374151;
}

.dark .trix-content {
  color: #d1d5db;
}

trix-editor[placeholder]:empty:before {
  color: #9ca3af;
  content: attr(placeholder);
  pointer-events: none;
}

.dark trix-editor[placeholder]:empty:before {
  color: #6b7280;
}

trix-editor.borderless-editor,
trix-editor.borderless-editor:focus,
trix-editor.borderless-editor:active,
trix-editor.borderless-editor:hover {
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  font-size: 16px;
  line-height: 1.6;
  outline: none !important;
  margin: 0 !important;
}

trix-editor.borderless-editor[placeholder]:empty:before {
  color: #9ca3af;
  font-size: 16px;
  font-weight: normal;
}

.dark trix-editor.borderless-editor[placeholder]:empty:before {
  color: #6b7280;
}

trix-toolbar[id^="trix-toolbar-"] {
  border: none !important;
  padding: 12px 0 !important;
  margin-bottom: 16px !important;
  background: transparent !important;
  display: flex !important;
  justify-content: flex-start !important;
  gap: 0 !important;
}

.dark trix-toolbar[id^="trix-toolbar-"] {
  filter: invert(1) hue-rotate(180deg) !important;
}

trix-toolbar[id^="trix-toolbar-"] .trix-button-group {
  display: flex !important;
  margin-right: 0 !important;
  border: none !important;
  padding: 0 !important;
}

trix-toolbar[id^="trix-toolbar-"] .trix-button-group:not(:last-child) {
  border-right: none !important;
}

trix-toolbar[id^="trix-toolbar-"] .trix-button-group:not(:last-child)::after {
  display: none !important;
}

trix-toolbar[id^="trix-toolbar-"] .trix-button {
  border: none !important;
  background: transparent !important;
  padding: 6px 10px !important;
  margin: 0 !important;
  border-radius: 4px !important;
  color: #6b7280 !important;
  font-size: 14px !important;
  min-width: 28px !important;
  height: 28px !important;
}

.dark trix-toolbar[id^="trix-toolbar-"] .trix-button {
  color: #e5e7eb !important;
}

trix-toolbar[id^="trix-toolbar-"] .trix-button:hover {
  background: #f3f4f6 !important;
  color: #374151 !important;
}

.dark trix-toolbar[id^="trix-toolbar-"] .trix-button:hover {
  background: #4b5563 !important;
  color: #f9fafb !important;
}

trix-toolbar[id^="trix-toolbar-"] .trix-button.trix-active {
  background: #f3f4f6 !important;
  color: #374151 !important;
}

.dark trix-toolbar[id^="trix-toolbar-"] .trix-button.trix-active {
  background: #4b5563 !important;
  color: #f9fafb !important;
}

/* Fix Trix link dialog positioning */
.trix-dialog {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 9999 !important;
  background: white !important;
  border: 1px solid #d1d5db !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  padding: 16px !important;
  max-width: 400px !important;
  width: 90vw !important;
}

.dark .trix-dialog {
  background: #1f2937 !important;
  border-color: #374151 !important;
}

.trix-dialog__link-fields {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

.trix-dialog__link-fields .trix-input {
  padding: 8px 12px !important;
  border: 1px solid #d1d5db !important;
  border-radius: 4px !important;
  font-size: 14px !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background: white !important;
  color: #111827 !important;
}

.dark .trix-dialog__link-fields .trix-input {
  background: #374151 !important;
  border-color: #4b5563 !important;
  color: #f3f4f6 !important;
}

.trix-dialog__link-fields .trix-input:focus {
  outline: none !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

.trix-dialog .trix-button {
  background: #3b82f6 !important;
  color: white !important;
  border: none !important;
  padding: 8px 16px !important;
  border-radius: 4px !important;
  font-size: 14px !important;
  cursor: pointer !important;
  margin-top: 8px !important;
}

.trix-dialog .trix-button:hover {
  background: #2563eb !important;
}

/* Compact Trix toolbar for comments */
.trix-compact trix-toolbar[id^="trix-toolbar-"] {
  padding: 4px 0 !important;
  margin-bottom: 4px !important;
}

.trix-compact trix-toolbar[id^="trix-toolbar-"] .trix-button {
  padding: 4px 8px !important;
  min-width: 24px !important;
  height: 24px !important;
  font-size: 13px !important;
}

.trix-compact trix-toolbar[id^="trix-toolbar-"] .trix-button-group {
  margin-right: 4px !important;
}

.trix-compact trix-editor {
  margin-top: 0 !important;
}

/* Gray input box styling for comments */
trix-editor {
  background-color: #f3f4f6 !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 16px 16px 12px 16px !important;
  font-size: 15px !important;
  line-height: 1.6 !important;
  min-height: 80px !important;
  color: #6b7280 !important;
}

.dark trix-editor {
  background-color: #374151 !important;
  color: #d1d5db !important;
}

trix-editor:focus {
  outline: none !important;
  background-color: #e5e7eb !important;
  box-shadow: none !important;
}

.dark trix-editor:focus {
  background-color: #4b5563 !important;
}

trix-editor[placeholder]:empty:before {
  color: #9ca3af !important;
}

.dark trix-editor[placeholder]:empty:before {
  color: #6b7280 !important;
}

/* Comment thread connecting lines */
.comment-thread {
  position: relative;
}

.comment-thread > div {
  position: relative;
}

.comment-thread > div::before {
  content: '';
  position: absolute;
  left: -28px;
  top: -16px;
  width: 28px;
  height: 32px;
  border-left: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  border-bottom-left-radius: 12px;
}

.dark .comment-thread > div::before {
  border-color: #374151;
}

.comment-thread > div:first-child::before {
  top: -68px;
  height: 84px;
}

.comment-thread > div:not(:last-child)::after {
  content: '';
  position: absolute;
  left: -28px;
  top: 32px;
  bottom: -16px;
  width: 1px;
  background-color: #e5e7eb;
}

.dark .comment-thread > div:not(:last-child)::after {
  background-color: #374151;
}
