/* ============================================================
   FxRichText — block-based document editor / viewer
   ============================================================ */

/* Applied to the outer NxLayout when IsReadOnly=true — override here as needed */
.fx-richtext--readonly {
    background:inherit;
}   

.fx-richtext-root {
    display: flex;
    flex-direction: column;
    border: var(--nx-border-width) solid var(--nx-border-color);
    border-radius: var(--nx-border-radius);
    background: var(--nx-tertiary-bg);
    padding: var(--nx-space-small);
    gap: var(--nx-space-small);
}

.fx-richtext-header {

    font-family: var(--nx-font);
    font-size: 0.85rem;

}

.fx-richtext-readonly {
      display: flex;
      flex-direction: column;
      gap: var(--nx-space-small);
      color: var(--nx-primary-fg);
      font-family: var(--nx-font);
      line-height: 1.4;
  }

  .fx-richtext-readonly .fx-richtext-p {
      white-space: pre-wrap;
  }

/* ---------------- Block list (editor) ---------------- */

.fx-richtext-blocks {
    display: flex;
    flex-direction: column;
    gap: var(--nx-space-small);
}

.fx-richtext-block {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: var(--nx-space-small);
    padding: 4px;
    border: var(--nx-border-width) dashed transparent;
    border-radius: var(--nx-border-radius);
    transition: border-color 120ms ease, background 120ms ease;
}

    .fx-richtext-block:hover {
        border-color: var(--nx-border-color);
    }

    .fx-richtext-block.drop-target {
        border-color: var(--nx-highlight-fg);
        background: var(--nx-highlight-bg);
    }

.fx-richtext-handle,
.fx-richtext-delete {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--nx-muted-fg);
    padding: 4px;
    border-radius: var(--nx-border-radius);
    opacity: 0;
    transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
    line-height: 1;
}

.fx-richtext-handle {
    cursor: grab;
}

    .fx-richtext-handle:active {
        cursor: grabbing;
    }

.fx-richtext-block:hover .fx-richtext-handle,
.fx-richtext-block:hover .fx-richtext-delete {
    opacity: 1;
}

.fx-richtext-handle:hover {
    color: var(--nx-primary-fg);
    background: var(--nx-secondary-bg);
}

.fx-richtext-delete:hover {
    color: var(--nx-negative-fg);
    background: var(--nx-negative-bg);
}

.fx-richtext-block-body {
    min-width: 0;
    width: 100%;
}

/* ---------------- Inputs ---------------- */

.fx-richtext-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border: var(--nx-border-width) solid transparent;
    border-radius: var(--nx-border-radius);
    padding: 4px 8px;
    color: var(--nx-primary-fg);
    font-family: var(--nx-font);
    outline: none;
    resize: vertical;
}

    .fx-richtext-input:hover {
        border-color: var(--nx-border-color);
    }

    .fx-richtext-input:focus {
        border-color: var(--nx-highlight-fg);
        background: var(--nx-tertiary-bg);
    }

.fx-richtext-p {
    font-size: 1rem;
    line-height: 1.4;
    min-height: 2.4em;
}

.fx-richtext-h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.fx-richtext-h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* ---------------- Add block toolbar ---------------- */

.fx-richtext-add {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: var(--nx-space-small);
    margin-top: var(--nx-space-small);
    padding-bottom: 2px;
}

.fx-richtext-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 10px;
    background: var(--nx-secondary-bg);
    border: var(--nx-border-width) solid var(--nx-border-color);
    border-radius: var(--nx-border-radius);
    color: var(--nx-secondary-fg);
    font-family: var(--nx-font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

    .fx-richtext-add-btn:hover {
        color: var(--nx-highlight-fg);
        border-color: var(--nx-highlight-fg);
        background: var(--nx-highlight-bg);
    }

/* ---------------- Attachment block ---------------- */

.fx-richtext-image {
    display: inline-block;
    max-width: min(240px, 100%);
    padding: 4px;
    background: var(--nx-tertiary-bg);
    border: var(--nx-border-width) solid var(--nx-border-color);
    border-radius: var(--nx-border-radius);
    box-shadow: var(--nx-box-shadow);
    cursor: zoom-in;
    overflow: hidden;
    vertical-align: top;
    line-height: 0;
    transition: transform 120ms ease, border-color 120ms ease;
    text-decoration: none;
}

    .fx-richtext-image:hover {
        transform: scale(1.02);
        border-color: var(--nx-highlight-fg);
    }

    .fx-richtext-image img {
        display: block;
        width: 100%;
        height: auto;
        max-width: 100%;
        max-height: 180px;
        object-fit: cover;
        border-radius: calc(var(--nx-border-radius) - 2px);
    }

.fx-richtext-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--nx-tertiary-bg);
    border: var(--nx-border-width) solid var(--nx-border-color);
    border-radius: var(--nx-border-radius);
    color: var(--nx-highlight-fg);
    text-decoration: none;
    cursor: pointer;
    font-family: var(--nx-font);
}

    .fx-richtext-file:hover {
        border-color: var(--nx-highlight-fg);
        background: var(--nx-highlight-bg);
    }

/* Safety net so an image can never overflow its container. */
.fx-richtext-readonly img,
.fx-richtext-blocks img {
    max-width: 100%;
    height: auto;
}
