/* ==========================================================================
   eventia-admin · Entrada de estilos
   Orden importa: tokens → primitivas → componentes → layouts.
   ========================================================================== */
@import url("tokens.css");
@import url("layout-primitives.css");
@import url("components.css");
@import url("layouts.css");

/* JSONEditor (josdejong/jsoneditor, ver assets/vendor/jsoneditor): el host
   necesita altura explícita; el textarea plano queda como fallback. */
.json-editor-host {
	height: 480px;
	margin: 0.25rem 0 0.75rem;
}

/* Upload de tema (logo/arte): selector de archivo junto al campo URL. */
.upload-inline {
	display: flex;
	gap: 0.5rem;
	align-items: center;
}
.upload-inline input[type="file"] {
	flex: 0 0 220px;
	min-height: 0;
	padding: 4px 8px;
	font-size: 0.8rem;
}
.upload-inline input[type="url"],
.upload-inline input:not([type="file"]) {
	flex: 1 1 auto;
}

/* Editor de código (code-editors.js, CodeMirror 6): host de cada editor */
.code-editor-host {
	height: 320px;
	margin: 0.25rem 0 0.75rem;
	border: 1px solid rgba(255, 255, 255, 0.12);
}

/* CodeMirror crece con el contenido; dentro del host fijo debe llenarlo y
   desplazarse, no desbordarlo. */
.code-editor-host .cm-editor {
	height: 100%;
}

.code-editor-host .cm-editor .cm-scroller {
	overflow: auto;
	font-family: var(--font-family-mono, Consolas, monospace);
}

/* Builder del formulario de registro (registration-builder.js) */
.field-list {
	list-style: none;
	margin: 0.5rem 0 1rem;
	padding: 0;
	display: grid;
	gap: 0.5rem;
}
.field-row {
	display: grid;
	grid-template-columns: auto minmax(10rem, 1fr) minmax(8rem, 0.75fr) auto auto auto auto auto;
	gap: 0.5rem;
	align-items: center;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.03);
}
/* Las filas con editor de opciones (select) pasan a una columna: el campo
   ocupaba 7 columnas y el editor va debajo, a ancho completo. */
.field-row:has(.field-options) {
	grid-template-columns: auto minmax(10rem, 1fr) minmax(8rem, 0.75fr) auto auto auto auto auto;
}
.field-row .field-options {
	grid-column: 1 / -1;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	padding-top: 0.35rem;
}
.field-options-list {
	width: 100%;
	font-family: ui-monospace, monospace;
	font-size: 0.8rem;
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 6px;
	color: inherit;
	padding: 0.4em 0.6em;
	resize: vertical;
}
.field-locked {
	opacity: 0.92;
}
.field-badge {
	font-size: 0.75rem;
	padding: 0.15em 0.6em;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.1);
	white-space: nowrap;
}
.field-label,
.field-name {
	min-width: 0;
	padding: 0.45em 0.7em;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
}
.field-name {
	font-family: ui-monospace, monospace;
	font-size: 0.85rem;
}
.schema-preview {
	max-height: 16rem;
	overflow: auto;
	padding: 0.75rem 1rem;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 8px;
	font-size: 0.8rem;
}
.form-preview {
	margin: 1rem 0;
	padding: 1rem 1.25rem;
	border: 1px dashed rgba(255, 255, 255, 0.25);
	border-radius: 8px;
	display: grid;
	gap: 0.75rem;
}


/* ════════════════════════════════════════════════════════════════════════
   JSONEditor (josdejong/jsoneditor) · tema oscuro para el panel
   El vendor solo trae tema claro y el panel es oscuro (tokens.css); además
   la regla genérica de tablas de components.css pinta table.jsoneditor-tree
   (fondo oscuro + celdas con padding) y la regla genérica de campos alcanza
   al input de búsqueda. Todo va prefijado con .json-editor-host: gana en
   especificidad a jsoneditor.min.css (cargado después) y al tema de Ace,
   que el editor inyecta en runtime.
   ════════════════════════════════════════════════════════════════════════ */

/* Marco general */
.json-editor-host .jsoneditor {
	color: var(--text-primary);
	background: var(--bg-card);
	border: 1px solid var(--border-color);
	border-radius: var(--radius-sm);
}

