/**
 * Self-hosted styles for the nitrogen/editor BlockEditor field.
 *
 * Shipped as a Filament CSS asset (see EditorServiceProvider) so the field is
 * self-contained and does NOT depend on the consuming app compiling arbitrary
 * Tailwind utilities from this package's blade views — those utilities are not
 * in a downstream app's Tailwind `content` scan, so a hand-rolled Tailwind
 * overlay (fixed/inset-0/z-50/…) silently renders inline instead of floating.
 * Dark mode follows Filament's `.dark` root class.
 *
 * Everything is namespaced (`ne-…`, `ce-block--custom…`) to avoid clashing with
 * the host app or editor.js core.
 */

/* ----------------------------------------------------------------------------
 * Block config modal (overlay dialog)
 * ------------------------------------------------------------------------- */
.ne-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow-y: auto;
}

.ne-modal__backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(17, 24, 39, 0.75);
    transition: opacity 0.2s ease;
}

.ne-modal__wrap {
    position: relative;
    display: flex;
    min-height: 100%;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: left;
}

.ne-modal__panel {
    position: relative;
    width: 100%;
    max-width: 42rem;
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}
.dark .ne-modal__panel {
    background-color: #1f2937; /* gray-800 */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

.ne-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb; /* gray-200 */
}
.dark .ne-modal__header {
    border-bottom-color: #374151; /* gray-700 */
}

.ne-modal__heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.ne-modal__title {
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 600;
    color: #111827; /* gray-900 */
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dark .ne-modal__title {
    color: #ffffff;
}

.ne-modal__icon {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    color: var(--primary-500, #6366f1);
}

.ne-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: #9ca3af; /* gray-400 */
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.ne-modal__close:hover {
    background-color: #f3f4f6; /* gray-100 */
    color: #6b7280; /* gray-500 */
}
.dark .ne-modal__close:hover {
    background-color: #374151; /* gray-700 */
}
.ne-modal__close svg {
    width: 1.25rem;
    height: 1.25rem;
}

.ne-modal__body {
    padding: 1rem 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.ne-modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb; /* gray-200 */
    background-color: #f9fafb; /* gray-50 */
}
.dark .ne-modal__footer {
    border-top-color: #374151; /* gray-700 */
    background-color: rgba(31, 41, 55, 0.5);
}

/* ----------------------------------------------------------------------------
 * Modal buttons
 * ------------------------------------------------------------------------- */
.ne-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.25rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ne-btn svg {
    width: 1rem;
    height: 1rem;
}
.ne-btn--secondary {
    border: 1px solid #d1d5db; /* gray-300 */
    background-color: #ffffff;
    color: #374151; /* gray-700 */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.ne-btn--secondary:hover {
    background-color: #f9fafb; /* gray-50 */
}
.dark .ne-btn--secondary {
    border-color: #4b5563; /* gray-600 */
    background-color: transparent;
    color: #d1d5db; /* gray-300 */
}
.dark .ne-btn--secondary:hover {
    background-color: #374151; /* gray-700 */
}
.ne-btn--primary {
    border: 1px solid transparent;
    background-color: var(--primary-600, #4f46e5);
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.ne-btn--primary:hover {
    background-color: var(--primary-500, #6366f1);
}

/* ----------------------------------------------------------------------------
 * Block toolbar position — pin the +/tune menu to the RIGHT in every context
 *
 * WHY: editor.js auto-orients the block toolbar (the "+" insert button and the
 * tune/"settings" button, grouped in `.ce-toolbar__actions`) based on the
 * inherited text `direction` and available horizontal space around the block.
 * Its runtime-injected stylesheet places `.ce-toolbar__actions` at the LEFT of
 * the centered `.ce-toolbar__content` column by default (`right: 100%`), and
 * flips it under RTL / narrow-mode. In our app the NEWS editor inherited a
 * config/CSS combination that rendered the menu on the LEFT, while content
 * pages rendered it on the RIGHT — the same field, two different results.
 *
 * We unify it to the RIGHT for ALL host contexts by pinning `.ce-toolbar__
 * actions` to the right edge and neutralising the `--left-oriented` /
 * `--right-oriented` variants of both buttons so they can never flip.
 *
 * Everything is scoped under our own `.block-editor` wrapper so it can never
 * leak into an unrelated editor.js instance living in the host app.
 *
 * `!important` is used ONLY on properties that must beat editor.js's own
 * runtime-injected inline stylesheet (`.ce-toolbar__actions{right:100%}` and
 * its RTL `left`/`right` overrides carry equal or higher specificity once
 * combined with `.codex-editor`). The `.block-editor ` prefix already raises
 * our specificity above the bare `.ce-toolbar__actions` rule, but the RTL
 * variant (`.codex-editor.codex-editor--rtl .ce-toolbar__actions`) matches with
 * two classes, so we need `!important` to win deterministically in every mode.
 * ------------------------------------------------------------------------- */
.block-editor .ce-toolbar__actions {
    /* Sit at the right edge of the centered toolbar content column, not left.
       Overrides editor.js `right: 100%` (LTR default) and its RTL `left`. */
    right: 0 !important;
    left: auto !important;
    /* Match editor.js's own right-gutter padding without a left one. */
    padding-right: 0;
    padding-left: 5px;
    margin-left: auto;
    margin-right: 0;
}

/* Neutralise the auto-orientation: make the left/right variants identical so
   the popover arrow (the `:before` pseudo, the only thing these modifiers move)
   always points from the right edge, regardless of which one editor.js picks. */
.block-editor .ce-toolbar__plus--left-oriented::before,
.block-editor .ce-toolbar__plus--right-oriented::before,
.block-editor .ce-toolbar__settings-btn--left-oriented::before,
.block-editor .ce-toolbar__settings-btn--right-oriented::before {
    left: auto;
    right: 15px;
    margin-left: 0;
}

/* ----------------------------------------------------------------------------
 * Generic (fallback) custom-block preview inside the editor holder
 * ------------------------------------------------------------------------- */
.ce-block--custom {
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background-color: #f9fafb; /* gray-50 */
}
.dark .ce-block--custom {
    border-color: #374151; /* gray-700 */
    background-color: rgba(31, 41, 55, 0.4);
}
.ce-block--custom__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.ce-block--custom__label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151; /* gray-700 */
}
.dark .ce-block--custom__label {
    color: #d1d5db; /* gray-300 */
}
.ce-block--custom__content {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280; /* gray-500 */
}
.dark .ce-block--custom__content {
    color: #9ca3af; /* gray-400 */
}

/* ----------------------------------------------------------------------------
 * Heading block (editor.js `header` tool)
 *
 * The host's Tailwind preflight resets h1–h6 to body size, so without these the
 * saved heading looked like a paragraph in the editor (NP2-41). Sizes come from
 * the hub type scale (--n3-fs-*); the fallbacks are the same values.
 * ------------------------------------------------------------------------- */
.codex-editor .ce-header {
    font-weight: 600;
    line-height: 1.3;
    padding: 4px 0;
    margin: 12px 0 4px;
}
.codex-editor h1.ce-header,
.codex-editor h2.ce-header {
    font-size: var(--n3-fs-5, 18px);
}
.codex-editor h3.ce-header {
    font-size: var(--n3-fs-4, 15px);
}
.codex-editor h4.ce-header,
.codex-editor h5.ce-header,
.codex-editor h6.ce-header {
    font-size: var(--n3-fs-3, 13.5px);
}
