/*
 * Action Text content styling for Froala WYSIWYG Editor output
 * These styles apply to both the editor and displayed rich text content
 * Loaded AFTER Froala CSS to override its defaults
 */

/* ============================================
   FROALA EDITOR WRAPPER
   ============================================ */
.froala-editor-wrapper {
  margin-bottom: 0.5rem;
}

.froala-editor-container {
  border-radius: 0.375rem;
}

.fr-box.fr-basic {
  border-radius: 0.375rem;
}

.fr-box.fr-basic .fr-element.fr-view {
  min-height: 150px;
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.625;
  color: #111827;
}

.fr-box.fr-basic .fr-wrapper {
  border-radius: 0 0 0.375rem 0.375rem;
  border-color: #d1d5db;
  background: #fff;
}

.fr-box.fr-basic .fr-toolbar {
  border-radius: 0.375rem 0.375rem 0 0;
  border-color: #d1d5db;
  background: #f9fafb;
}

.fr-box.fr-basic.fr-focused .fr-wrapper {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ============================================
   HEADINGS - Tailwind Typography
   ============================================ */
.fr-view h1,
.rich-text-content h1,
div.fr-view h1 {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  color: #111827 !important;
  margin-top: 1.25rem !important;
  margin-bottom: 0.75rem !important;
}

.fr-view h2,
.rich-text-content h2,
div.fr-view h2 {
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
  color: #111827 !important;
  margin-top: 1.25rem !important;
  margin-bottom: 0.5rem !important;
}

.fr-view h3,
.rich-text-content h3,
div.fr-view h3 {
  font-size: 1.125rem !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  color: #111827 !important;
  margin-top: 1rem !important;
  margin-bottom: 0.5rem !important;
}

.fr-view h4,
.rich-text-content h4,
div.fr-view h4 {
  font-size: 1rem !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  color: #111827 !important;
  margin-top: 1rem !important;
  margin-bottom: 0.5rem !important;
}

.fr-view h5,
.fr-view h6,
.rich-text-content h5,
.rich-text-content h6,
div.fr-view h5,
div.fr-view h6 {
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  color: #374151 !important;
  margin-top: 0.75rem !important;
  margin-bottom: 0.5rem !important;
}

.fr-view > h1:first-child,
.fr-view > h2:first-child,
.fr-view > h3:first-child,
.fr-view > h4:first-child,
.rich-text-content > h1:first-child,
.rich-text-content > h2:first-child,
.rich-text-content > h3:first-child,
.rich-text-content > h4:first-child {
  margin-top: 0 !important;
}

/* ============================================
   PARAGRAPHS
   ============================================ */
.fr-view p,
.rich-text-content p,
div.fr-view p {
  margin-top: 0 !important;
  margin-bottom: 0.75rem !important;
  line-height: 1.625 !important;
}

.fr-view p:last-child,
.rich-text-content p:last-child {
  margin-bottom: 0 !important;
}

/* ============================================
   LISTS - Bullet Points
   ============================================ */
.fr-view ul,
.rich-text-content ul,
div.fr-view ul {
  list-style-type: disc !important;
  padding-left: 1.5rem !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.75rem !important;
  margin-left: 0 !important;
}

.fr-view ol,
.rich-text-content ol,
div.fr-view ol {
  list-style-type: decimal !important;
  padding-left: 1.5rem !important;
  margin-top: 0.5rem !important;
  margin-bottom: 0.75rem !important;
  margin-left: 0 !important;
}

.fr-view ul ul,
.rich-text-content ul ul {
  list-style-type: circle !important;
  margin-top: 0.25rem !important;
  margin-bottom: 0.25rem !important;
}

.fr-view ul ul ul,
.rich-text-content ul ul ul {
  list-style-type: square !important;
}

.fr-view ol ol,
.rich-text-content ol ol {
  list-style-type: lower-alpha !important;
  margin-top: 0.25rem !important;
  margin-bottom: 0.25rem !important;
}

.fr-view li,
.rich-text-content li,
div.fr-view li {
  margin-top: 0.25rem !important;
  margin-bottom: 0.25rem !important;
  padding-left: 0.25rem !important;
  line-height: 1.625 !important;
}

.fr-view li > p,
.rich-text-content li > p {
  margin-bottom: 0.25rem !important;
}

/* ============================================
   TABLES - Tailwind Style
   ============================================ */
.fr-view table,
.rich-text-content table,
div.fr-view table {
  width: 100% !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  margin-top: 0.75rem !important;
  margin-bottom: 0.75rem !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  background-color: #fff !important;
}

.fr-view table thead,
.rich-text-content table thead {
  background-color: #f9fafb !important;
}

.fr-view table thead tr,
.rich-text-content table thead tr {
  background-color: #f9fafb !important;
}

.fr-view table th,
.rich-text-content table th,
div.fr-view table th {
  padding: 0.75rem 1rem !important;
  text-align: left !important;
  font-weight: 600 !important;
  color: #374151 !important;
  border: 1px solid #e5e7eb !important;
  background-color: #f9fafb !important;
}

.fr-view table td,
.rich-text-content table td,
div.fr-view table td {
  padding: 0.75rem 1rem !important;
  text-align: left !important;
  color: #111827 !important;
  border: 1px solid #e5e7eb !important;
  vertical-align: top !important;
  background-color: #fff !important;
}

.fr-view table tbody tr:nth-child(even) td,
.rich-text-content table tbody tr:nth-child(even) td {
  background-color: #fafafa !important;
}

.fr-view table tbody tr:hover td,
.rich-text-content table tbody tr:hover td {
  background-color: #f3f4f6 !important;
}

/* Froala table selection */
.fr-view td.fr-selected-cell,
.fr-view th.fr-selected-cell {
  background-color: #dbeafe !important;
}

/* ============================================
   BLOCKQUOTES
   ============================================ */
.fr-view blockquote,
.rich-text-content blockquote,
div.fr-view blockquote {
  border-left: 4px solid #3b82f6 !important;
  padding: 0.75rem 1rem !important;
  margin: 1rem 0 !important;
  color: #4b5563 !important;
  font-style: italic !important;
  background-color: #f9fafb !important;
  border-radius: 0 0.375rem 0.375rem 0 !important;
}

.fr-view blockquote p,
.rich-text-content blockquote p {
  margin-bottom: 0 !important;
}

/* ============================================
   CODE
   ============================================ */
.fr-view pre,
.rich-text-content pre,
div.fr-view pre {
  background-color: #1f2937 !important;
  color: #f3f4f6 !important;
  padding: 1rem !important;
  border-radius: 0.5rem !important;
  overflow-x: auto !important;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  margin: 0.75rem 0 !important;
}

.fr-view code,
.rich-text-content code,
div.fr-view code {
  background-color: #f3f4f6 !important;
  color: #dc2626 !important;
  padding: 0.125rem 0.375rem !important;
  border-radius: 0.25rem !important;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace !important;
  font-size: 0.875em !important;
}

.fr-view pre code,
.rich-text-content pre code {
  background-color: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

/* ============================================
   LINKS
   ============================================ */
.fr-view a,
.rich-text-content a,
div.fr-view a {
  color: #2563eb !important;
  text-decoration: underline !important;
  text-underline-offset: 2px !important;
}

.fr-view a:hover,
.rich-text-content a:hover {
  color: #1d4ed8 !important;
}

/* ============================================
   HORIZONTAL RULE
   ============================================ */
.fr-view hr,
.rich-text-content hr,
div.fr-view hr {
  border: 0 !important;
  border-top: 1px solid #e5e7eb !important;
  margin: 1.5rem 0 !important;
}

/* ============================================
   IMAGES
   ============================================ */
.fr-view img,
.rich-text-content img,
div.fr-view img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 0.375rem !important;
}

/* ============================================
   TEXT FORMATTING
   ============================================ */
.fr-view strong,
.fr-view b,
.rich-text-content strong,
.rich-text-content b {
  font-weight: 600 !important;
}

.fr-view em,
.fr-view i,
.rich-text-content em,
.rich-text-content i {
  font-style: italic !important;
}

/* ============================================
   RICH TEXT CONTENT DISPLAY
   ============================================ */
.rich-text-content {
  line-height: 1.625;
  color: #111827;
}

.rich-text-content > *:first-child {
  margin-top: 0 !important;
}

.rich-text-content > *:last-child {
  margin-bottom: 0 !important;
}

/* ============================================
   ATTACHMENTS - Active Storage
   ============================================ */
.rich-text-content .attachment {
  display: inline-block;
  max-width: 100%;
}

.rich-text-content .attachment--preview {
  text-align: center;
}

.rich-text-content .attachment--file {
  padding: 0.5rem 1rem;
  background-color: #f3f4f6;
  border-radius: 0.375rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.rich-text-content .attachment__caption {
  text-align: center;
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

.rich-text-content .attachment-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rich-text-content .attachment-gallery .attachment {
  flex: 1 1 calc(50% - 0.25rem);
  max-width: calc(50% - 0.25rem);
}
