/**
 * miclase-md-editor.css
 * Tema Dark Premium (Rigid 50/50 Layout, Mobile Responsive & Custom Scroll).
 * INCLUYE: Soporte para Doble Barra Flexbox, Poka-Yoke DOM Dropdowns y Pseudo-Spacer para Scroll de Paneles.
 * @version 1.0
 */

.mc-editor-container {
    display: flex;
    flex-direction: column;
    background: var(--color-card-bg, rgba(22, 22, 30, 0.55));
    border: 1px solid var(--color-card-border, rgba(255, 255, 255, 0.07));
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    transition: all 0.3s ease;
    height: 75vh; 
    min-height: 600px;
    position: relative;
}

/* --- DOBLE BARRA DE HERRAMIENTAS --- */
.mc-editor-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
    background: var(--color-black-title, rgba(10, 10, 14, 0.95));
    border-bottom: 1px solid var(--color-card-border, rgba(255, 255, 255, 0.07));
    z-index: 10;
}

.mc-editor-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    gap: 4px;
}

.mc-editor-toolbar-row:first-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
}

.mc-editor-toolbar-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding-right: 8px;
    margin-right: 4px;
}

.mc-editor-toolbar-group:last-child { 
    border-right: none; 
    margin-right: 0; 
}

.mc-editor-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-muted, #8e8e9e);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1rem;
}

.mc-editor-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-text-main, #f8f9fa);
}

/* --- DROPDOWNS --- */
.dropdown-menu .dropdown-item[type="button"] {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: #dee2e6;
}

.dropdown-menu .dropdown-item[type="button"]:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* --- PROPORCIÓN RÍGIDA 50/50 (Desktop) --- */
.mc-editor-body {
    display: flex;
    flex-direction: row !important;
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    position: relative;
}

.mc-editor-monaco-wrapper,
.mc-editor-preview-wrapper {
    flex: 0 0 50% !important;
    width: 50% !important;
    max-width: 50% !important;
    min-width: 50% !important;
    height: 100% !important;
    box-sizing: border-box !important;
    position: relative;
}

.mc-editor-monaco-wrapper { 
    background: #0d1117 !important; 
}

.mc-editor-preview-wrapper {
    background: rgba(13, 17, 23, 0.6);
    border-left: 1px solid var(--color-card-border, rgba(255, 255, 255, 0.1));
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px;
    word-break: break-word;
}

.mc-editor-textarea { 
    display: none !important; 
}

/* MODOS DESKTOP */
.mc-editor-mode-edit .mc-editor-preview-wrapper { display: none !important; }
.mc-editor-mode-edit .mc-editor-monaco-wrapper { flex: 0 0 100% !important; width: 100% !important; max-width: 100% !important; }

.mc-editor-mode-preview .mc-editor-monaco-wrapper { display: none !important; }
.mc-editor-mode-preview .mc-editor-preview-wrapper { flex: 0 0 100% !important; width: 100% !important; max-width: 100% !important; border-left: none; }

/* PANEL FLOTANTE PROFESIONAL */
.mc-editor-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 350px;
    height: 100%;
    background: rgba(15, 15, 20, 0.98);
    border-left: 1px solid var(--color-card-border);
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box !important;
}

.mc-editor-panel.open { 
    transform: translateX(0); 
}

.mc-editor-panel-header {
    padding: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    color: var(--color-primary);
    flex-shrink: 0;
}

.mc-editor-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-sizing: border-box !important;
}

.mc-editor-panel-body .panel-logic-container {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box !important;
}

.mc-editor-panel-body .tab-content {
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-sizing: border-box !important;
}

.mc-symbol-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.mc-symbol-grid:last-child {
    margin-bottom: 0;
}

.mc-symbol-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 8px 0;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Cambria Math', serif;
    font-size: 1.1rem;
}

.mc-symbol-btn:hover {
    background: var(--color-primary);
}

.mc-template-list button {
    width: 100%;
    text-align: left;
    background: rgba(255,255,255,0.05);
    border: none;
    padding: 8px 12px;
    color: #c9d1d9;
    margin-bottom: 4px;
    border-radius: 4px;
}

.mc-template-list button:hover { 
    background: rgba(59, 130, 246, 0.3); 
    color: #fff; 
}

.mc-template-list button:last-child {
    margin-bottom: 0;
}

/* CUSTOM SCROLL PARA EL PANEL LATERAL */
.custom-scroll {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.2);
    box-sizing: border-box !important;
}

.mc-editor-panel-body .tab-pane.custom-scroll {
    min-height: 0;
    height: 100%;
    box-sizing: border-box !important;
}

.custom-scroll::-webkit-scrollbar { 
    width: 6px; 
}
.custom-scroll::-webkit-scrollbar-track { 
    background: rgba(0, 0, 0, 0.2); 
}
.custom-scroll::-webkit-scrollbar-thumb { 
    background: rgba(255, 255, 255, 0.3); 
    border-radius: 4px; 
}
.custom-scroll::-webkit-scrollbar-thumb:hover { 
    background: rgba(255, 255, 255, 0.5); 
}

/* --- GARANTÍA ABSOLUTA DE MARGEN INFERIOR Y VISIBILIDAD DE PANELES --- */
.mc-editor-panel-body .tab-pane {
    padding-bottom: 1rem !important; 
    box-sizing: border-box !important;
}

/* Pseudo-elemento Físico Estructural: Previene el colapso de margen en WebKit / Blink */
.mc-editor-panel-body .tab-pane::after {
    content: "";
    display: block;
    clear: both;
    height: 5px !important;
    width: 100%;
    flex-shrink: 0;
    pointer-events: none;
}

/* Centralización del control de espacio inferior en el pseudo-elemento */
.mc-editor-panel-body .tab-pane > *:last-child {
    margin-bottom: 0 !important;
}

/* BARRA DE ESTADO INFERIOR NATIVA (NO FLOTANTE) */
.mc-editor-statusbar {
    display: flex;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--color-black-title, rgba(10, 10, 14, 0.98));
    border-top: 1px solid var(--color-card-border, rgba(255, 255, 255, 0.07));
    font-size: 0.75rem;
    color: var(--color-text-muted, #8e8e9e);
    font-family: monospace;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 10;
}

/* MathJax Error Styling */
merror {
    background: #4a0000;
    color: #ffcccc;
    border: 1px solid #ff0000;
    padding: 2px 4px;
    border-radius: 3px;
}

/* =========================================================================
   MEDIA QUERIES - RESPONSIVE MOBILE
   ========================================================================= */
@media (max-width: 768px) {
    .mc-editor-container {
        height: 85vh;
        min-height: 650px;
    }

    .mc-editor-toolbar {
        padding: 6px;
    }

    .mc-editor-toolbar-row {
        justify-content: center;
    }
    
    .mc-editor-toolbar-group {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 4px;
        margin-bottom: 4px;
        width: 100%;
        justify-content: center;
    }
    
    .mc-editor-toolbar-group:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .mc-editor-body {
        flex-direction: column !important;
    }

    .mc-editor-mode-split .mc-editor-monaco-wrapper,
    .mc-editor-mode-split .mc-editor-preview-wrapper {
        flex: 0 0 50% !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        height: 50% !important;
        border-left: none !important;
    }

    .mc-editor-mode-split .mc-editor-preview-wrapper {
        border-top: 2px solid var(--color-primary, #3b82f6) !important;
    }

    .mc-editor-panel {
        width: 100%;
        border-left: none;
    }

    .mc-editor-panel-body .tab-pane::after {
        height: 60px !important; 
    }

    .mc-editor-statusbar {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 4px;
    }
}