/* ── Árbol (modo tree) ─────────────────────────────────────────────── */
/* La tabla del árbol hereda el fondo oscuro del panel vía la regla
   genérica de tablas: se deja transparente sobre el fondo del editor.
   table.jsoneditor-values (una por fila, anidada) necesita width:auto:
   la regla genérica le pone width:100% y estira el separador ":" hasta
   el borde, desalineando los valores. */
.json-editor-host .jsoneditor table.jsoneditor-tree:not(.table),
.json-editor-host .jsoneditor table.jsoneditor-values:not(.table) {
	background: transparent;
	border: 0;
	border-radius: 0;
}
.json-editor-host .jsoneditor table.jsoneditor-values:not(.table) {
	/* width:auto en una tabla de bloque significa "llenar el contenedor":
	   max-content sí encoge a su contenido (stock del editor). */
	width: max-content;
	max-width: 100%;
}
.json-editor-host .jsoneditor table.jsoneditor-tree:not(.table) tbody td {
	padding: 0;
	border-bottom: 0;
	color: var(--text-primary);
	font-size: 14px;
	vertical-align: top; /* la regla genérica de tablas del panel pone middle */
}
.json-editor-host .jsoneditor table.jsoneditor-tree:not(.table) tbody tr { transition: none; }
.json-editor-host .jsoneditor table.jsoneditor-tree:not(.table) tbody tr:hover { background: transparent; }

.json-editor-host div.jsoneditor-tree { background: var(--bg-card); }
/* El algoritmo auto de la tabla del árbol le da casi todo el ancho a la
   columna del valor (su contenido preferido es enorme) y encoge la de la
   key hasta cortarla. width:1% + nowrap fuerza a la celda de la key a
   ocupar solo su contenido; el valor sigue envolviendo con break-word. */
