/* Contenido HTML de preguntas — legible en ambos temas */
.rich-content {
    line-height: 1.6;
    color: var(--text);
    word-wrap: break-word;
}

.rich-content :where(p, li, span, div, h1, h2, h3, h4, strong, em, u, b, i, ol, ul):not(pre *) {
    color: inherit;
}

.rich-content [style] {
    color: inherit !important;
    background: transparent !important;
    background-color: transparent !important;
}

.rich-content a {
    color: var(--accent);
}

.rich-content a:hover {
    color: var(--accent-hover);
}

.rich-content p {
    margin: 0 0 0.5rem;
}

.rich-content p:last-child {
    margin-bottom: 0;
}

.rich-content ul,
.rich-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.rich-content strong,
.rich-content b {
    font-weight: 700;
    color: inherit;
}

.rich-content em,
.rich-content i {
    font-style: italic;
    color: inherit;
}

.rich-content u {
    text-decoration: underline;
    color: inherit;
}

.rich-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0.5rem 0;
    border-radius: 6px;
}

.question-editor-wrap .ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

/* Clases de alineación/indentación de Quill (sin cargar quill.css en todas las páginas) */
.rich-content .ql-align-center {
    text-align: center;
}

.rich-content .ql-align-right {
    text-align: right;
}

.rich-content .ql-align-justify {
    text-align: justify;
}

.rich-content li.ql-indent-1,
.rich-content .ql-indent-1:not(li) {
    padding-left: 3em;
}

.rich-content li.ql-indent-2,
.rich-content .ql-indent-2:not(li) {
    padding-left: 6em;
}

.rich-content li.ql-indent-3,
.rich-content .ql-indent-3:not(li) {
    padding-left: 9em;
}

/* Editor Quill */
.question-editor-wrap {
    margin-bottom: 0.5rem;
}

.question-editor-wrap .question-input-hidden {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    resize: none !important;
    overflow: hidden !important;
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.question-editor-wrap .ql-toolbar.ql-snow {
    background: var(--surface2);
    border-color: var(--border);
    border-radius: 8px 8px 0 0;
}

.question-editor-wrap .ql-container.ql-snow {
    background: var(--editor-bg);
    border-color: var(--border);
    border-radius: 0 0 8px 8px;
    min-height: 120px;
    font-size: 1rem;
}

.question-editor-wrap .ql-editor {
    color: var(--text);
    background: var(--editor-bg);
    min-height: 120px;
}

.question-editor-wrap .ql-editor :where(p, li, span, strong, em, u, ol, ul):not(pre *) {
    color: inherit;
}

.question-editor-wrap .ql-editor [style] {
    color: inherit !important;
    background: transparent !important;
    background-color: transparent !important;
}

.question-editor-wrap .ql-editor.ql-blank::before {
    color: var(--muted);
    font-style: normal;
}

.question-editor-wrap .ql-snow .ql-stroke {
    stroke: var(--muted);
}

.question-editor-wrap .ql-snow .ql-fill {
    fill: var(--muted);
}

.question-editor-wrap .ql-snow .ql-picker-label {
    color: var(--muted);
}

.question-editor-wrap .ql-snow.ql-toolbar button:hover,
.question-editor-wrap .ql-snow.ql-toolbar button.ql-active {
    color: var(--accent);
}

.question-editor-wrap .ql-snow.ql-toolbar button:hover .ql-stroke,
.question-editor-wrap .ql-snow.ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent);
}

.question-block-heading,
.question-block .question-file-block label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.exam-preview-question {
    max-height: 4rem;
    overflow: hidden;
    font-size: 0.9rem;
}

/* Formas de respuesta por pregunta */
.question-answer-modes {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1.25rem;
    margin: 0.5rem 0 0.75rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 0.9rem;
}

.question-answer-modes .checkbox-row {
    margin: 0;
}

.question-answer-modes-label {
    color: var(--muted);
    font-weight: 600;
}

.exam-answer-mode-hint {
    margin: 0.85rem 0 0.6rem;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--accent);
    background: var(--surface2);
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
    color: var(--text);
}

/* Subíndice / superíndice */
.rich-content sub,
.rich-content sup {
    font-size: 0.75em;
    line-height: 0;
}

/* Bloques de código */
.rich-content pre,
.question-editor-wrap .ql-editor pre.ql-syntax {
    background: #282c34;
    color: #abb2bf;
    font-family: "Fira Code", "Consolas", "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    overflow-x: auto;
    white-space: pre;
    tab-size: 4;
    margin: 0.5rem 0;
}

/* Fórmulas */
.rich-content .ql-formula,
.question-editor-wrap .ql-editor .ql-formula {
    display: inline-block;
    padding: 0 0.1em;
}

.question-editor-wrap .ql-editor .ql-formula {
    cursor: pointer;
    border-radius: 4px;
}

.question-editor-wrap .ql-editor .ql-formula:hover {
    outline: 1px dashed var(--accent);
}

/* Tablas */
.rich-content table,
.question-editor-wrap .ql-editor table.rich-table {
    border-collapse: collapse;
    margin: 0.75rem 0;
    max-width: 100%;
    display: block;
    overflow-x: auto;
}

.rich-content th,
.rich-content td,
.question-editor-wrap .ql-editor table.rich-table th,
.question-editor-wrap .ql-editor table.rich-table td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.65rem;
    text-align: left;
    vertical-align: top;
    min-width: 3rem;
}

.rich-content th,
.question-editor-wrap .ql-editor table.rich-table th {
    background: var(--surface2);
    font-weight: 600;
}

.question-editor-wrap .ql-editor table.rich-table {
    cursor: pointer;
}

.question-editor-wrap .ql-editor table.rich-table:hover {
    outline: 1px dashed var(--accent);
}

/* Diálogos del editor (fórmula / tabla) */
.rich-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    height: fit-content;
    max-height: 90vh;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    padding: 0;
    width: min(680px, 94vw);
    box-shadow: var(--shadow);
}

.rich-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.rich-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.rich-dialog-header h3 {
    margin: 0;
    font-size: 1rem;
}

.rich-dialog-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.rich-dialog-body {
    padding: 1rem;
    max-height: 65vh;
    overflow-y: auto;
}

.rich-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.rich-dialog-hint {
    margin: 0.75rem 0 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.rich-formula-snippets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.rich-formula-snippets .btn {
    min-width: 2.4rem;
    justify-content: center;
}

.rich-formula-input {
    width: 100%;
    font-family: "Fira Code", "Consolas", monospace;
    font-size: 0.95rem;
}

.rich-formula-preview {
    min-height: 3rem;
    padding: 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface2);
    overflow-x: auto;
}

.rich-table-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.rich-table-controls input[type="number"] {
    width: 5rem;
    margin-left: 0.35rem;
}

.rich-table-grid-wrap {
    overflow-x: auto;
}

.rich-table-grid {
    border-collapse: collapse;
}

.rich-table-grid td {
    padding: 2px;
}

.rich-table-grid input {
    min-width: 7rem;
    padding: 0.3rem 0.45rem;
    font-size: 0.9rem;
}

.rich-table-grid.has-header tr:first-child input {
    font-weight: 600;
    background: var(--surface2);
}
