/* M14 editor — selection + caret + selection overlay styles. */

.lx-document-editor {
    position: relative;
    background: #fff;
    color: #111827;
    padding: 1.5rem;
    overflow: auto;
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.5;
}

.lx-document-editor:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.lx-document-editor-empty {
    color: #6b7280;
    font-style: italic;
    text-align: center;
    padding: 4rem 1rem;
}

.lx-caret {
    position: absolute;
    width: 1px;
    background: #1f2937;
    pointer-events: none;
    transition: opacity 0.05s linear;
    z-index: 5;
}

.lx-selection-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 4;
    inset: 0;
}

.lx-selection-band {
    position: absolute;
    background: rgba(96, 165, 250, 0.32);
    border-radius: 1px;
}

/* Run-content spans get a tiny line-height tweak so DOM Range.getBoundingClientRect
   reports a stable height for the caret. */
.lx-document-editor .lx-r,
.lx-document-editor .lx-t {
    display: inline;
}

.lx-document-editor .lx-layout-doc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16pt;
    min-width: max-content;
    margin: 0 auto;
}

.lx-document-editor .lx-layout-page {
    flex: 0 0 auto;
}

.lx-document-editor .lx-layout-run,
.lx-document-editor .lx-layout-tab {
    line-height: 1;
}

.lx-document-editor .lx-layout-image,
.lx-document-editor .lx-layout-vml-image {
    display: block;
    object-fit: contain;
}

.lx-document-editor .lx-layout-vml-placeholder,
.lx-document-editor .lx-layout-image-missing,
.lx-document-editor .lx-layout-opaque {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0.5pt dashed #d1d5db;
    color: #6b7280;
    font-size: 7pt;
    background: #f9fafb;
    box-sizing: border-box;
}

.lx-document-editor .lx-object-selected {
    outline: 1.5pt solid #4f46e5;
    outline-offset: 1pt;
}

.lx-object-adorn {
    position: absolute;
    z-index: 8;
    pointer-events: none;
    box-sizing: border-box;
}

.lx-object-adorn[hidden] {
    display: none !important;
}

.lx-object-adorn-frame {
    position: absolute;
    inset: -2px;
    border: 1px solid #4f46e5;
    background: rgba(79, 70, 229, 0.05);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.95);
    pointer-events: none;
}

.lx-object-move,
.lx-object-resize {
    position: absolute;
    width: 11px;
    height: 11px;
    border: 1px solid #4338ca;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.22);
    pointer-events: auto;
}

.lx-object-move {
    left: 50%;
    top: -22px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    transform: translateX(-50%);
    cursor: move;
}

.lx-object-move::before,
.lx-object-move::after {
    content: "";
    position: absolute;
    background: #4338ca;
}

.lx-object-move::before {
    left: 5px;
    right: 5px;
    top: 8px;
    height: 1px;
}

.lx-object-move::after {
    top: 5px;
    bottom: 5px;
    left: 8px;
    width: 1px;
}

.lx-object-resize-nw { left: -7px; top: -7px; cursor: nwse-resize; }
.lx-object-resize-n { left: 50%; top: -7px; transform: translateX(-50%); cursor: ns-resize; }
.lx-object-resize-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.lx-object-resize-e { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.lx-object-resize-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.lx-object-resize-s { left: 50%; bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
.lx-object-resize-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.lx-object-resize-w { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.lx-object-size-chip {
    position: absolute;
    right: -2px;
    bottom: -24px;
    min-width: 4rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #111827;
    color: #fff;
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

.lx-object-dragging,
.lx-object-dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}

/* === Ribbon shell layout =================================================
   These styles belong to the surviving OOXML ribbon shell. They used to live
   inside the deleted HTML editor component, so keep them with the editor CSS
   instead of coupling the ribbon chrome to a removed component.
*/

.lx-ribbon-shell {
    --c-blue:        #378ADD;
    --c-teal:        #1D9E75;
    --c-coral:       #D85A30;
    --c-amber:       #EF9F27;
    --c-amber-deep:  #BA7517;
    --c-green:       #639922;
    --c-pink:        #D4537E;
    --c-red:         #E24B4A;
    --c-purple-soft: #7F77DD;
    --hover-bg: rgb(var(--surface-3));

    position: relative;
    z-index: 20;
    overflow: visible;
    background: rgb(var(--ribbon-tabbar));
    border-bottom: 1px solid rgb(var(--border) / 0.5);
}

/* Combined top bar — brand + tabs + quick actions in a single 36px row. */
.lx-ribbon-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 36px;
    padding: 6px 12px;
    background: rgb(var(--surface-1));
    border-bottom: 0.5px solid rgb(var(--border) / 0.55);
}

.lx-ribbon-tabbar {
    display: flex;
    align-items: center;
    gap: 1px;
    min-width: 0;
}

.lx-ribbon-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 12px;
    border: none;
    border-radius: 6px;
    color: rgb(var(--fg-2));
    font-size: 13px;
    font-weight: 400;
    line-height: 1;
    background: transparent;
    transition: background-color 120ms ease, color 120ms ease;
    cursor: pointer;
}

.lx-ribbon-tab:hover {
    color: rgb(var(--fg-1));
    background: rgb(var(--surface-3));
}

.lx-ribbon-tab.is-active {
    color: rgb(var(--accent-500));
    font-weight: 500;
    background: rgb(var(--accent-500) / 0.10);
}

.lx-ribbon-tab:focus-visible {
    outline: 2px solid rgb(var(--accent-500));
    outline-offset: 2px;
}

.lx-ribbon-quick {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: rgb(var(--fg-2));
    transition: background-color 120ms ease, color 120ms ease;
}

.lx-ribbon-quick:hover {
    background: rgb(var(--surface-3));
}

.lx-ribbon-quick:focus-visible {
    outline: 2px solid rgb(var(--accent-500));
    outline-offset: 2px;
}

.lx-ribbon-quick-divider {
    flex: 0 0 auto;
    width: 1px;
    height: 14px;
    margin: 0 3px;
    background: rgb(var(--border));
}

.lx-ribbon-surface {
    position: relative;
    overflow-x: auto;
    overflow-y: visible;
    min-height: 40px;
    max-height: 40px;
    padding: 5px 12px;
    background: rgb(var(--ribbon-strip));
    border-top: 0;
}

.lx-ribbon-flat {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: max-content;
    height: 30px;
}

.lx-ribbon-vdiv {
    flex: 0 0 auto;
    width: 1px;
    height: 16px;
    margin: 0 3px;
    background: rgb(var(--border));
}

.lx-ribbon-select {
    height: 28px;
    padding: 0 8px;
    border: 0.5px solid rgb(var(--border));
    border-radius: 6px;
    color: rgb(var(--fg-1));
    font-size: 13px;
    background: rgb(var(--surface-1));
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.lx-ribbon-select:hover {
    border-color: rgb(var(--border-strong) / 0.75);
}

.lx-ribbon-select:focus {
    border-color: rgb(var(--ring));
    box-shadow: 0 0 0 2px rgb(var(--ring) / 0.25);
}

@media (max-width: 640px) {
    .lx-ribbon-surface {
        display: none;
    }

    .lx-editor.is-header-footer-editing .lx-ribbon-surface {
        display: block;
    }
}
