/* Universal Rich Text (WYSIWYG) Editor Styles */
.rte-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background-color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  margin-bottom: 0.75rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.rte-wrapper:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background-color: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
  user-select: none;
}

.rte-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  border-right: 1px solid #e5e7eb;
  padding-right: 0.375rem;
  margin-right: 0.25rem;
}

.rte-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;
  height: 1.875rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  background: transparent;
  color: #4b5563;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
}

.rte-btn:hover {
  background-color: #e5e7eb;
  color: #111827;
}

.rte-btn.active {
  background-color: #e0e7ff;
  color: #4338ca;
  font-weight: 600;
}

.rte-select {
  height: 1.875rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  background-color: #ffffff;
  cursor: pointer;
}

.rte-select:focus {
  outline: none;
  border-color: #6366f1;
}

.rte-content {
  min-height: 140px;
  max-height: 600px;
  padding: 0.75rem 1rem;
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #1f2937;
  outline: none;
}

.rte-content:empty:before {
  content: attr(placeholder);
  color: #9ca3af;
  pointer-events: none;
  display: block;
}

/* Shared rich-text body styles: the editor (.rte-content) and every public/read-only
   place that renders stored HTML (.rich-body) use the same rules, so what an admin
   sees while editing matches what members and readers see. Tailwind preflight strips
   list markers and heading sizes, so these rules set them explicitly. */
.rte-content p,
.rich-body p {
  margin: 0.5em 0;
}

.rte-content p:last-child {
  margin-bottom: 0;
}

.rte-content h1,
.rich-body h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0.5em 0;
}

.rte-content h2,
.rich-body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.5em 0;
}

.rte-content h3,
.rich-body h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0.5em 0;
}

.rte-content h4,
.rich-body h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0.5em 0;
}

.rte-content ul,
.rich-body ul {
  list-style-type: disc;
  list-style-position: outside;
  padding-left: 1.5rem;
  margin: 0.5em 0;
}

.rte-content ol,
.rich-body ol {
  list-style-type: decimal;
  list-style-position: outside;
  padding-left: 1.5rem;
  margin: 0.5em 0;
}

.rte-content ul ul,
.rich-body ul ul {
  list-style-type: circle;
}

.rte-content ol ol,
.rich-body ol ol {
  list-style-type: lower-alpha;
}

.rte-content li,
.rich-body li {
  margin: 0.15em 0;
}

.rte-content blockquote,
.rich-body blockquote {
  border-left: 3px solid #6366f1;
  padding-left: 0.75rem;
  color: #4b5563;
  font-style: italic;
  margin: 0.5rem 0;
}

.rte-content a,
.rich-body a {
  color: #2563eb;
  text-decoration: underline;
}

.rte-content hr,
.rich-body hr {
  border: 0;
  border-top: 1px solid #d1d5db;
  margin: 0.75em 0;
}

.rte-content table,
.rich-body table {
  border-collapse: collapse;
  margin: 0.5em 0;
}

.rte-content th,
.rte-content td,
.rich-body th,
.rich-body td {
  border: 1px solid #d1d5db;
  padding: 0.25rem 0.5rem;
  vertical-align: top;
}

.rte-content th,
.rich-body th {
  font-weight: 600;
}

.rte-color-picker {
  position: relative;
  display: inline-flex;
}

.rte-color-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.25rem;
  padding: 0.375rem;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  margin-top: 0.25rem;
}

.rte-color-swatch {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.2rem;
  border: 1px solid #d1d5db;
  cursor: pointer;
}

.rte-color-swatch:hover {
  transform: scale(1.1);
}

.rte-mode-code .rte-content {
  display: none !important;
}

.rte-mode-code .rte-raw-textarea {
  display: block !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 0 0 0.5rem 0.5rem;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  background-color: #f8fafc;
  color: #0f172a;
}
