/* Variables root para colores y temas consistentes */
:root {
    --bg-light-gray: #f5f5f5;
    --bg-white: #ffffff;
    --text-dark-gray: #333333;
    --accent-green: #4CAF50;
    --border-light: #e0e0e0;
    --bg-canvas: #fafafa;
}

/* Estilos generales para body y layout principal */
body {
    margin: 0;
    background: var(--bg-light-gray);
    color: var(--text-dark-gray);
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
}

#topbar, #projects-topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 15px;
    gap: 10px;
}

#topbar h1, #projects-topbar h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--text-dark-gray);
}

#left-sidebar, #right-sidebar {
    position: fixed;
    top: 50px;
    bottom: 0;
    width: 300px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    padding: 15px;
    z-index: 900;
}

#right-sidebar {
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-light);
}

#glcanvas {
    position: absolute;
    top: 50px;
    left: 300px;
    right: 300px;
    bottom: 0;
    background: var(--bg-canvas);
}

/* Estilos para paneles y botones */
.panel-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    color: #888888;
}

.btn-tool {
    width: 100%;
    margin-bottom: 5px;
    text-align: left;
    font-size: 0.85rem;
    border: none;
    border-radius: 4px;
    background: var(--bg-light-gray);
    color: var(--text-dark-gray);
}

.btn-tool:hover {
    background: #e0e0e0;
}

.btn-tool i {
    margin-right: 8px;
}

.btn-export {
    background: var(--accent-green);
    color: white;
}

#coords {
    position: absolute;
    background: rgba(255,255,255,0.8);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 100;
    display: flex;
    flex-direction: row;
    align-items: center;
    white-space: nowrap;
    line-height: 1;
}

#coords input {
    width: 60px;
    border: none;
    background: transparent;
    text-align: center;
}

.accordion-body small {
    font-size: 0.75rem;
}

#projects-container {
    display: none;
    position: fixed;
    top: 50px;
    left: 0;
    width: 100%;
    height: calc(100vh - 50px);
    overflow-y: auto;
    background: var(--bg-light-gray);
    padding: 15px;
}

.snap-btn {
    background: var(--bg-light-gray);
    color: var(--text-dark-gray);
    border: 1px solid var(--border-light);
}

.snap-btn.active {
    background: var(--accent-green);
    color: white;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.dropdown-item.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.accordion-button.active {
    background-color: #0d6efd !important;
    color: white !important;
}

/* Estilos para árbol jerárquico CAD-like */
#elementTree {
    font-family: system-ui, monospace;
    font-size: 0.85rem; /* Tamaño de letra pequeño */
    line-height: 1.2; /* Espacio entre líneas ajustado */
}

#elementTree ul.tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

#elementTree .tree li {
    position: relative;
    padding-left: 25px; /* Sangría progresiva */
    margin-bottom: 5px; /* Espacio entre elementos */
}

#elementTree .tree li::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 10px;
    width: 1px;
    background: #ccc; /* Líneas verticales grises */
}

#elementTree .tree li:last-child::before {
    bottom: auto;
    height: 10px; /* Línea corta para último hijo */
}

#elementTree .tree li::after {
    content: "";
    position: absolute;
    top: 10px;
    left: 10px;
    width: 10px;
    height: 1px;
    background: #ccc; /* Líneas horizontales */
}

#elementTree summary {
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: inline-flex;
    align-items: center;
}

#elementTree summary::-webkit-details-marker {
    display: none;
}

#elementTree .visibility-toggle {
    cursor: pointer;
    margin-right: 5px; /* Espacio después del botón de visibilidad */
}

#elementTree .element-icon {
    margin-right: 5px; /* Espacio después del icono */
    color: #888; /* Color neutro para iconos */
}

#elementTree details[open] > summary .bi-chevron-right {
    transform: rotate(90deg); /* Rotar icono al expandir */
}

#elementTree .tree details {
    margin-left: 0; /* Ajuste para sub-niveles */
}

#elementTree .selected {
    background-color: #e0f7fa; /* Fondo azul claro para seleccionado */
}

/* Estilos para menú contextual */
#contextMenu {
    position: absolute;
    display: none;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 5px 0;
}

#contextMenu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#contextMenu li {
    padding: 5px 15px;
    cursor: pointer;
}

#contextMenu li:hover {
    background: #f0f0f0;
}

/* Indentación progresiva para niveles en árbol */
#elementTree .tree {
    padding-left: 0;
}

#elementTree .tree ul.tree {
    padding-left: 20px;
}

#elementTree .tree ul.tree ul.tree {
    padding-left: 40px;
}

#elementTree .tree ul.tree ul.tree ul.tree {
    padding-left: 60px;
}

/* Estilos para modal de ventana (compacto y profesional) */
#windowModal .modal-body {
    font-size: 0.85rem; /* Reducir tamaño de letra */
}

#windowModal .mb-3 {
    margin-bottom: 0.5rem !important; /* Reducir alto de filas */
}

#windowModal label {
    margin-bottom: 0.2rem; /* Menos espacio bajo labels */
}

#windowModal input, #windowModal select {
    height: 30px; /* Reducir alto de inputs */
    padding: 0.25rem 0.5rem;
}

#windowModal .window-block {
    border: 1px solid #e0e0e0;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    background: #f9f9f9;
}

#windowModal .diagram-option {
    color: blue; /* Diagramas en azul */
}