/* Trix Toolbar Styles */
trix-toolbar {
  background-color: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  border-top: none;
  border-left: none;
  border-right: none;
  padding: 0.5rem;
  border-radius: 0;
  position: relative;
}

trix-toolbar .trix-button-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  justify-content: flex-start;
}

trix-toolbar .trix-button-row [data-trix-send-button] {
  margin-left: auto;
}

trix-toolbar .trix-button-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
}

trix-toolbar .trix-button-group-spacer {
  flex: 1;
}

/* Hide default Trix link dialog */
trix-toolbar .trix-dialog--link {
  display: none !important;
}

trix-toolbar .trix-dialog {
  display: none !important;
}

trix-toolbar .trix-button {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  border: none;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

trix-toolbar .trix-button:hover {
  background-color: #e5e7eb;
  color: #1f2937;
}

trix-toolbar .trix-button:active {
  background-color: #d1d5db;
}

trix-toolbar .trix-button.trix-active {
  background-color: #e5e7eb;
  color: #1f2937;
}

trix-toolbar .trix-button svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Hide default Trix icons */
trix-toolbar .trix-button::before {
  display: none;
}

/* Trix Editor Styles */
trix-editor {
  min-height: 8rem;
  max-height: 32rem;
  padding: 0.5rem;
  border: 2px solid transparent;
  overflow-y: auto;
  overflow-x: hidden;
}

trix-editor:focus {
  border: 2px solid #14b8a6;
  outline: none;
}

/* List styles for Trix editor */
trix-editor ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

trix-editor ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

trix-editor li {
  margin-bottom: 0.25rem;
}

trix-editor ul ul {
  list-style-type: circle;
}

trix-editor ul ul ul {
  list-style-type: square;
}

trix-editor ol ol {
  list-style-type: lower-alpha;
}

trix-editor ol ol ol {
  list-style-type: lower-roman;
}

/* List styles for rendered Trix content */
.trix-content ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.trix-content ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.trix-content li {
  margin-bottom: 0.25rem;
}

.trix-content ul ul {
  list-style-type: circle;
}

.trix-content ul ul ul {
  list-style-type: square;
}

.trix-content ol ol {
  list-style-type: lower-alpha;
}

.trix-content ol ol ol {
  list-style-type: lower-roman;
}

.trix-content pre {
  background-color: #fff;
  padding: 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid #e2e8f0;
}

/* Link styles for Trix editor */
trix-editor a {
  color: #14b8a6;
  text-decoration: underline;
  text-decoration-color: #14b8a6;
}

trix-editor a:hover {
  color: #0d9488;
  text-decoration-color: #0d9488;
}

/* Link styles for rendered Trix content */
.trix-content a {
  color: #14b8a6;
  text-decoration: underline;
  text-decoration-color: #14b8a6;
}

.trix-content a:hover {
  color: #0d9488;
  text-decoration-color: #0d9488;
}

/* Trix attachment chip styles - override Trix's default attachment styles */
/* Target Trix's actual classes: figure.attachment.attachment--file */
/* Note: Image previews (.attachment--preview) are handled separately below */
/* Only apply to non-preview attachments (files, PDFs, etc.) */
trix-editor figure.attachment.attachment--file,
trix-editor figure.attachment.attachment--pdf,
trix-editor figure.attachment[data-trix-attachment]:not(.attachment--preview) {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  background-color: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 0.5rem !important;
  padding: 0.15rem 0.75rem !important;
  margin: 0.25rem 0.125rem !important;
  vertical-align: middle !important;
  user-select: none !important;
  position: relative !important;
  max-width: none !important;
  width: auto !important;
}

/* Show image preview in Trix editor */
trix-editor figure.attachment.attachment--preview img {
  display: block !important;
  max-width: 200px !important;
  height: auto !important;
  border-radius: 0.5rem;
}

/* Hide figcaption (filename and icon) for image previews in editor */
trix-editor
  figure.attachment.attachment--preview
  figcaption.attachment__caption {
  display: none !important;
}

/* Limit image width in Trix editor */
trix-editor img {
  max-width: 200px !important;
  height: auto !important;
}

/* Limit figure width in Trix editor to prevent layout breaking */
trix-editor figure.attachment.attachment--preview {
  max-width: 200px !important;
  display: block !important;
  margin: 0.5rem 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

/* Style links in attachment chips (but not image previews) */
trix-editor figure.attachment:not(.attachment--preview) > a {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  text-decoration: none !important;
  color: #111827 !important;
  cursor: pointer !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: transparent !important;
}

trix-editor figure.attachment:not(.attachment--preview) > a:hover {
  text-decoration: none !important;
  color: #111827 !important;
  background: transparent !important;
}

/* Style figcaption for file attachments (but not image previews) */
trix-editor
  figure.attachment:not(.attachment--preview)
  figcaption.attachment__caption {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.5rem !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

/* Add file icon at the start using ::before (but not for image previews) */
trix-editor
  figure.attachment:not(.attachment--preview)
  figcaption.attachment__caption::before {
  content: "";
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z'/%3E%3Cpath d='M14 2v4a2 2 0 0 0 2 2h4'/%3E%3Cpath d='M10 9H8'/%3E%3Cpath d='M16 13H8'/%3E%3Cpath d='M16 17H8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  display: inline-block;
}

trix-editor figure.attachment .attachment__name {
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  color: #111827 !important;
  white-space: nowrap !important;
  max-width: 200px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  text-decoration: none !important;
}

trix-editor figure.attachment .attachment__size {
  display: none !important;
}

trix-editor figure.attachment .attachment__toolbar {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

trix-editor figure.attachment .attachment-delete {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 18px !important;
  height: 18px !important;
  padding: 0 !important;
  margin: 0 !important;
  margin-left: 0.25rem !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0.25rem !important;
  color: #6b7280 !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
}

trix-editor figure.attachment .attachment-delete:hover {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
}

/* Attachment chip styles in rendered content */
.trix-content figure.attachment,
.trix-content figure.attachment.attachment--file,
.trix-content figure.attachment.attachment--pdf {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.15rem 0.75rem;
  margin: 0.25rem 0.125rem;
  vertical-align: middle;
  user-select: none;
}

.trix-content figure.attachment:hover {
  background-color: #f9fafb;
  border-color: #d1d5db;
}

.trix-content figure.attachment > a {
  text-decoration: none;
  color: #111827;
}

.trix-content figure.attachment .attachment__size {
  display: none;
}

.trix-content figure.attachment .attachment__toolbar {
  display: none;
}

/* Add file icon at the start using ::before for rendered content */
.trix-content figure.attachment figcaption.attachment__caption::before {
  content: "";
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z'/%3E%3Cpath d='M14 2v4a2 2 0 0 0 2 2h4'/%3E%3Cpath d='M10 9H8'/%3E%3Cpath d='M16 13H8'/%3E%3Cpath d='M16 17H8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  display: inline-block;
}

.trix-content figure.attachment figcaption.attachment__caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.trix-content figure.attachment .attachment__name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trix-content figure.attachment .attachment-delete {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  margin-left: 0.25rem;
  background: transparent;
  border: none;
  border-radius: 0.25rem;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.trix-content figure.attachment .attachment-delete:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.trix-content figure.attachment .attachment-delete svg {
  width: 14px;
  height: 14px;
}

/* Image attachment styles in rendered content */
.trix-content figure.attachment.attachment--preview {
  display: block;
  margin: 0.5rem 0;
  padding: 0;
  border: none;
  background: transparent;
  max-width: 400px;
}

.trix-content figure.attachment.attachment--preview:hover {
  background: transparent;
  border: none;
}

.trix-content figure.attachment.attachment--preview .attachment__preview-image {
  max-width: 400px;
  height: auto;
  border-radius: 0.5rem;
  display: block;
  margin: 0;
}

/* Hide fallback badge in rendered content - show image instead */
.trix-content figure.attachment.attachment--preview .attachment__fallback {
  display: none;
}