.json-editor-host td.jsoneditor-tree:has(> .jsoneditor-field) {
	width: 1%;
	white-space: nowrap;
}
.json-editor-host div.jsoneditor-field {
	word-break: normal;
}
.json-editor-host div.jsoneditor-tree .jsoneditor-field { color: var(--text-heading); }
.json-editor-host .jsoneditor-value.jsoneditor-string { color: #7ee787; }
.json-editor-host .jsoneditor-value.jsoneditor-url { color: #7ee787; }
.json-editor-host .jsoneditor-value.jsoneditor-number { color: #f78c6c; }
.json-editor-host .jsoneditor-value.jsoneditor-boolean { color: var(--yellow); }
.json-editor-host .jsoneditor-value.jsoneditor-null { color: var(--blue); }
.json-editor-host .jsoneditor-readonly { color: var(--text-muted); }
.json-editor-host div.jsoneditor td.jsoneditor-separator { color: var(--text-muted); }
.json-editor-host div.jsoneditor-tree div.jsoneditor-show-more { background: var(--bg-hover); color: var(--text-secondary); }
.json-editor-host div.jsoneditor-tree div.jsoneditor-show-more a { color: var(--text-secondary); }

/* Filas seleccionadas / resaltadas */
.json-editor-host tr.jsoneditor-highlight,
.json-editor-host tr.jsoneditor-selected { background-color: var(--bg-hover); }
.json-editor-host tr.jsoneditor-selected.jsoneditor-first { background-color: var(--bg-hover); }

/* Campos editables: hover, foco y coincidencias de búsqueda */
.json-editor-host div.jsoneditor-field[contenteditable="true"]:hover,
.json-editor-host div.jsoneditor-field[contenteditable="true"]:focus,
.json-editor-host div.jsoneditor-value[contenteditable="true"]:hover,
.json-editor-host div.jsoneditor-value[contenteditable="true"]:focus,
.json-editor-host div.jsoneditor-field.jsoneditor-highlight,
.json-editor-host div.jsoneditor-value.jsoneditor-highlight,
.json-editor-host div.jsoneditor-field.jsoneditor-highlight-active,
.json-editor-host div.jsoneditor-value.jsoneditor-highlight-active {
	background-color: color-mix(in oklab, var(--primary) 25%, transparent);
	border-color: var(--primary);
	color: var(--text-heading);
}

/* Los iconos del sprite del vendor son oscuros: sobre fondo oscuro no se
   ven. invert() los aclara (hue-rotate conserva el matiz de los rojos). */
.json-editor-host div.jsoneditor-tree button.jsoneditor-button,
.json-editor-host .jsoneditor-menu > button,
.json-editor-host .jsoneditor-treepath button,
.json-editor-host .jsoneditor-statusbar button,
.json-editor-host .jsoneditor-search button,
.json-editor-host .jsoneditor-navigation-bar button,
.json-editor-host .jsoneditor-contextmenu .jsoneditor-icon,
.json-editor-host .jsoneditor-text-errors .jsoneditor-schema-error {
	filter: invert(1) hue-rotate(180deg);
}

/* ── Barra de menú ─────────────────────────────────────────────────── */
.json-editor-host .jsoneditor-menu {
	background-color: var(--primary-dk);
	border-bottom: 1px solid color-mix(in oklab, var(--primary-dk), #000 20%);
	color: var(--on-primary);
}
.json-editor-host .jsoneditor-menu .jsoneditor-modes { color: var(--on-primary); }

/* ── Barra de ruta (treepath) y barra de navegación (modo code) ────── */
.json-editor-host .jsoneditor-treepath,
.json-editor-host .jsoneditor-treepath.show-all,
.json-editor-host .jsoneditor-navigation-bar {
	background-color: var(--bg-card-header);
	color: var(--text-secondary);
}
.json-editor-host .jsoneditor-treepath .jsoneditor-treepath-element,
.json-editor-host .jsoneditor-treepath .jsoneditor-treepath-seperator { color: var(--text-secondary); }
.json-editor-host .jsoneditor-treepath span.jsoneditor-treepath-element:hover,
.json-editor-host .jsoneditor-treepath span.jsoneditor-treepath-seperator:hover { color: var(--text-primary); }

/* ── Búsqueda ──────────────────────────────────────────────────────── */
.json-editor-host .jsoneditor .jsoneditor-search .jsoneditor-frame {
	background: var(--bg-input);
	border: 1px solid var(--border-color);
	border-radius: var(--radius-sm);
}
.json-editor-host .jsoneditor .jsoneditor-search input {
	width: auto;
	padding: 3px 6px;
	background: transparent;
	border: 0;
	border-radius: 0;
	color: var(--text-primary);
	font-size: 0.85rem;
}
.json-editor-host .jsoneditor .jsoneditor-search input::placeholder { color: var(--text-muted); }
.json-editor-host .jsoneditor .jsoneditor-search .jsoneditor-results { color: var(--text-muted); }

/* ── Barra de estado ───────────────────────────────────────────────── */
.json-editor-host .jsoneditor-statusbar {
	background: var(--bg-card-header);
	border-top: 1px solid var(--border-color);
	color: var(--text-muted);
}
.json-editor-host .jsoneditor-statusbar .jsoneditor-curserinfo-count,
.json-editor-host .jsoneditor-statusbar .jsoneditor-curserinfo-val { color: var(--text-primary); }
.json-editor-host .jsoneditor-poweredBy { color: var(--text-muted); }

/* ── Menú contextual (clic derecho sobre un nodo) ──────────────────── */
.json-editor-host .jsoneditor-contextmenu .jsoneditor-menu {
	background: var(--bg-card);
	border: 1px solid var(--border-card);
	box-shadow: var(--shadow-lg);
	color: var(--text-primary);
}
.json-editor-host .jsoneditor-contextmenu .jsoneditor-menu li { color: var(--text-secondary); }
.json-editor-host .jsoneditor-contextmenu .jsoneditor-menu li button { color: var(--text-primary); }
.json-editor-host .jsoneditor-contextmenu .jsoneditor-menu li button:hover,
.json-editor-host .jsoneditor-contextmenu .jsoneditor-menu li button.jsoneditor-selected { background-color: var(--bg-hover); }
.json-editor-host .jsoneditor-contextmenu .jsoneditor-separator { border-color: var(--border-color); }

/* ── Modales (ordenar / transformar / filtrar) ─────────────────────── */
/* El overlay se ancla a document.body (fuera de .json-editor-host), así
   que estas reglas se anclan en .jsoneditor-modal-overlay, clase propia
   del vendor que no existe en ningún otro lugar del panel. */
/* pico-modal (dentro del vendor) fija background-color: white como estilo
   inline en el modal y el overlay, y el modal es hijo de body (hermano del
   overlay): solo !important sobre el selector plano lo vence. Estas clases
   solo existen mientras un modal de JSONEditor está abierto. */
.jsoneditor-modal-overlay { background: rgba(4, 8, 20, .6) !important; }
.jsoneditor-modal {
	background: var(--bg-card) !important;
	border: 1px solid var(--border-card);
	box-shadow: var(--shadow-xl);
	color: var(--text-primary);
}
.jsoneditor-modal table:not(.table) { background: transparent; border: 0; border-radius: 0; }
.jsoneditor-modal table:not(.table) tbody td { color: var(--text-primary); border-bottom: 0; vertical-align: middle; }
.jsoneditor-modal .jsoneditor-jmespath-label { color: var(--text-secondary); }
/* div. prefix: sube (0,2,0)→(0,2,1) para ganar la cascada al vendor,
   que se carga después de esta hoja a igual especificidad. */
div.jsoneditor-modal .jsoneditor-transform-preview {
	background: var(--bg-body);
	border: 1px solid var(--border-color);
	color: var(--text-primary);
}
.jsoneditor-modal .jsoneditor-modal-actions button { color: var(--text-primary); }
div.jsoneditor-modal :is(input, select, textarea):not([type="checkbox"]) {
	background: var(--bg-input);
	border: 1px solid var(--border-color);
	border-radius: var(--radius-sm);
	color: var(--text-primary);
}
.jsoneditor-modal a { color: var(--primary); }

/* Selectr (desplegable de los modales) */
div.jsoneditor-modal .selectr-selected,
div.jsoneditor-modal .selectr-options {
	background: var(--bg-input);
	border-color: var(--border-color);
	color: var(--text-primary);
}
div.jsoneditor-modal .selectr-options li { color: var(--text-primary); }
div.jsoneditor-modal .selectr-options li:hover { background: var(--bg-hover); }

/* ── Panel de errores de validación (modo code) ────────────────────── */
.json-editor-host .jsoneditor .jsoneditor-text-errors { background: var(--bg-card-header); border-top: 1px solid var(--border-color); }
.json-editor-host .jsoneditor .jsoneditor-text-errors tr { background-color: transparent; color: var(--text-secondary); }
.json-editor-host .jsoneditor .jsoneditor-text-errors tr.parse-error { background-color: color-mix(in oklab, var(--red) 15%, transparent); }
.json-editor-host .jsoneditor .jsoneditor-text-errors tr.jump-to-line:hover { background: var(--bg-hover); }

/* ── Ace (modo code): el tema claro se inyecta en runtime, así que se
   sube un nivel de especificidad (.json-editor-host) para ganarle. ── */
.json-editor-host .ace-jsoneditor.ace_editor,
.json-editor-host .ace-jsoneditor .ace_scroller { background-color: var(--bg-card); }
.json-editor-host .ace-jsoneditor .ace_gutter { background: var(--bg-card-header); color: var(--text-muted); }
.json-editor-host .ace-jsoneditor .ace_gutter-active-line { background-color: var(--bg-hover); }
.json-editor-host .ace-jsoneditor .ace_marker-layer .ace_active-line { background: var(--bg-row-hover); }
.json-editor-host .ace-jsoneditor .ace_text-layer { color: var(--text-secondary); }
.json-editor-host .ace-jsoneditor .ace_variable { color: var(--text-heading); }
.json-editor-host .ace-jsoneditor .ace_string { color: #7ee787; }
.json-editor-host .ace-jsoneditor .ace_constant.ace_numeric { color: #f78c6c; }
.json-editor-host .ace-jsoneditor .ace_constant.ace_language { color: var(--yellow); }
.json-editor-host .ace-jsoneditor .ace_keyword.ace_operator { color: var(--text-secondary); }
.json-editor-host .ace-jsoneditor .ace_cursor { border-left-color: var(--text-primary); }
.json-editor-host .ace-jsoneditor .ace_marker-layer .ace_selection { background: color-mix(in oklab, var(--primary) 35%, transparent); }
.json-editor-host .ace-jsoneditor .ace_marker-layer .ace_bracket { border-color: var(--text-muted); }
.json-editor-host .ace-jsoneditor .ace_marker-layer .ace_selected-word { border-color: var(--primary); }
.json-editor-host .ace-jsoneditor .ace_invisible { color: var(--text-muted); }
.json-editor-host .ace-jsoneditor .ace_indent-guide { background: none; }

/* Píldora flotante de "x errores adicionales" (modo code) y margen de
   impresión de Ace, que el tema claro pinta grises. */
.json-editor-host .jsoneditor .jsoneditor-additional-errors {
	background-color: var(--bg-card-header);
	border: 1px solid var(--border-color);
	color: var(--text-secondary);
}
.json-editor-host .ace-jsoneditor .ace_print-margin { background: var(--border-color); }
