/* --- Pantalla de Carga --- */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f4ff 50%, #f0f9ff 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    font-family: 'DM Sans', Arial, sans-serif;
    transition: opacity 0.5s ease-out;
}

#loading-screen.fade-out {
    opacity: 0;
}

.loading-container {
    text-align: center;
    max-width: 380px;
    padding: 20px;
}

.loading-logo {
    margin-bottom: 25px;
}

.loading-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary, #0071bc), var(--secondary, #29abe2));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    box-shadow: 0 8px 25px rgba(0, 113, 188, 0.25);
    animation: pulse-icon 2s ease-in-out infinite;
}

.loading-icon i {
    font-size: 2rem;
    color: white;
}

@keyframes pulse-icon {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 25px rgba(0, 113, 188, 0.25);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 35px rgba(0, 113, 188, 0.35);
    }
}

.loading-logo h1 {
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 2rem;
    color: var(--primary, #0071bc);
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 113, 188, 0.1);
}

.loading-subtitle {
    font-size: 0.95rem;
    color: var(--dark, #1a3a53);
    margin-bottom: 0;
    opacity: 0.8;
    line-height: 1.3;
}

.loading-progress {
    margin-bottom: 25px;
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 15px;
}

.loading-dot {
    width: 10px;
    height: 10px;
    background: var(--primary, #0071bc);
    border-radius: 50%;
    animation: loading-bounce 1.4s ease-in-out infinite both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }
.loading-dot:nth-child(3) { animation-delay: 0s; }

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

#loading-text {
    font-size: 0.9rem;
    color: var(--dark, #1a3a53);
    margin: 0;
    font-weight: 500;
    opacity: 0.9;
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0.9;
}

.loading-step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--gray, #6c757d);
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    transition: all 0.4s ease;
    border: 1px solid transparent;
}

.loading-step i:first-child {
    width: 16px;
    text-align: center;
    color: var(--secondary, #29abe2);
    margin-right: 6px;
    font-size: 0.9rem;
}

.loading-step span {
    flex: 1;
    text-align: left;
}

.step-status {
    display: flex;
    align-items: center;
    min-width: 20px;
    justify-content: center;
}

.step-status i {
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

/* Estados de los pasos */
.loading-step.step-pending {
    opacity: 0.6;
}

.loading-step.step-pending .step-pending {
    color: var(--gray, #6c757d);
}

.loading-step.step-active {
    background: rgba(0, 113, 188, 0.08);
    border-color: var(--primary, #0071bc);
    opacity: 1;
    transform: scale(1.01);
    box-shadow: 0 2px 10px rgba(0, 113, 188, 0.15);
}

.loading-step.step-active .step-active {
    color: var(--primary, #0071bc);
}

.loading-step.step-completed {
    background: rgba(40, 167, 69, 0.08);
    border-color: var(--success, #28a745);
    opacity: 1;
}

.loading-step.step-completed .step-completed {
    color: var(--success, #28a745);
}

.loading-step.step-error {
    background: rgba(220, 53, 69, 0.08);
    border-color: #dc3545;
    opacity: 1;
}

.loading-step.step-error .step-error {
    color: #dc3545;
}

.loading-step:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateX(3px);
}

.loading-step.step-active:hover {
    transform: scale(1.01) translateX(3px);
}

/* Animación adicional para la pantalla de carga */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInStagger {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading-container {
    animation: slideInUp 0.6s ease-out;
}

/* Animación escalonada para los pasos */
.loading-step:nth-child(1) {
    animation: fadeInStagger 0.6s ease-out 0.2s both;
}

.loading-step:nth-child(2) {
    animation: fadeInStagger 0.6s ease-out 0.4s both;
}

.loading-step:nth-child(3) {
    animation: fadeInStagger 0.6s ease-out 0.6s both;
}

/* Efecto de shimmer en la carga */
@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.loading-step.step-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    background-size: 200px 100%;
    animation: shimmer 2s infinite;
    border-radius: 10px;
    pointer-events: none;
}

.loading-step {
    position: relative;
    overflow: hidden;
}

/* Mejora del ícono principal con efecto de respiración */
@keyframes breathe {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

.loading-icon {
    animation: breathe 3s ease-in-out infinite;
}

/* Efecto de ondas en el fondo */
#loading-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(0, 113, 188, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(41, 171, 226, 0.1) 0%, transparent 50%);
    animation: float 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Mensaje especial para primera ejecución */
.first-run-info {
    margin-top: 20px;
    padding: 10px 16px;
    background: rgba(0, 113, 188, 0.08);
    border: 1px solid rgba(0, 113, 188, 0.15);
    border-radius: 8px;
    text-align: center;
}

.first-run-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--primary, #0071bc);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.3;
}

.first-run-info i {
    color: var(--secondary, #29abe2);
    font-size: 0.85rem;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .loading-container {
        padding: 15px;
        max-width: 280px;
    }
    
    .loading-logo h1 {
        font-size: 1.6rem;
    }
    
    .loading-subtitle {
        font-size: 0.85rem;
    }
    
    .loading-icon {
        width: 50px;
        height: 50px;
        margin-bottom: 12px;
    }
    
    .loading-icon i {
        font-size: 1.6rem;
    }
    
    .loading-step {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .loading-step i:first-child {
        font-size: 0.85rem;
        width: 14px;
    }
    
    .step-status i {
        font-size: 0.85rem;
    }
    
    .first-run-info {
        margin-top: 15px;
        padding: 8px 12px;
    }
    
    .first-run-info p {
        font-size: 0.75rem;
        flex-direction: column;
        gap: 4px;
    }
    
    .loading-dots {
        gap: 5px;
        margin-bottom: 12px;
    }
    
    .loading-dot {
        width: 8px;
        height: 8px;
    }
    
    #loading-text {
        font-size: 0.85rem;
    }
}

/* Para pantallas muy pequeñas */
@media (max-width: 480px) {
    .loading-container {
        padding: 12px;
        max-width: 260px;
    }
    
    .loading-logo {
        margin-bottom: 20px;
    }
    
    .loading-progress {
        margin-bottom: 20px;
    }
    
    .loading-logo h1 {
        font-size: 1.4rem;
    }
    
    .loading-subtitle {
        font-size: 0.8rem;
    }
}

/* Para pantallas en landscape en móviles */
@media (max-height: 600px) and (orientation: landscape) {
    .loading-container {
        padding: 10px;
        max-width: 350px;
    }
    
    .loading-logo {
        margin-bottom: 15px;
    }
    
    .loading-progress {
        margin-bottom: 15px;
    }
    
    .loading-logo h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .loading-icon {
        width: 45px;
        height: 45px;
        margin-bottom: 10px;
    }
    
    .loading-icon i {
        font-size: 1.4rem;
    }
    
    .loading-steps {
        gap: 6px;
    }
    
    .loading-step {
        padding: 6px 12px;
    }
    
    .first-run-info {
        margin-top: 10px;
        padding: 6px 10px;
    }
}

/* --- Modal de Validación de Errores --- */
.validation-errors-modal {
    max-height: 60vh;
    overflow: auto;
    padding: 0.5em 1.2em 1.2em 1.2em;
    background: #f8fdff;
}

.validation-error-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0.2em;
}

.validation-error-group {
    margin-bottom: 0.18em;
}

.validation-error-group-label {
    font-weight: 600;
    color: #222;
    font-size: 1.08em;
    display: block;
    margin-bottom: 0.08em;
}

.validation-error-sublist {
    margin-left: 10px;
    list-style: disc;
    color: #b00020;
    padding-left: 14px;
}

.validation-error-item {
    margin-bottom: 0.08em;
}

.validation-error-link {
    color: #b00020;
    text-decoration: underline dotted;
    font-size: 1em;
    cursor: pointer;
    transition: color 0.18s;
}
.validation-error-link:hover {
    color: #e06c75;
}
/* --- Botones del Modal de Código JSON --- */
.modal-toolbar-section .modal-btn {
    background: #f8fdff;
    border: 1px solid #cdd5e0;
    border-radius: 6px;
    font-family: 'DM Sans', Arial, sans-serif;
    font-size: 0.97rem;
    font-weight: 500;
    color: var(--primary, #0071bc);
    padding: 7px 13px;
    margin-left: 0;
    margin-right: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    box-shadow: none;
    transition: background 0.18s, color 0.18s, border 0.18s;
}

.modal-toolbar-section .modal-btn i {
    font-size: 1em;
    color: var(--primary, #0071bc);
    transition: color 0.18s;
}

.modal-toolbar-section .modal-btn:hover {
    background: #e0f4ff;
    color: var(--secondary, #ff6b35);
    border-color: #a0aec0;
}

.modal-toolbar-section .modal-btn:hover i {
    color: var(--secondary, #ff6b35);
}

/* --- Estilos para el código JSON en el modal --- */
#json-modal pre {
    margin: 0;
    max-height: 60vh;
    overflow: auto;
    background: #282c34;
    color: #abb2bf;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.97rem;
    white-space: pre;
}

#json-modal code {
    display: block;
    width: 100%;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    white-space: pre;
}

/* --- Modal para código JSON --- */
#json-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    align-items: center;
    justify-content: center;
    background: none;
}

#json-modal .modal-backdrop {
    position: absolute;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.32);
    z-index: 1;
}

#json-modal .modal-content {
    position: relative;
    z-index: 2;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    max-width: 700px;
    min-width: 320px;
    width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'DM Sans', Arial, sans-serif;
}

#json-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 10px 20px;
    border-bottom: 1px solid #e0e6ed;
    background: #f8fdff;
}

#json-modal .modal-title {
    font-size: 1.18rem;
    font-weight: 700;
    color: var(--primary, #0071bc);
}

#json-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: #b0b8c1;
    cursor: pointer;
    padding: 0 6px;
    transition: color 0.18s;
}

#json-modal .modal-close:hover {
    color: #e06c75;
}

#json-modal .modal-body {
    padding: 18px 22px 18px 22px;
    overflow: auto;
    font-size: 1.01rem;
    background: #f8fdff;
}

/* Fuerza alineación superior y bloque para la navegación y su lista */
.sidebar-nav,
.sidebar-nav-list {
    display: block !important;
    align-items: initial !important;
    justify-content: flex-start !important;
    height: auto;
    margin: 0;
    padding: 0;
}

.sidebar-nav-list>li {
    display: block;
    margin: 0;
    padding: 0;
}

/* --- Tipografías de Marca --- */
@font-face {
    font-family: 'DM Sans';
    src: url('./../../media/fonts/dm-sans.woff2') format('woff2'),
        url('./../../media/fonts/dm-sans.ttf') format('truetype');
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: 'Sora';
    src: url('./../../media/fonts/sora.woff2') format('woff2'),
        url('./../../media/fonts/sora.ttf') format('truetype');
    font-weight: 100 900;
    font-display: swap;
}

/* Estilos Generales del Editor */
.editor-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    font-family: 'DM Sans', Arial, sans-serif;
    background-color: #f4f7fa;
    align-items: stretch;
}


