/* ==========================================================================
   REMOOX Cloud - CMS & Web App Builder Engine (Native Library CSS)
   ========================================================================== */

:root {
    --rmx-bg-editor: #f8f9fa;
    --rmx-sidebar-bg: #ffffff;
    --rmx-border-color: #e0e0e0;
    --rmx-primary-color: #0d6efd;
    --rmx-active-hover: #e9ecef;
    --rmx-text-muted: #676767;
    --rmx-font-family: Arial, sans-serif;
}

/* Selector de páginas del campo "URL de Destino (HREF)" en bloques de
   botón: dropdown flotante anclado por posición absoluta calculada en JS
   (no depende de position:relative del padre, porque el input puede vivir
   dentro del canvas del editor visual en cualquier nivel de anidamiento). */
.rmx-href-picker {
    position: absolute;
    z-index: 3000;
    display: none;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .15);
    padding: 4px;
}

.rmx-href-picker-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
}

.rmx-href-picker-item:hover {
    background-color: #eef5ff;
}

.rmx-href-picker-title {
    font-size: 11px;
    font-weight: 700;
    color: #0f172a;
}

.rmx-href-picker-path {
    font-size: 10px;
    color: #64748b;
}

/* Layout General del Builder */
.rmx-builder-container {
    display: flex;
    height: calc(100vh - 110px);
    background-color: var(--rmx-dark-bg, #0b0f19);
    font-family: var(--rmx-font-family);
    overflow: hidden;
    border: 1px solid var(--rmx-dark-border, #1c2333);
    border-radius: 10px;
}

/* Sidebar Izquierdo: Explorador de Archivos y Componentes */
.rmx-builder-sidebar-left {
    width: 280px;
    flex-shrink: 0;
    background-color: var(--rmx-sidebar-bg);
    border-right: 1px solid var(--rmx-border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

/* Área principal: barra superior (nombre/estado + acciones) + contenido
   (hoy, el Chat de IA a todo lo ancho restante). min-height:0 es necesario
   para que el hijo con overflow-y:auto (los mensajes del chat) pueda
   encogerse dentro del flex en vez de desbordar la página. */
.rmx-builder-workspace {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.rmx-builder-toolbar {
    min-height: 56px;
    background-color: var(--rmx-dark-bg-alt, #10151f);
    border-bottom: 1px solid var(--rmx-dark-border, #1c2333);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 15px;
}

.rmx-builder-toolbar #rmx-webapp-name-label {
    color: #e2e8f0;
}

.rmx-builder-toolbar .text-muted {
    color: var(--rmx-dark-text-muted, #64748b) !important;
}

/* Botones de la barra superior (Ejecutar / Exportar): mismo tratamiento
   "neón" del explorador — transparentes con borde de color hasta el hover,
   donde se rellenan con un glow, en vez de los botones sólidos de Bootstrap. */
.rmx-builder-toolbar .btn.btn-outline-primary {
    color: var(--rmx-neon-blue, #0d6efd);
    border-color: rgba(13, 110, 253, .5);
    background-color: transparent;
}

.rmx-builder-toolbar .btn.btn-outline-primary:hover {
    background-color: var(--rmx-neon-blue, #0d6efd);
    color: #fff;
    box-shadow: 0 0 10px var(--rmx-neon-blue-glow, rgba(13, 110, 253, .55));
}

.rmx-builder-toolbar .btn-success {
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, .5);
    background-color: transparent;
}

.rmx-builder-toolbar .btn-success:hover {
    background-color: #22c55e;
    border-color: #22c55e;
    color: #0b0f19;
    box-shadow: 0 0 10px rgba(34, 197, 94, .55);
}

/* Botones compactos de solo ícono (editar app, cerrar modal): mismo tamaño
   20x20 que los botones del Explorador (nueva página / subir archivo). */
.rmx-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    padding: 0;
    border: none;
    background-color: transparent;
    color: var(--rmx-neon-blue, #0d6efd);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}

.rmx-icon-btn .material-symbols-outlined {
    font-size: 14px;
}

.rmx-icon-btn:hover {
    background-color: rgba(13, 110, 253, .15);
    color: var(--rmx-neon-blue, #0d6efd);
}

/* Atajo a Google Analytics del sitio (abre la ventana de editar con el campo listo). */
.rmx-ga-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    border: 1px dashed rgba(203, 213, 225, .75);
    background: rgba(255, 255, 255, .04);
    color: #e2e8f0;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
}

.rmx-ga-chip .material-symbols-outlined { font-size: 13px; }
.rmx-ga-chip:hover { border-style: solid; background: rgba(255, 255, 255, .1); }
.rmx-ga-chip.is-on { border-style: solid; border-color: rgba(61, 220, 132, .5); color: #3ddc84; }

/* Modales anchos de la Web App (Editar aplicación / Google Analytics):
   casi pantalla completa, tarjetas repartidas con flex-wrap que bajan a
   una columna en pantallas angostas. Se abren con .is-open. */
.rmx-wm {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    align-items: center;
    justify-content: center;
    padding: 2vh 2vw;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
}

.rmx-wm.is-open { display: flex; animation: rmx-wm-fade .16s ease-out; }

@keyframes rmx-wm-fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.rmx-wm-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1600px;
    max-height: 96vh;
    background: #f8fafc;
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, .35);
    overflow: hidden;
}

.rmx-wm-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.rmx-wm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(13, 110, 253, .1);
    color: #0d6efd;
}

.rmx-wm-icon.is-ga { background: rgba(249, 171, 0, .14); color: #e37400; }
.rmx-wm-icon .material-symbols-outlined { font-size: 24px; }

.rmx-wm-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rmx-wm-titles strong { font-size: 16px; color: #0f172a; }
.rmx-wm-titles span { font-size: 12px; color: #64748b; }

.rmx-wm-body {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    overflow-y: auto;
}

.rmx-wm-card {
    flex: 1 1 320px;
    min-width: 0;
    padding: 18px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.rmx-wm-card h6 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}

.rmx-wm-card h6 .material-symbols-outlined { font-size: 18px; color: #0d6efd; }

.rmx-wm-field { margin-bottom: 12px; }

.rmx-wm-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
}

/* !important: el tema global fija alto y ancho (95%) de los inputs. */
.rmx-wm .rmx-wm-field .form-control { width: 100% !important; min-height: 36px; font-size: 13px !important; border-radius: 8px; border-color: #cbd5e1; }
.rmx-wm .rmx-wm-field textarea.form-control { height: auto !important; }
.rmx-wm .rmx-wm-field .form-control:focus { border-color: #0d6efd; box-shadow: 0 0 0 3px rgba(13, 110, 253, .15); }
.rmx-wm .rmx-wm-field .rmx-wm-big { height: 48px !important; font-size: 20px !important; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; }

.rmx-wm-help { margin: 0; font-size: 11px; line-height: 1.5; color: #64748b; }

.rmx-wm-note {
    padding: 12px;
    border-radius: 10px;
    background: #f1f5f9;
    font-size: 12px;
    line-height: 1.5;
    color: #475569;
}

.rmx-wm-note strong { display: block; margin-bottom: 4px; color: #0f172a; }
.rmx-wm-note p { margin: 0 0 6px; }
.rmx-wm-note p:last-child { margin-bottom: 0; }
.rmx-wm-codes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rmx-wm-codes code { padding: 3px 8px; border-radius: 6px; background: #fff; color: #0f172a; word-break: break-all; }

.rmx-wm-steps { margin: 0; padding-left: 20px; font-size: 12px; line-height: 1.6; color: #334155; }
.rmx-wm-steps li { margin-bottom: 8px; }

.rmx-wm-list { margin: 0 0 12px; padding: 0; list-style: none; font-size: 12px; color: #334155; }
.rmx-wm-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f1f5f9; }
.rmx-wm-list li:last-child { border-bottom: 0; }
.rmx-wm-list .material-symbols-outlined { font-size: 18px; color: #e37400; }

.rmx-wm-state {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.4;
}

.rmx-wm-state .material-symbols-outlined { font-size: 18px; }
.rmx-wm-state.is-off { background: #f1f5f9; color: #475569; }
.rmx-wm-state.is-on { background: #dcfce7; color: #166534; }
.rmx-wm-state.is-new { background: #dbeafe; color: #1e40af; }
.rmx-wm-state.is-bad { background: #fee2e2; color: #991b1b; }

.rmx-wm-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 24px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.rmx-wm-foot .btn { min-width: 110px; border-radius: 8px; }

@media (max-width: 576px) {
    .rmx-wm { padding: 0; }
    .rmx-wm-panel { max-height: 100vh; height: 100%; border-radius: 0; }
    .rmx-wm-head, .rmx-wm-body, .rmx-wm-foot { padding-left: 16px; padding-right: 16px; }
}

/* Chip de estado (Publicado/Borrador/Archivado): reemplaza el badge sólido
   de Bootstrap por una píldora con punto de color + glow sutil, más legible
   sobre el fondo oscuro y reubicada junto al nombre de la app. */
.rmx-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    border: 1px solid;
    background-color: rgba(255, 255, 255, .04);
    line-height: 1.6;
}

.rmx-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rmx-status-chip.status-published {
    color: #3ddc84;
    border-color: rgba(61, 220, 132, .5);
}

.rmx-status-chip.status-published .rmx-status-dot {
    background-color: #3ddc84;
    box-shadow: 0 0 6px rgba(61, 220, 132, .8);
}

.rmx-status-chip.status-draft {
    color: #ffc94d;
    border-color: rgba(255, 201, 77, .5);
}

.rmx-status-chip.status-draft .rmx-status-dot {
    background-color: #ffc94d;
    box-shadow: 0 0 6px rgba(255, 201, 77, .8);
}

.rmx-status-chip.status-archived {
    color: #94a3b8;
    border-color: rgba(148, 163, 184, .5);
}

.rmx-status-chip.status-archived .rmx-status-dot {
    background-color: #94a3b8;
    box-shadow: 0 0 6px rgba(148, 163, 184, .6);
}

.rmx-builder-canvas-frame {
    width: 100%;
    height: 100%;
    border: none;
    background-color: #ffffff;
}

/* Sidebar Derecho: ya no se usa en el índice del CMS Builder (el Chat de IA
   ocupa ahora todo el ancho restante), se deja disponible por si otra
   vista todavía la necesita. */
.rmx-builder-sidebar-right {
    width: 320px;
    background-color: var(--rmx-sidebar-bg);
    border-left: 1px solid var(--rmx-border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Responsive: en pantallas angostas, el explorador pasa a ser una franja
   superior con alto limitado (con su propio scroll) y el área principal
   (barra + chat) ocupa el resto verticalmente. */
@media (max-width: 768px) {
    .rmx-builder-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 110px);
    }

    .rmx-builder-sidebar-left {
        width: 100%;
        max-height: 220px;
        border-right: none;
        border-bottom: 1px solid var(--rmx-dark-border, #1c2333);
    }

    .rmx-builder-workspace {
        min-height: 520px;
    }

    .rmx-builder-toolbar {
        padding: 10px 12px;
    }
}

/* Arbol de Archivos (/pages, /assets, /scripts, /components) */
.rmx-file-tree {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 12px;
}

.rmx-file-tree-item {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    user-select: none;
    color: #333;
    border-bottom: 1px solid #f1f1f1;
}

.rmx-file-tree-item:hover {
    background-color: var(--rmx-active-hover);
}

.rmx-file-tree-item.active {
    background-color: #e8f0fe;
    color: var(--rmx-primary-color);
    font-weight: bold;
}

.rmx-file-tree-item .material-symbols-outlined {
    font-size: 18px;
    margin-right: 8px;
    color: var(--rmx-text-muted);
}

/* Componentes arrastrables */
.rmx-draggable-component {
    padding: 8px 12px;
    margin: 5px;
    background-color: #fff;
    border: 1px dashed var(--rmx-border-color);
    border-radius: 4px;
    cursor: grab;
    font-size: 11px;
    display: flex;
    align-items: center;
}

.rmx-draggable-component:hover {
    border-color: var(--rmx-primary-color);
    background-color: #f4f8ff;
}

/* Contador de Tokens y Acciones de IA */
.rmx-token-badge {
    background-color: #fff8e1;
    color: #b78103;
    border: 1px solid #ffe082;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
}

/* Carpetas del Explorador: colapsadas por defecto, el toggle en main.js
   solo agrega/quita la clase "expanded" y el ícono; este es el CSS que
   realmente oculta/muestra el contenido de la carpeta. */
.rmx-folder-group .rmx-folder-children {
    display: none;
}

.rmx-folder-group.expanded .rmx-folder-children {
    display: block;
    /* Una carpeta con muchos archivos no debe empujar a las demás fuera
       de la vista: scroll propio a partir de ~500px. */
    max-height: 500px;
    overflow-y: auto;
}

/* Retroalimentación visual al arrastrar un archivo sobre una carpeta destino */
.rmx-folder-dropzone.rmx-drop-target > .rmx-folder-toggle {
    background-color: rgba(13, 110, 253, .18);
    outline: 1px dashed var(--rmx-neon-blue);
}

/* ==========================================================================
   Explorador (sidebar izquierdo) — tema oscuro minimalista tipo editor de
   código, con acentos en el mismo azul de marca que usa .btn-primary en el
   resto de la app (--rmx-primary-color / #0d6efd), con un toque "neón" vía
   text-shadow/box-shadow sutiles en vez de un color distinto inventado.
   ========================================================================== */
:root {
    --rmx-neon-blue: #0d6efd;
    --rmx-neon-blue-glow: rgba(13, 110, 253, .55);
    --rmx-dark-bg: #0b0f19;
    --rmx-dark-bg-alt: #10151f;
    --rmx-dark-border: #1c2333;
    --rmx-dark-text: #cbd5e1;
    --rmx-dark-text-muted: #64748b;
}

.rmx-builder-sidebar-left {
    background-color: var(--rmx-dark-bg);
    border-right: 1px solid var(--rmx-dark-border);
    color: var(--rmx-dark-text);
}

.rmx-builder-sidebar-left .rmx-explorer-header {
    color: #e2e8f0 !important;
    letter-spacing: .06em;
    border-bottom-color: var(--rmx-dark-border) !important;
}

/* Buscador del explorador (tree_search.js) */
#rmx-tree-search-toggle.active {
    background-color: rgba(13, 110, 253, .18);
    color: var(--rmx-neon-blue, #0d6efd);
}

.rmx-tree-search {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

/* #id + browser-default: esta vista también carga Materialize, cuyo
   input[type=search]:not(.browser-default) le ganaba en especificidad. */
#rmx-tree-search input {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    box-shadow: none;
    height: 30px;
    padding: 0 28px 0 28px;
    font-size: 11px;
    color: #e2e8f0;
    background: rgba(15, 23, 42, .85);
    border: 1px solid var(--rmx-dark-border, #1e293b);
    border-radius: 6px;
    outline: none;
}

#rmx-tree-search input:focus {
    border-color: var(--rmx-neon-blue, #0d6efd);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, .25);
}

/* Sin la "x" nativa de type=search: ya hay un botón propio para limpiar. */
#rmx-tree-search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.rmx-tree-search .rmx-tree-search-icon {
    position: absolute;
    left: 7px;
    top: 7px;
    font-size: 16px;
    color: var(--rmx-dark-text-muted, #64748b);
    pointer-events: none;
}

#rmx-tree-search-clear {
    position: absolute;
    right: 4px;
    top: 5px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--rmx-dark-text-muted, #64748b);
    cursor: pointer;
}

#rmx-tree-search-clear .material-symbols-outlined {
    font-size: 16px;
}

#rmx-tree-search-count {
    width: 100%;
    margin-top: 4px;
    padding-left: 4px;
    font-size: 10px;
    color: var(--rmx-dark-text-muted, #64748b);
}

#rmx-tree-search-count:empty {
    display: none;
}

.rmx-search-hidden {
    display: none !important;
}

.rmx-search-mark {
    padding: 0;
    color: inherit;
    background: rgba(250, 204, 21, .35);
    border-radius: 2px;
}

.rmx-search-empty {
    padding: 8px 6px;
    font-size: 11px;
    color: var(--rmx-dark-text-muted, #64748b);
}

.rmx-tree-view {
    font-family: 'Consolas', 'Fira Code', 'Cascadia Code', Menlo, monospace;
    font-size: 11px;
}

/* Línea moderna de separación entre Pages / Components / Assets / Scripts:
   un degradado sutil en el azul de marca en vez de un simple border-bottom
   plano, para que se sienta parte del tema "tecnología avanzada". */
.rmx-folder-group {
    position: relative;
    padding-bottom: 6px;
    margin-bottom: 6px !important;
}

.rmx-folder-group::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--rmx-neon-blue-glow) 0%, rgba(13, 110, 253, .08) 60%, transparent 100%);
}

.rmx-folder-group:last-child::after {
    display: none;
}

.rmx-folder-toggle {
    color: var(--rmx-dark-text);
    border-radius: 6px;
    transition: color .12s ease, background-color .12s ease;
}

.rmx-folder-toggle:hover {
    background-color: rgba(13, 110, 253, .12);
    color: #fff;
}

.rmx-folder-toggle .folder-icon {
    color: var(--rmx-neon-blue);
    text-shadow: 0 0 6px var(--rmx-neon-blue-glow);
}

.rmx-folder-toggle span:not(.material-symbols-outlined) {
    color: inherit;
}

.rmx-file-item {
    border-radius: 6px;
    color: var(--rmx-dark-text);
    transition: background-color .12s ease;
}

.rmx-file-item:hover {
    background-color: rgba(13, 110, 253, .1);
}

.rmx-file-item.active {
    background-color: rgba(13, 110, 253, .18);
    box-shadow: inset 2px 0 0 var(--rmx-neon-blue);
}

.rmx-file-item .material-symbols-outlined {
    color: var(--rmx-dark-text-muted);
}

.rmx-file-item .text-muted {
    color: var(--rmx-dark-text-muted) !important;
}

/* Botones compactos del explorador (nueva página, subir archivo): outline
   azul neón sutil sobre fondo oscuro en vez del outline-primary claro. */
.rmx-builder-sidebar-left .btn.btn-outline-primary {
    color: var(--rmx-neon-blue);
    border-color: rgba(13, 110, 253, .5);
    background-color: transparent;
}

.rmx-builder-sidebar-left .btn.btn-outline-primary:hover {
    background-color: var(--rmx-neon-blue);
    color: #fff;
    box-shadow: 0 0 10px var(--rmx-neon-blue-glow);
}

/* remoox-ui.css lleva btn-outline-primary al celeste de la marca en todo el
   panel; dentro del editor se mantiene el azul neón también al presionar. */
.rmx-builder-toolbar .btn.btn-outline-primary:not(:disabled):not(.disabled):active,
.rmx-builder-sidebar-left .btn.btn-outline-primary:not(:disabled):not(.disabled):active {
    background-color: var(--rmx-neon-blue, #0d6efd);
    border-color: var(--rmx-neon-blue, #0d6efd);
    color: #fff;
}

/* Menú contextual: mismo tema oscuro, para que no "salte" a un dropdown
   blanco de golpe sobre el explorador oscuro. */
#rmx-context-menu.dropdown-menu {
    background-color: var(--rmx-dark-bg-alt);
    border: 1px solid var(--rmx-dark-border);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}

#rmx-context-menu .dropdown-item {
    color: var(--rmx-dark-text);
}

#rmx-context-menu .dropdown-item:hover {
    background-color: rgba(13, 110, 253, .15);
    color: #fff;
}

#rmx-context-menu .dropdown-item.disabled {
    color: var(--rmx-dark-text-muted) !important;
    pointer-events: none;
}

#rmx-context-menu .dropdown-header {
    color: var(--rmx-dark-text-muted);
}

#rmx-context-menu .dropdown-divider {
    border-top-color: var(--rmx-dark-border);
}

/* Scrollbar delgado y oscuro, look de editor de código */
.rmx-builder-sidebar-left ::-webkit-scrollbar {
    width: 8px;
}

.rmx-builder-sidebar-left ::-webkit-scrollbar-track {
    background: transparent;
}

.rmx-builder-sidebar-left ::-webkit-scrollbar-thumb {
    background-color: #263041;
    border-radius: 4px;
}

.rmx-builder-sidebar-left ::-webkit-scrollbar-thumb:hover {
    background-color: var(--rmx-neon-blue);
}

/* ==========================================================================
   Chat con el Asistente de IA — tema oscuro "robótico" con acentos en el
   azul de marca REMOOX (mismo --rmx-neon-blue / #0d6efd usado en el
   Explorador), reutilizable en el índice del CMS Builder y como pestaña
   dentro de crear/editar página.
   ========================================================================== */
.rmx-ai-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: radial-gradient(circle at 20% 0%, rgba(13, 110, 253, .10) 0%, transparent 45%), var(--rmx-dark-bg, #0b0f19);
    color: var(--rmx-dark-text, #cbd5e1);
    font-family: var(--rmx-font-family);
}

.rmx-ai-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.rmx-ai-chat-empty {
    margin: auto;
    text-align: center;
    max-width: 340px;
    color: var(--rmx-dark-text-muted, #64748b);
}

.rmx-ai-chat-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 110, 253, .12);
    box-shadow: 0 0 0 1px rgba(13, 110, 253, .35), 0 0 24px rgba(13, 110, 253, .35);
}

.rmx-ai-chat-empty-icon .material-symbols-outlined {
    font-size: 28px;
    color: var(--rmx-neon-blue, #0d6efd);
}

.rmx-ai-chat-empty h3 {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 6px;
}

.rmx-ai-chat-empty p {
    font-size: 12px;
    line-height: 1.6;
    margin: 0;
}

.rmx-ai-chat-msg {
    display: flex;
    gap: 10px;
    max-width: 78%;
    align-items: flex-end;
}

.rmx-ai-chat-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.rmx-ai-chat-msg-assistant {
    align-self: flex-start;
}

.rmx-ai-chat-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 110, 253, .15);
    box-shadow: 0 0 0 1px rgba(13, 110, 253, .4);
}

.rmx-ai-chat-avatar .material-symbols-outlined {
    font-size: 15px;
    color: var(--rmx-neon-blue, #0d6efd);
}

.rmx-ai-chat-msg-user .rmx-ai-chat-avatar {
    background: rgba(255, 255, 255, .08);
    box-shadow: none;
}

.rmx-ai-chat-msg-user .rmx-ai-chat-avatar .material-symbols-outlined {
    color: #cbd5e1;
}

.rmx-ai-chat-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.rmx-ai-chat-msg-user .rmx-ai-chat-bubble {
    background: var(--rmx-neon-blue, #0d6efd);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 0 14px rgba(13, 110, 253, .35);
}

.rmx-ai-chat-msg-assistant .rmx-ai-chat-bubble {
    background: var(--rmx-dark-bg-alt, #10151f);
    border: 1px solid var(--rmx-dark-border, #1c2333);
    border-bottom-left-radius: 4px;
}

.rmx-ai-chat-bubble p {
    margin: 0 0 8px 0;
}

.rmx-ai-chat-bubble p:last-child {
    margin-bottom: 0;
}

/* Bloque de código HTML que el asistente propone insertar: se muestra
   aparte del texto normal, con su propio botón de acción. */
.rmx-ai-chat-code-block {
    margin: 8px 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--rmx-dark-border, #1c2333);
    background: var(--rmx-dark-bg, #0b0f19);
}

.rmx-ai-chat-code-block pre {
    margin: 0;
    padding: 10px 12px;
    max-height: 220px;
    overflow: auto;
    font-family: 'Consolas', 'Fira Code', Menlo, monospace;
    font-size: 11px;
    color: #94a3b8;
    white-space: pre-wrap;
    word-break: break-word;
}

.rmx-ai-chat-insert-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-top: 1px solid var(--rmx-dark-border, #1c2333);
    background: rgba(13, 110, 253, .12);
    color: var(--rmx-neon-blue, #0d6efd);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.rmx-ai-chat-insert-btn .material-symbols-outlined {
    font-size: 16px;
}

.rmx-ai-chat-insert-btn:hover {
    background: rgba(13, 110, 253, .22);
    color: var(--rmx-neon-blue, #0d6efd);
}

.rmx-ai-chat-insert-btn:disabled {
    opacity: .6;
    cursor: default;
}

/* Botón único al final del mensaje que inserta/actualiza a la vez el
   lienzo + Estilos CSS + JavaScript/Lógica (ver appendCombinedInsertButton
   en ai_chat.js). Reutiliza la tarjeta de .rmx-ai-chat-code-block pero sin
   <pre> arriba, así que no necesita el borde superior del botón. */
.rmx-ai-chat-insert-all .rmx-ai-chat-insert-btn {
    border-top: none;
}

.rmx-ai-chat-truncated-notice {
    margin-top: 6px !important;
    font-size: 11px;
    color: #f0ad4e;
}

.rmx-ai-chat-typing .rmx-ai-chat-bubble span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rmx-neon-blue, #0d6efd);
    margin-right: 4px;
    animation: rmx-ai-typing 1.2s infinite ease-in-out;
}

.rmx-ai-chat-typing .rmx-ai-chat-bubble span:nth-child(2) {
    animation-delay: .2s;
}

.rmx-ai-chat-typing .rmx-ai-chat-bubble span:nth-child(3) {
    animation-delay: .4s;
    margin-right: 0;
}

@keyframes rmx-ai-typing {

    0%,
    60%,
    100% {
        opacity: .3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.rmx-ai-chat-typing-label {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--rmx-text-muted, #8792a6);
}

/* display:grid en vez de flex: con flexbox, cualquier CSS ajeno que le
   fuerce al <textarea> un ancho intrínseco/porcentual (Materialize,
   Bootstrap 4.5.2 y 5.2.1 se cargan a la vez en esta vista) puede hacer que
   el botón de enviar "no quepa" y caiga a una segunda línea. Con grid y
   columnas fijas (1fr auto) el botón SIEMPRE ocupa la segunda columna, sin
   importar qué ancho pida el textarea. */
.rmx-ai-chat-input-bar {
    flex-shrink: 0;
    display: grid !important;
    grid-template-columns: 1fr 40px !important;
    align-items: end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--rmx-dark-border, #1c2333);
    background: var(--rmx-dark-bg, #0b0f19);
    width: 100%;
    box-sizing: border-box;
}

.rmx-ai-chat-textarea {
    grid-column: 1;
    width: 100% !important;
    min-width: 0;
    resize: none;
    max-height: 140px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--rmx-dark-border, #1c2333);
    background: var(--rmx-dark-bg-alt, #10151f);
    color: #e2e8f0;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.rmx-ai-chat-textarea:focus {
    border-color: var(--rmx-neon-blue, #0d6efd);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .2);
}

.rmx-ai-chat-textarea::placeholder {
    color: var(--rmx-dark-text-muted, #64748b);
}

.rmx-ai-chat-send-btn {
    grid-column: 2;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50%;
    border: none;
    background: var(--rmx-neon-blue, #0d6efd);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 14px rgba(13, 110, 253, .5);
    transition: transform .1s ease;
}

.rmx-ai-chat-send-btn:hover {
    transform: scale(1.06);
}

.rmx-ai-chat-send-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

@media (max-width: 768px) {
    .rmx-ai-chat-msg {
        max-width: 92%;
    }

    .rmx-ai-chat-messages {
        padding: 14px;
    }

    .rmx-ai-chat-input-bar {
        padding: 10px 14px;
    }
}