/* Terminal style */
body {
    font-family: 'Courier New', monospace;
    background: #0a0a0a;
    color: #00ff00;
    margin: 20px;
    line-height: 1.4;
}

h1 {
    color: #00ff00;
    text-shadow: 0 0 5px #00ff00;
}

/* Estilo para la versión */
.version {
    font-size: 0.4em;
    color: #00cc00;
    font-weight: normal;
    text-shadow: 0 0 3px #00cc00;
    vertical-align: top;
    margin-left: 8px;
}

/* Contenedor principal con flexbox para redimensionamiento bidireccional */
.container {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    min-height: 400px;
    align-items: stretch;
    height: fit-content;
}

/* Estados de vista */
.container.view-editor #preview {
    display: none;
}

.container.view-canvas #editor {
    display: none;
}

.container.view-editor #editor {
    width: 100%;
    max-width: none;
}

.container.view-canvas #preview {
    width: 100%;
    max-width: none;
    height: calc(100vh - 200px);  /* Altura de pantalla menos espacio para controles */
    min-height: unset;
}

/* Ajustar el contenedor cuando está en modo canvas */
.container.view-canvas {
    height: calc(100vh - 200px);
    min-height: unset;
}

/* Editor redimensionable - controla el tamaño */
#editor {
    background: #111;
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 10px;
    font-family: inherit;
    min-height: 400px;          /* Altura mínima flexible */
    width: 50%;                 /* Tamaño inicial */
    min-width: 200px;           /* Mínimo ancho */
    max-width: 80%;             /* Máximo ancho */
    resize: both;               /* Redimensionar en ambas direcciones */
    overflow: auto;
}

/* Preview que toma el espacio restante con zoom y pan */
#preview {
    background: #111;
    border: 1px solid #00ff00;
    padding: 0;                 /* Sin padding para mejor control */
    overflow: hidden;           /* Ocultar scroll nativo */
    flex: 1;                    /* Toma todo el espacio restante */
    min-width: 150px;           /* Mínimo para que sea funcional */
    position: relative;         /* Para controles de zoom */
    cursor: grab;               /* Indicar que se puede arrastrar */
    /* La altura se sincroniza automáticamente con align-items: stretch */
}

#preview:active {
    cursor: grabbing;           /* Cursor al arrastrar */
}

/* Contenedor interno del diagrama con transformaciones */
#preview .mermaid {
    transform-origin: 0 0;      /* Punto de origen para zoom */
    transition: transform 0.1s ease-out; /* Suavizar transformaciones */
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
}

/* Controles de zoom */
.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.zoom-btn {
    background: rgba(17, 17, 17, 0.9);
    border: 1px solid #00ff00;
    color: #00ff00;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
}

.zoom-btn:hover {
    background: #00ff00;
    color: #000;
}

.zoom-info {
    background: rgba(17, 17, 17, 0.9);
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 2px 6px;
    font-size: 10px;
    text-align: center;
    border-radius: 3px;
}

/* Controles */
button, select {
    background: #111;
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 5px 10px;
    margin: 2px;
    cursor: pointer;
    font-family: inherit;
}

button:hover, select:hover {
    background: #00ff00;
    color: #000;
}

/* Botones de vista */
.view-btn {
    padding: 8px 12px;
    font-size: 12px;
    margin: 0 2px;
}

.view-btn.active {
    background: #00ff00;
    color: #000;
    font-weight: bold;
}

.view-btn:hover {
    background: #00cc00;
    color: #000;
}

/* Resultados */
#results {
    background: #111;
    border: 1px solid #00ff00;
    padding: 10px;
    margin-top: 20px;
    white-space: pre-wrap;
}

/* Panel de ayuda */
#help-panel {
    background: #111;
    border: 1px solid #00ff00;
    padding: 15px;
    margin: 10px 0;
    border-radius: 3px;
}

#help-panel h3, #help-panel h4 {
    color: #00ff00;
    margin-top: 10px;
    margin-bottom: 5px;
}

#help-panel ul {
    margin: 5px 0 10px 20px;
    padding: 0;
}

#help-panel li {
    margin: 3px 0;
}

#help-panel pre {
    background: #222;
    border: 1px solid #00ff00;
    padding: 10px;
    margin: 10px 0;
    overflow-x: auto;
    font-size: 12px;
}

#help-panel code {
    background: #222;
    padding: 2px 4px;
    border: 1px solid #00ff00;
}

/* Modales */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #0a0a0a;
    border: 2px solid #00ff00;
    padding: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80%;
    overflow-y: auto;
}

.modal-content h3, .modal-content h4 {
    color: #00ff00;
    margin: 10px 0 5px 0;
}

.modal-content input, .modal-content textarea, .modal-content select {
    background: #111;
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 5px;
    margin: 5px;
    width: calc(100% - 20px);
    font-family: inherit;
}

.modal-content textarea {
    min-height: 60px;
    resize: vertical;
}

.modal-content input[type="color"] {
    width: 50px;
    height: 30px;
    padding: 0;
}

#comments-list div {
    background: #111;
    border: 1px solid #00ff00;
    padding: 8px;
    margin: 5px 0;
    border-radius: 3px;
}

/* Estilos Mermaid para mejor visibilidad */
.mermaid {
    background: #0a0a0a !important;
}

/* Líneas de conexión gris claro */
.mermaid .relation {
    stroke: #cccccc !important;
    stroke-width: 2px !important;
}

.mermaid .relationshipLine {
    stroke: #cccccc !important;
    stroke-width: 2px !important;
}

.mermaid .er.relationshipLine {
    stroke: #cccccc !important;
    stroke-width: 2px !important;
}

/* Marcadores de flecha gris claro */
.mermaid .er.relationshipLineEnding {
    fill: #cccccc !important;
    stroke: #cccccc !important;
}

.mermaid marker {
    fill: #cccccc !important;
    stroke: #cccccc !important;
}

/* Texto de relaciones blanco y más visible con mejor posicionamiento */
.mermaid .er.relationshipLabel {
    fill: #ffffff !important;
    font-weight: bold !important;
    font-size: 12px !important;
    text-shadow: 0 0 3px #000000 !important;
}

/* Fondo semitransparente para los textos de relación */
.mermaid .er.relationshipLabelBox {
    fill: rgba(0, 0, 0, 0.7) !important;
    stroke: #333333 !important;
    stroke-width: 1px !important;
    rx: 3 !important;
    ry: 3 !important;
}

/* Ajustar spacing de los textos de relación */
.mermaid .er.relationshipLabel tspan {
    dominant-baseline: central !important;
}

/* Líneas de las tablas */
.mermaid .er.entityBox {
    stroke: #00ff00 !important;
    stroke-width: 1px !important;
    fill: #111 !important;
}

/* Texto de las tablas */
.mermaid .er.entityLabel {
    fill: #00ff00 !important;
    font-weight: bold !important;
}

.mermaid .er.attributeBoxEven,
.mermaid .er.attributeBoxOdd {
    fill: #111 !important;
    stroke: #00ff00 !important;
}

.mermaid .er.entityLabel text {
    fill: #00ff00 !important;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    #editor {
        resize: vertical;
        min-height: 200px;
    }
    
    #preview {
        min-height: 200px;
    }
    
    .modal-content {
        width: 95%;
        padding: 15px;
    }
}