/* ==========================================================================
   Trix editor overrides — compact, dark mode, Planner design tokens
   ========================================================================== */

/* --- Tailwind preflight fix: restore typography inside .trix-content --- */
.trix-content h1 { font-size: 1.25em; font-weight: 700; margin: 0.4em 0; }
.trix-content h2 { font-size: 1.125em; font-weight: 600; margin: 0.4em 0; }
.trix-content h3 { font-size: 1em; font-weight: 600; margin: 0.3em 0; }
.trix-content strong { font-weight: 700; }
.trix-content em { font-style: italic; }
.trix-content u { text-decoration: underline; }
.trix-content del, .trix-content s { text-decoration: line-through; }
.trix-content ul { list-style: disc; padding-left: 1.25em; margin: 0.3em 0; }
.trix-content ol { list-style: decimal; padding-left: 1.25em; margin: 0.3em 0; }
.trix-content li { margin: 0.15em 0; }
.trix-content blockquote {
  border-left: 2px solid #5d5b56;
  padding-left: 0.625em;
  margin: 0.4em 0;
  color: #a5a29d;
}
.trix-content pre {
  background: #2a2826;
  color: #eeedeb;
  padding: 0.5em 0.75em;
  border-radius: 0.375rem;
  overflow-x: auto;
  margin: 0.4em 0;
  font-size: 0.8125rem;
  line-height: 1.5;
}
.trix-content code {
  background: rgba(107, 114, 128, 0.15);
  padding: 0.1em 0.3em;
  border-radius: 0.25rem;
  font-size: 0.8125rem;
}
.trix-content pre code { background: none; padding: 0; }
.trix-content a { color: #e8644b; text-decoration: underline; }
.trix-content a:hover { color: #cc4d35; }

/* --- Dark mode typography --- */
.dark .trix-content blockquote { border-left-color: #5d5b56; color: #7a7772; }
.dark .trix-content code { background: rgba(156, 163, 175, 0.15); }
.dark .trix-content a { color: #ff7a5c; }
.dark .trix-content a:hover { color: #ffa085; }

/* --- Bottom toolbar layout --- */
.trix-container--bottom-toolbar {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
.trix-container--bottom-toolbar > trix-toolbar {
  order: 1;
}
.trix-container--bottom-toolbar > trix-editor {
  order: 0;
}

/* --- Editor styles --- */
trix-editor {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  min-height: 60px;
  outline: none !important;
  box-shadow: none !important;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: #413f3b;
}

trix-editor:empty::before {
  color: #a5a29d;
  font-size: 0.8125rem;
}

.dark trix-editor { color: #cccac6; }
.dark trix-editor:empty::before { color: #5d5b56; }

/* --- Toolbar: compact, icon-scaled, TailAdmin colors --- */
trix-toolbar {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
}

trix-toolbar .trix-button-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  border: none !important;
  background: transparent !important;
  justify-content: center;
  overflow-x: auto;
}

trix-toolbar .trix-button-group {
  border: none !important;
  background: transparent !important;
  margin: 0 !important;
  display: flex;
  gap: 0;
  position: relative;
}

/* Subtle separator between groups */
trix-toolbar .trix-button-group + .trix-button-group::before {
  content: "";
  display: block;
  width: 1px;
  margin: 4px 2px;
  background: #e0dfdc;
  align-self: stretch;
}
.dark trix-toolbar .trix-button-group + .trix-button-group::before {
  background: #413f3b;
}

trix-toolbar .trix-button {
  border: none !important;
  background: transparent !important;
  color: #6b7280;
  border-radius: 0.25rem;
  padding: 0 !important;
  width: 1.625rem !important;
  height: 1.625rem !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 100ms ease-out, color 100ms ease-out;
  cursor: pointer;
}

/* Scale down the built-in SVG background-image icons */
trix-toolbar .trix-button::before {
  transform: scale(0.7) !important;
  transform-origin: center;
  opacity: 0.45;
  transition: opacity 100ms ease-out;
}

trix-toolbar .trix-button:hover {
  background: rgba(107, 114, 128, 0.1) !important;
}
trix-toolbar .trix-button:hover::before { opacity: 0.75; }

trix-toolbar .trix-button.trix-active {
  background: rgba(232, 100, 75, 0.1) !important;
}
trix-toolbar .trix-button.trix-active::before { opacity: 0.9; }

/* Dark mode: invert the black SVG icons to white, then lower brightness */
.dark trix-toolbar .trix-button::before {
  filter: invert(1);
  opacity: 0.4;
}
.dark trix-toolbar .trix-button:hover {
  background: rgba(156, 163, 175, 0.12) !important;
}
.dark trix-toolbar .trix-button:hover::before { opacity: 0.75; }

.dark trix-toolbar .trix-button.trix-active {
  background: rgba(255, 122, 92, 0.15) !important;
}
.dark trix-toolbar .trix-button.trix-active::before {
  filter: invert(0.6) sepia(1) saturate(5) hue-rotate(340deg);
  opacity: 0.9;
}

/* --- Hide file & heading-1 buttons (keep heading as h2 only) --- */
trix-toolbar .trix-button-group--file-tools { display: none !important; }

/* --- Toolbar pinned at bottom with subtle separator --- */
.trix-container--bottom-toolbar > trix-toolbar {
  border-top: 1px solid #e0dfdc;
  padding-top: 0.25rem !important;
  margin-top: auto !important;
}

.dark .trix-container--bottom-toolbar trix-toolbar {
  border-top-color: #413f3b;
}

/* --- Dialogs (link input etc.) --- */
trix-toolbar .trix-dialog {
  background: #f7f6f4;
  border: 1px solid #e0dfdc;
  border-radius: 0.5rem;
  padding: 0.375rem 0.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  font-size: 0.8125rem;
}

trix-toolbar .trix-dialog input[type="url"],
trix-toolbar .trix-dialog input[type="text"] {
  border: 1px solid #cccac6;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  outline: none;
}

trix-toolbar .trix-dialog input:focus {
  border-color: #e8644b;
  box-shadow: 0 0 0 2px rgba(232, 100, 75, 0.15);
}

trix-toolbar .trix-dialog .trix-button-group {
  gap: 0.25rem;
}

trix-toolbar .trix-dialog .trix-button-group .trix-button {
  width: auto !important;
  height: auto !important;
  padding: 0.125rem 0.5rem !important;
  font-size: 0.75rem;
  border-radius: 0.25rem;
}

.dark trix-toolbar .trix-dialog {
  background: #2a2826;
  border-color: #413f3b;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

.dark trix-toolbar .trix-dialog input[type="url"],
.dark trix-toolbar .trix-dialog input[type="text"] {
  background: #1a1917;
  border-color: #5d5b56;
  color: #eeedeb;
}

.dark trix-toolbar .trix-dialog input:focus {
  border-color: #ff7a5c;
  box-shadow: 0 0 0 2px rgba(255, 122, 92, 0.2);
}

.dark trix-toolbar .trix-dialog .trix-button-group .trix-button {
  color: #cccac6;
}
.dark trix-toolbar .trix-dialog .trix-button-group .trix-button::before {
  filter: invert(1);
}

/* --- Form input integration (modal form) --- */
trix-editor.form-input {
  min-height: 72px;
}