/* --- Barra Lateral --- */
.editor-sidebar {
    width: 300px;
    background-color: #ffffff;
    border-right: 1px solid #e0e6ed;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 10;
    align-items: stretch;
    justify-content: flex-start;
    font-size: 0.93rem;
    margin-left: 0;
    opacity: 1;
    transition: margin-left 0.32s cubic-bezier(.4, 1.3, .5, 1), opacity 0.25s;
}

.sidebar-collapse-btn {
    transition: background 0.18s, color 0.18s, border 0.18s;
    cursor: pointer;
    padding: 4px 9px;
    font-size: 0.89rem;
    background: #f2f3f5;
    border: 1px solid #cdd5e0;
    border-radius: 6px;
    min-width: 0;
    height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--primary, #0071bc);
    box-shadow: none;
}

.sidebar-collapse-btn:hover {
    background: #e0e6ed;
}

.sidebar-expand-btn {
    position: static;
    margin-right: 8px;
    margin-left: 0;
    top: 0;
    left: 0;
    z-index: 30;
    background: transparent;
    border: 1px solid #cdd5e0;
    border-radius: 6px;
    min-width: 0;
    height: 38px;
    padding: 7px 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'DM Sans', Arial, sans-serif;
    font-weight: 500;
    font-size: 0.97rem;
    color: var(--primary, #0071bc);
    box-shadow: none;
    transition: background 0.18s, color 0.18s, border 0.18s;
    cursor: pointer;
}

.sidebar-expand-btn i {
    font-size: 1em;
    color: var(--primary, #0071bc);
    transition: color 0.18s;
}

.sidebar-expand-btn:hover {
    background: #f0f4f8;
    color: var(--primary, #0071bc);
    border-color: #a0aec0;
}

.sidebar-expand-btn:hover i {
    color: var(--secondary, #ff6b35);
}

.sidebar-expand-label {
    display: inline;
    font-size: 0.89rem;
    font-weight: 500;
    color: var(--primary, #0071bc);
    margin-left: 4px;
}

.sidebar-header {
    padding: 0 20px;
    background: #f2f3f5;
    border-bottom: 1px solid #e0e6ed;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 70px;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px 0 10px 0;
    min-height: 0;
    max-height: none;
    background: #f2f3f5;
}

/* Navegación anidada y compacta */
.sidebar-nav-list {
    list-style: none;
    margin: 0;
    padding-left: 0;
}

.sidebar-nav-item {
    margin: 0;
    padding: 0;
}

.sidebar-nav-group {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.98em;
    padding: 2px 8px 2px 18px;
    display: block;
    cursor: default;
    margin-bottom: 2px;
}

.sidebar-nav-sublist {
    list-style: none;
    margin: 0 0 0 10px;
    padding-left: 10px;
    border-left: 1px dashed #e0e6ed;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px 2px 18px;
    font-size: 0.93em;
    color: var(--dark);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.sidebar-nav-link:hover {
    background: #eef5ff;
    color: var(--primary);
}

.sidebar-nav-link i {
    font-size: 1em;
    color: #b0b8c1;
}

.sidebar-nav-item .sidebar-nav-link.active {
    background: #e0ecff;
    color: var(--primary);
    font-weight: 700;
}

.sidebar-nav-item.collapsible>.sidebar-nav-link {
    font-weight: 700;
}

.sidebar-nav-toggle {
    margin-right: 2px;
    color: #b0b8c1;
    font-size: 1em;
    transition: transform 0.2s;
}

.sidebar-nav-children {
    margin-left: 10px;
    border-left: 1px dashed #e0e6ed;
    padding-left: 6px;
}

.sidebar-nav-empty {
    color: #b0b8c1;
    font-size: 0.95em;
    padding: 10px 0 0 18px;
    display: block;
}

.sidebar-nav-list a[data-path] {
    display: block;
    padding: 2px 8px 2px 18px;
    color: var(--dark);
    text-decoration: none;
    font-size: 0.93em;
    border-radius: 4px;
    transition: background 0.15s;
}

.sidebar-nav-list a[data-path]:hover {
    background: #eef5ff;
    color: var(--primary);
}

.sidebar-nav-list a[data-path].active {
    background: #e0ecff;
    color: var(--primary);
    font-weight: 700;
}


.sidebar-footer {
    padding: 8px 20px;
    border-top: 1px solid #e0e6ed;
    flex-shrink: 0;
    height: 40px;
    display: flex;
    align-items: center;
}

.sidebar-footer a {
    color: var(--gray);
    text-decoration: none;
    font-weight: 500;
}

.sidebar-footer a:hover {
    color: var(--primary);
}


/* --- Contenido Principal --- */
.editor-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Barra de Herramientas --- */

/* --- Barra de Herramientas (Header) --- */
/* Header principal: columna, sticky-header abajo */
.editor-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 4px;
    background: #f2f3f5;
    border-bottom: 1.5px solid #e0e6ed;
    box-shadow: 0 2px 18px rgba(0, 113, 188, 0.07);
    font-family: 'Sora', 'DM Sans', Arial, sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
    flex-shrink: 0;
    /* position: static; */
    position: static;
    width: 100%;
    z-index: 20;
    transition: background 0.3s, box-shadow 0.3s, margin-left 0.32s cubic-bezier(.4, 1.3, .5, 1);
    box-sizing: border-box;
}

/* Fila horizontal para los botones y vistas */
.toolbar-flex-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0;
}

.editor-toolbar>.toolbar-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px 14px 18px;
    background: transparent;
}

.editor-toolbar>.toolbar-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px 14px 18px;
    background: transparent;
}

#sticky-header {
    position: static;
    background: #f2f3f5;
    backdrop-filter: blur(10px);
    padding: 10px 30px;
    border-bottom: 1px solid #e0e6ed;
    z-index: 15;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #333;
    min-height: 45px;
    box-sizing: border-box;
    transition: none;
}

.toolbar-section {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.editor-toolbar button {
    background: #FFFFFF;
    border: 1px solid #cdd5e0;
    border-radius: 5px;
    padding: 4px 9px;
    cursor: pointer;
    font-family: 'DM Sans', Arial, sans-serif;
    font-weight: 500;
    font-size: 0.89rem;
    color: var(--primary, #0071bc);
    box-shadow: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.18s, color 0.18s, border 0.18s;
    min-height: 28px;
}

.editor-toolbar button i {
    font-size: 1em;
    color: var(--secondary, #ff6b35);
    transition: color 0.18s;
}

.editor-toolbar button:hover {
    background: #f0f4f8;
    color: var(--primary, #0071bc);
    border-color: #a0aec0;
    box-shadow: none;
}

.editor-toolbar button:hover i {
    color: var(--primary, #0071bc);
}

.editor-toolbar button.btn-primary {
    background: var(--primary, #0071bc);
    color: #fff;
    border: none;
    box-shadow: none;
}

.editor-toolbar button.btn-primary:hover {
    background: var(--secondary, #ff6b35);
    color: #fff;
    border: none;
    box-shadow: none;
}

/* --- Botones de Vista (Formulario/Código) --- */
.view-btn {
    background: transparent;
    color: var(--primary, #0071bc);
    border: 1px solid #cdd5e0;
    border-radius: 5px;
    padding: 4px 9px;
    cursor: pointer;
    font-family: 'DM Sans', Arial, sans-serif;
    font-weight: 500;
    font-size: 0.89rem;
    box-shadow: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.18s, color 0.18s, border 0.18s;
    min-height: 28px;
}

.view-btn i {
    color: var(--primary, #0071bc);
    transition: color 0.18s;
}

.view-btn:hover {
    background: #f0f4f8;
    color: var(--primary, #0071bc);
    border-color: #a0aec0;
}

.view-btn:hover i {
    color: var(--secondary, #ff6b35);
}

.view-btn.active {
    background: var(--secondary, #ff6b35);
    color: #fff;
    border-color: var(--secondary, #ff6b35);
    box-shadow: none;
}

.view-btn.active i {
    color: #fff;
}


/* --- Área de Trabajo --- */
.editor-workspace {
    flex-grow: 1;
    overflow-y: auto;
    position: static;
    background: #f8f9fa;
    padding: 30px;
    border-bottom: 1px solid #e0e6ed;
    z-index: 15;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.81rem;
    color: #333;
    min-height: 28px;
    box-sizing: border-box;
    transition: top 0.3s;
}

.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
}

/* --- Vista de Formulario --- */
.rips-form {
    max-width: 900px;
    margin: 0 auto;
}

.rips-form h2 {
    font-size: 2.1rem;
    color: var(--dark);
    margin-bottom: 25px;
    border-bottom: 2px solid var(--secondary);
    padding-bottom: 10px;
    font-family: 'Sora', 'DM Sans', Arial, sans-serif;
    font-weight: 800;
    letter-spacing: 0.01em;
}

/* Centrado específico para el título del formulario */
#form-title {
    text-align: center !important;
    display: table;
    margin: 0 auto 25px auto;
    padding-bottom: 10px;
    width: auto;
}

fieldset {
    border: 1px solid #dcdfe3;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    background-color: #ffffff;
}

legend {
    font-family: 'Sora', 'DM Sans', Arial, sans-serif;
    font-weight: 800;
    color: var(--primary);
    padding: 0 10px;
    font-size: 1.2rem;
    letter-spacing: 0.01em;
}

/* Título de bienvenida con Sora Ultrabold */
.welcome-screen h2 {
    font-size: 2.2rem;
    color: var(--primary);
    margin-bottom: 10px;
    font-family: 'Sora', 'DM Sans', Arial, sans-serif;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
    display: flex;
    align-items: center;
}

.form-group label .required-asterisk {
    color: #dc3545;
    margin-left: 4px;
}

.form-group input,
.form-group select {
    padding: 10px;
    border: 1px solid #cdd5e0;
    border-radius: 6px;
    font-size: 1rem;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 113, 188, 0.2);
}

.form-group input.invalid,
.form-group select.invalid {
    border-color: #dc3545;
    background-color: #fff5f5;
}

/* Estilos para elementos de array (múltiples usuarios, consultas, etc.) */
.array-item {
    border: 1px dashed #a0aec0;
    padding: 15px;
    margin-top: 15px;
    border-radius: 8px;
    position: relative;
    background-color: #fafbfd;
}

.remove-item-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #fce8e6;
    color: #dc3545;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-weight: bold;
}

.add-item-btn {
    background-color: #e6f7ff;
    color: var(--primary);
    border: 1px dashed var(--primary);
    padding: 10px 15px;
    width: 100%;
    margin-top: 10px;
    cursor: pointer;
    font-weight: 600;
}


/* --- Vista de Código --- */
#code-view {
    height: 100%;
}

#code-output {
    display: block;
    width: 100%;
    height: calc(100vh - 150px);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    background-color: #282c34;
    color: #abb2bf;
    border: none;
    padding: 15px;
    border-radius: 8px;
    outline: none;
    white-space: pre;
    overflow: auto;
}

.token.key {
    color: #e06c75;
}

.token.string {
    color: #98c379;
}

.token.number {
    color: #d19a66;
}

.token.boolean {
    color: #56b6c2;
}

.token.null {
    color: #c678dd;
}

.token.punctuation {
    color: #abb2bf;
}

.token.error {
    background-color: rgba(220, 53, 69, 0.3);
    text-decoration: underline wavy red;
}

/* --- Barra de Estado --- */
.editor-statusbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background-color: #323a45;
    color: #ffffff;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator.valid {
    color: #a3e9a4;
}

.status-indicator.invalid {
    color: #f8b4b4;
}

/* --- Contenedor de información de archivo --- */
.file-info-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.file-info-text {
    font-size: 0.85rem;
    color: #ffffff;
}

.filename-pin-btn {
    background: none;
    border: 1px solid #4a545e;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #adb5bd;
    transition: all 0.2s;
    min-width: 28px;
    height: 24px;
}

.filename-pin-btn:hover {
    background: #4a545e;
    border-color: #6c757d;
    color: #ffffff;
}

.filename-pin-btn.pinned {
    background: var(--primary, #0071bc);
    color: white;
    border-color: var(--primary, #0071bc);
    transform: rotate(45deg);
}

.filename-pin-btn.pinned:hover {
    background: var(--secondary, #29abe2);
}

.filename-input {
    background: #2c3338;
    border: 1px solid #4a545e;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85rem;
    color: #ffffff;
    outline: none;
    min-width: 200px;
    max-width: 300px;
}

.filename-input:focus {
    border-color: var(--primary, #0071bc);
    box-shadow: 0 0 0 2px rgba(0, 113, 188, 0.3);
}

.filename-input::placeholder {
    color: #6c757d;
}


/* --- Media Queries para Responsividad --- */

/* --- Encabezado de Jerarquía --- */
#sticky-header {
    position: sticky;
    top: 78px;
    /* Igual que el margin-top de .editor-workspace */
    background: #f2f3f5;
    backdrop-filter: blur(10px);
    padding: 5px 16px;
    border-bottom: 1px solid #e0e6ed;
    z-index: 15;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    font-size: 0.81rem;
    color: #333;
    min-height: 28px;
    box-sizing: border-box;
    transition: top 0.3s;
}

#sticky-header .breadcrumb-item {
    display: flex;
    align-items: center;
    color: var(--primary);
    font-weight: 600;
}

#sticky-header .breadcrumb-separator {
    margin: 0 8px;
    color: #a0aec0;
}

#sticky-header .breadcrumb-item:last-child {
    color: var(--dark);
    font-weight: 700;
}

@media (max-width: 900px) {
    .editor-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 6px 10px 6px;
        position: static;
        width: 100%;
    }

    .toolbar-section {
        flex-wrap: wrap;
        gap: 8px;
    }

    .editor-workspace {
        padding: 5px 16px;
    }

    .array-item {
        padding: 5px;
    }

    fieldset {
        padding: 5px;
    }
}

/* Estilos para menú desplegable en móviles */
@media (max-width: 768px) {
    .editor-toolbar {
        position: relative;
        padding: 8px 12px;
    }

    .toolbar-flex-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
    }

    .toolbar-section {
        width: 100%;
        position: relative;
        overflow: hidden;
        max-height: 48px;
        transition: max-height 0.3s ease-in-out;
        padding: 0 16px;
        box-sizing: border-box;
    }

    .toolbar-section.expanded {
        max-height: 280px;
    }

    .toolbar-section::before {
        content: '☰ Herramientas';
        display: block;
        background: #f8f9fa;
        color: var(--primary, #0071bc);
        border: 1px solid #dee2e6;
        padding: 8px 12px;
        margin: 0 0 8px 0;
        cursor: pointer;
        font-weight: 500;
        font-size: 0.85rem;
        border-radius: 4px;
        transition: all 0.2s;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .toolbar-section:hover::before {
        background: #e9ecef;
        border-color: #adb5bd;
    }

    .toolbar-section.expanded::before {
        content: '✕ Cerrar herramientas';
        background: #e9ecef;
        color: #6c757d;
        border-color: #adb5bd;
    }

    .editor-toolbar button {
        min-width: 120px;
        margin-bottom: 8px;
        justify-content: flex-start;
        gap: 8px;
    }

    .editor-toolbar button i {
        min-width: 16px;
    }

    /* Ocultar botones por defecto, mostrar solo cuando está expandido */
    .toolbar-section > *:not(.mobile-menu-toggle):not(.sidebar-expand-btn) {
        opacity: 0;
        transform: translateY(-10px);
        transition: opacity 0.2s, transform 0.2s;
        pointer-events: none;
    }

    .toolbar-section.expanded > *:not(.mobile-menu-toggle):not(.sidebar-expand-btn) {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    /* El botón de expandir sidebar siempre debe estar visible */
    .toolbar-section .sidebar-expand-btn {
        opacity: 1 !important;
        transform: translateY(0) !important;
        pointer-events: auto !important;
    }

    /* Ajustes para la barra lateral colapsada en móviles */
    body.sidebar-collapsed .editor-main {
        margin-left: 0;
    }

    body.sidebar-collapsed .editor-toolbar {
        margin-left: 0;
    }

    /* Botón de expandir sidebar más prominente en móviles */
    .sidebar-expand-btn {
        background: #f8f9fa;
        color: var(--primary, #0071bc);
        padding: 10px 14px;
        border: 1px solid #dee2e6;
        border-radius: 6px;
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        min-width: 120px;
        justify-content: flex-start;
        gap: 8px;
        transition: all 0.2s ease;
    }

    .sidebar-expand-btn:hover {
        background: #e9ecef;
        border-color: #adb5bd;
        transform: none;
    }

    .sidebar-expand-btn i {
        min-width: 16px;
        color: var(--primary, #0071bc);
    }

    .sidebar-expand-btn .sidebar-expand-label {
        display: inline !important;
        margin-left: 4px;
        color: var(--primary, #0071bc);
    }

    /* Mejoras adicionales para formularios en móviles */
    .rips-form {
        padding: 8px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* Evita zoom en iOS */
        padding: 12px;
        min-height: 44px; /* Tamaño mínimo táctil */
    }

    .array-item {
        padding: 12px;
        margin-bottom: 16px;
    }

    .array-block-title {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .remove-item-btn {
        min-width: 44px;
        min-height: 44px;
        font-size: 1.2rem;
    }

    .add-item-btn {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 0.95rem;
    }

    /* Ajustes para el workspace */
    .editor-workspace {
        padding: 8px;
    }

    .welcome-screen {
        padding: 24px 16px;
        text-align: center;
    }

    .welcome-screen h2 {
        font-size: 1.4rem;
        margin-bottom: 12px;
    }

    .welcome-screen p {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    /* Mejoras para la barra de estado en móviles */
    .editor-statusbar {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        padding: 12px;
        min-height: auto;
        text-align: center;
    }

    .status-indicator {
        justify-content: center;
        width: auto;
    }

    .file-info-container {
        justify-content: center;
        width: 100%;
    }

    .filename-input {
        font-size: 16px; /* Evita zoom en iOS */
    }
}

/* Estilos para dispositivos muy pequeños */
@media (max-width: 480px) {
    .editor-toolbar {
        padding: 6px 8px;
    }

    .toolbar-section {
        padding: 0 12px;
    }

    .toolbar-section::before {
        font-size: 0.8rem;
        padding: 6px 10px;
        margin: 0 0 6px 0;
    }

    .editor-toolbar button {
        min-width: 100px;
        font-size: 0.85rem;
        padding: 10px 12px;
    }

    .sidebar-expand-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-width: 100px;
    }

    .sidebar-expand-btn .sidebar-expand-label {
        display: none !important; /* Ocultar texto en pantallas muy pequeñas */
    }

    .rips-form {
        padding: 6px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .array-item {
        padding: 8px;
        margin-bottom: 12px;
    }

    .array-block-title {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .welcome-screen {
        padding: 16px 12px;
    }

    .welcome-screen h2 {
        font-size: 1.2rem;
    }

    .welcome-screen i {
        font-size: 2rem;
        margin-bottom: 12px;
    }

    .editor-statusbar {
        padding: 8px;
    }
}

/* Estilo para campos de formulario con errores de validación */
.form-group .invalid-field, .invalid-field {
    border-color: #dc3545 !important; /* Fuerte para anular otros estilos */
    box-shadow: 0 0 0 0 #dc3545;
}

/* Estilo para items en la navegación lateral que contienen errores */
.sidebar-nav-list .invalid-nav-item > a {
    padding-right: 10px;
    position: relative;
}

/* Punto rojo para el elemento específico con error */
.sidebar-nav-list .invalid-nav-item > a::after {
    content: '';
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background-color: #dc3545;
    border-radius: 50%;
}

/* Cambia el color del ícono de despliegue para contenedores con errores */
.invalid-nav-container > .sidebar-nav-toggle-group .sidebar-nav-toggle {
    color: #dc3545 !important;
}

/* Punto rojo para contenedores colapsados que ocultan un error */
.has-hidden-error > .sidebar-nav-toggle-group {
    position: relative;
    padding-right: 10px;
}

.has-hidden-error > .sidebar-nav-toggle-group::after {
    content: '';
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background-color: #dc3545;
    border-radius: 50%;
}

/* --- Modal de Búsqueda de Catálogos --- */
.search-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    align-items: center;
    justify-content: center;
    background: none;
}

.search-modal-backdrop {
    position: absolute;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.search-modal-content {
    position: relative;
    z-index: 2;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 650px;
    min-width: 400px;
    width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'DM Sans', Arial, sans-serif;
}

.search-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.search-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary, #0071bc);
    font-family: 'Sora', 'DM Sans', Arial, sans-serif;
}

.search-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: bold;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.search-modal-close:hover {
    background: #e2e8f0;
    color: #334155;
}

.search-modal-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.search-input-container {
    position: relative;
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.search-input {
    width: 100%;
    padding: 12px 44px 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'DM Sans', Arial, sans-serif;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary, #0071bc);
    box-shadow: 0 0 0 3px rgba(0, 113, 188, 0.1);
}

.search-icon {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 1rem;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    padding: 8px 0;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.15s;
}

.search-result-item:hover,
.search-result-item.selected {
    background-color: #f8fafc;
}

.search-result-item:last-child {
    border-bottom: none;
}

.result-code {
    flex-shrink: 0;
    width: 100px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary, #0071bc);
    font-size: 0.95rem;
}

.result-text {
    flex: 1;
    margin-left: 16px;
    color: #334155;
    font-size: 0.95rem;
    line-height: 1.4;
}

.search-loading,
.search-error,
.search-no-results {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 40px 24px;
    color: #64748b;
    font-size: 0.95rem;
}

.search-loading i,
.search-error i,
.search-no-results i {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.search-error {
    color: #dc2626;
}

.search-modal-footer {
    padding: 12px 24px 16px 24px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.search-help-text {
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Botón de búsqueda en los campos del formulario */
.form-group-with-search {
    position: relative;
}

.search-trigger-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--primary, #0071bc);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.2s;
    z-index: 1;
}

.search-trigger-btn:hover {
    background: rgba(0, 113, 188, 0.1);
    color: var(--secondary, #ff6b35);
}

.form-group-with-search input {
    padding-right: 40px;
}

/* Responsive para móviles */
@media (max-width: 600px) {
    .search-modal-content {
        min-width: 320px;
        width: 95vw;
        max-height: 90vh;
    }
    
    .search-modal-header,
    .search-input-container,
    .search-modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .search-result-item {
        padding-left: 16px;
        padding-right: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .result-code {
        width: auto;
    }
    
    .result-text {
        margin-left: 0;
    }
}
