/* Minimal, unopinionated base styles. Override freely in the host app. */
.cms-editor { border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; }
.cms-editor__toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid #e5e7eb; background: #f9fafb; }
.cms-editor__btn { padding: 4px 8px; font-size: 13px; border: 1px solid transparent; border-radius: 4px; background: transparent; cursor: pointer; color: inherit; }
.cms-editor__btn:hover { background: #eef2f7; }
.cms-editor__btn.is-active { background: #e0e7ff; border-color: #c7d2fe; }
/* Icon toolbar buttons: square, centred glyph (the imagebar keeps text labels). */
.cms-editor__toolbar .cms-editor__btn { display: inline-flex; align-items: center; justify-content: center; padding: 6px; min-width: 32px; }
.cms-editor__btn svg { display: block; width: 18px; height: 18px; }
.cms-editor__sep { width: 1px; align-self: stretch; margin: 4px 4px; background: #e5e7eb; }
.cms-editor__surface { min-height: 280px; padding: 16px; line-height: 1.6; }
/* Own the focus appearance so a host app's global focus ring/border on
   contenteditable doesn't leak onto the editing surface. */
.cms-editor__surface:focus,
.cms-editor__surface:focus-visible { outline: none; box-shadow: none; border-color: transparent; }
.cms-editor__surface img { max-width: 100%; height: auto; }

/* Image-properties panel (ADR-004) */
[x-cloak] { display: none !important; }
.cms-editor__imagebar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid #e5e7eb; background: #eef2ff; font-size: 13px; }
.cms-editor__imagebar-label { font-weight: 600; color: #4338ca; margin-right: 4px; }
.cms-editor__field { display: inline-flex; align-items: center; gap: 4px; color: #374151; }
.cms-editor__field input { width: 72px; padding: 3px 6px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 13px; }
.cms-editor__field--grow { flex: 1; min-width: 160px; }
.cms-editor__field--grow input { width: 100%; }

/* Alignment classes — applied to inserted images, usable on the front-end too */
.alignleft { float: left; margin: 0 16px 12px 0; }
.alignright { float: right; margin: 0 0 12px 16px; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }

.cms-editor__modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.cms-editor__modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.cms-editor__modal-body { position: relative; width: min(900px, 92vw); max-height: 86vh; overflow: auto; background: #fff; border-radius: 10px; }

.cms-picker { padding: 16px; }
.cms-picker__header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cms-picker__title { font-size: 16px; font-weight: 600; margin: 0; }
.cms-picker__search { flex: 1; padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; }
.cms-picker__upload { display: inline-flex; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 12px; border: 1px dashed #9ca3af; border-radius: 6px; cursor: pointer; }
.cms-picker__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.cms-picker__item { padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; cursor: pointer; background: none; }
.cms-picker__item:hover { border-color: #6366f1; }
.cms-picker__item img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.cms-picker__empty { color: #6b7280; grid-column: 1 / -1; padding: 24px; text-align: center; }
.cms-picker__error { color: #b91c1c; font-size: 13px; }

/* Dark mode — scoped to a `.dark` ancestor (Tailwind class / Flux strategy).
   Apps that key dark mode off prefers-color-scheme can re-map these in their
   own CSS; the package stays unopinionated about the toggle mechanism. */
.dark .cms-editor { border-color: #3f3f46; color: #e4e4e7; }
.dark .cms-editor__toolbar { border-bottom-color: #3f3f46; background: #18181b; }
.dark .cms-editor__btn { color: #e4e4e7; }
.dark .cms-editor__btn:hover { background: #27272a; }
.dark .cms-editor__btn.is-active { background: rgba(99, 102, 241, .25); border-color: #4f46e5; }
.dark .cms-editor__sep { background: #3f3f46; }
.dark .cms-editor__surface { color: #e4e4e7; }

.dark .cms-editor__imagebar { border-bottom-color: #3f3f46; background: rgba(79, 70, 229, .15); }
.dark .cms-editor__imagebar-label { color: #a5b4fc; }
.dark .cms-editor__field { color: #d4d4d8; }
.dark .cms-editor__field input { background: #18181b; border-color: #3f3f46; color: #e4e4e7; }

.dark .cms-editor__modal-body { background: #18181b; color: #e4e4e7; }
.dark .cms-picker__search { background: #18181b; border-color: #3f3f46; color: #e4e4e7; }
.dark .cms-picker__upload { border-color: #52525b; color: #d4d4d8; }
.dark .cms-picker__item:hover { border-color: #6366f1; }
.dark .cms-picker__empty { color: #a1a1aa; }
