/* SAPIA · Editor con negrita, cursiva y viñetas (public/js/editor-texto.js)
   y textos con formato en las vistas. Los textos largos van justificados. */

.editor {
    border: 1px solid var(--border-strong, rgba(44, 44, 42, .22));
    border-radius: var(--radius, 10px);
    background: var(--surface, #fff);
    transition: border-color .2s ease, box-shadow .2s ease;
}
.editor.foco {
    border-color: #1E5AA8;
    box-shadow: 0 0 0 3px rgba(30, 90, 168, .14);
}
.editor.error { border-color: var(--red-400, #E24B4A); }

.editor-barra {
    display: flex;
    gap: 2px;
    padding: 4px;
    border-bottom: 1px solid var(--border, rgba(44, 44, 42, .12));
    background: #F8F9FB;
    border-radius: var(--radius, 10px) var(--radius, 10px) 0 0;
}
.editor-barra button {
    display: grid;
    place-items: center;
    width: 32px;
    height: 28px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--text-2, #5F5E5A);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.editor-barra button:hover { background: #EEF1F6; color: var(--navy, #16244C); }
.editor-barra button[aria-pressed="true"] { background: #E2E9F5; color: var(--navy, #16244C); }
.editor-barra button:focus-visible { outline: 2px solid rgba(30, 115, 190, .55); outline-offset: 1px; }

.editor-area {
    /* Crece con el texto: lo pegado se ve completo, sin una barra de desplazamiento interna. */
    min-height: 110px;
    padding: 10px 13px;
    font: 14px/1.6 'DM Sans', sans-serif;
    color: var(--text, #1A1A18);
    text-align: justify;
    outline: 0;
    word-break: break-word;
}
.editor.vacio .editor-area::before {
    content: attr(data-placeholder);
    color: var(--text-3, #888780);
    pointer-events: none;
}

/* El textarea original queda en el formulario, oculto, con el HTML del editor. */
.editor-oculto {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    border: 0 !important;
    opacity: 0;
    pointer-events: none;
    resize: none;
}

/* Contenido con formato: en el editor y al mostrarlo en el panel. */
.editor-area p, .texto-rico p { margin: 0 0 .55em; }
.editor-area p:last-child, .texto-rico p:last-child { margin-bottom: 0; }
.editor-area ul, .texto-rico ul { margin: .3em 0 .55em 1.35em; padding: 0; }
.editor-area li, .texto-rico li { margin: .15em 0; }
.texto-rico { text-align: justify; white-space: normal; }
.texto-rico strong { font-weight: 600; color: var(--text, #1A1A18); }

/* Ayuda y vista previa de fórmulas (LaTeX entre $ $). */
.editor-ayuda {
    margin-left: auto;
    align-self: center;
    padding-right: 6px;
    font-size: 11.5px;
    color: var(--text-3, #888780);
}
.editor-vista {
    padding: 10px 13px 12px;
    border-top: 1px dashed var(--border-strong, rgba(44, 44, 42, .22));
    background: #FAFBFD;
    border-radius: 0 0 var(--radius, 10px) var(--radius, 10px);
    font-size: 14px;
    line-height: 1.6;
}
.editor-vista-titulo {
    display: block;
    margin-bottom: 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3, #888780);
}
.katex { font-size: 1.05em; }
@media (max-width: 640px) { .editor-ayuda { display: none; } }

/* Texto sobre el máximo (por ejemplo, después de pegar): se avisa en vez de cortarlo. */
.editor.excede { border-color: var(--red-400, #E24B4A); }
.editor.excede.foco { box-shadow: 0 0 0 3px rgba(226, 75, 74, .14); }
.editor-exceso {
    padding: 8px 13px;
    border-top: 1px solid #F1CFCF;
    background: #FDF4F4;
    color: #8A2424;
    font-size: 12.5px;
    border-radius: 0 0 var(--radius, 10px) var(--radius, 10px);
}
.char-count.exceso { color: var(--red-600, #A32D2D); font-weight: 600; }
