/* =========================================
   ESTILOS GENERALES Y BASE
   ========================================= */
body {
    background-color: #020617; /* Slate 950 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   LAYOUT Y POSICIONAMIENTO (LA CLAVE DE LA REGLA)
   ========================================= */

/* 1. El envoltorio debe ser relativo para que la regla se posicione dentro de él */
#simulation-wrapper {
    position: relative; 
    /* El canvas ya tiene sus estilos por Tailwind */
}

/* 2. El contenedor de la regla: FLOTA ENCIMA PERO ES TRANSPARENTE AL CLIC */
#ruler-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* ESTO ES LO IMPORTANTE: */
    pointer-events: none; /* Deja pasar los clics al canvas (para mover masas) */
    z-index: 30; /* Visualmente encima del canvas */
    overflow: hidden; /* Evita que la regla salga del área */
}

/* =========================================
   ELEMENTOS DE LA REGLA
   ========================================= */

.ruler-handle {
    position: absolute; 
    width: 24px; 
    height: 24px; 
    border-radius: 50%;
    background-color: rgba(250, 204, 21, 0.2); 
    border: 2px solid #facc15;
    cursor: grab; 
    
    /* ESTO REACTIVA LOS CLICS SOLO EN LOS BOTONES */
    pointer-events: auto; 
    z-index: 31; /* Un nivel más arriba que el contenedor */
    
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.3);
    touch-action: none; 
    display: grid; 
    place-items: center;
}

.ruler-handle:active { 
    cursor: grabbing; 
    background-color: rgba(250, 204, 21, 0.5); 
}

.ruler-handle::after { 
    content: ''; 
    width: 4px; 
    height: 4px; 
    background: #facc15; 
    border-radius: 50%; 
}

.ruler-line { 
    position: absolute; 
    background-color: #facc15; 
    height: 1px; 
    transform-origin: left center; 
    pointer-events: none; 
}

.ruler-text {
    position: absolute; 
    background-color: rgba(2, 6, 23, 0.9);
    color: #facc15; 
    font-size: 11px; 
    padding: 2px 6px; 
    font-family: monospace;
    border-radius: 4px; 
    border: 1px solid rgba(250, 204, 21, 0.3);
    pointer-events: none; 
    white-space: nowrap;
}

/* =========================================
   PANELES Y UI (GLASSMORPHISM)
   ========================================= */

.control-panel {
    background-color: rgba(15, 23, 42, 0.85); /* Slate 900 con opacidad */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Scrollbars personalizados (Estilo moderno) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #4f46e5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4338ca; }

/* =========================================
   CONTROLES DE FORMULARIO
   ========================================= */

/* Radio buttons personalizados */
.radio-label { position: relative; cursor: pointer; user-select: none; padding-left: 25px; display: inline-flex; align-items: center; height: 24px;}
.radio-label input { position: absolute; opacity: 0; cursor: pointer; }
.radio-dot { position: absolute; top: 2px; left: 0; height: 20px; width: 20px; background-color: #334155; border: 1px solid #475569; border-radius: 50%; transition: all 0.2s ease; }
.radio-label:hover input ~ .radio-dot { background-color: #475569; }
.radio-label input:checked ~ .radio-dot { background-color: #4f46e5; border-color: #4f46e5; box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2); }
.radio-dot:after { content: ""; position: absolute; display: none; top: 5px; left: 5px; width: 8px; height: 8px; border-radius: 50%; background: white; }
.radio-label input:checked ~ .radio-dot:after { display: block; }

/* Checkboxes personalizados */
.checkbox-label { position: relative; cursor: pointer; user-select: none; padding-left: 28px; display: flex; align-items: center; }
.checkbox-label input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.checkmark { position: absolute; top: 50%; left: 0; transform: translateY(-50%); height: 18px; width: 18px; background-color: #334155; border: 1px solid #475569; border-radius: 4px; transition: all 0.2s ease; }
.checkbox-label:hover input ~ .checkmark { background-color: #475569; }
.checkbox-label input:checked ~ .checkmark { background-color: #4f46e5; border-color: #4f46e5; }
.checkmark:after { content: ""; position: absolute; display: none; left: 5px; top: 1px; width: 5px; height: 10px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.checkbox-label input:checked ~ .checkmark:after { display: block; }

/* Sliders (Range Inputs) */
input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 6px;
    background: #334155; border-radius: 3px; outline: none;
    transition: background 0.2s;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px;
    background: #a5b4fc; cursor: pointer; border-radius: 50%;
    border: 2px solid #4f46e5; box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); background: #fff; }

/* Botones +/- para números */
.number-input-btn {
    background-color: #334155; color: #e2e8f0;
    width: 24px; height: 24px;
    border-radius: 4px; display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 1.1rem; line-height: 1;
    transition: background-color 0.2s;
}
.number-input-btn:hover { background-color: #475569; color: white; }

/* =========================================
   CLASES DE UTILIDAD ESPECÍFICAS
   ========================================= */

/* Modos Normales */
.mode-item { transition: all 0.2s ease; }
.mode-item.selected { background-color: rgba(55, 48, 163, 0.6); border-color: #6366f1; box-shadow: 0 0 10px rgba(99, 102, 241, 0.1); }
.mode-item-canvas {
    width: 100px; height: 40px;
    background-color: #0f172a;
    border-radius: 4px;
}

/* Popups y Transiciones */
#popup-overlay, #data-popup-overlay { transition: opacity 0.3s ease; }
#popup-box, #data-popup-box { transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); max-height: 85vh; overflow-y: auto; }
#popup-box.hidden, #data-popup-box.hidden { transform: translate(-50%, -48%) scale(0.96); opacity: 0; pointer-events: none; }

/* Tablas de Datos */
#data-table-container, #large-data-table-container { border: 1px solid #334155; border-radius: 6px; background: #0f172a; }
#data-table th, #data-table td { font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }

/* Notificaciones Toast */
#toast-notification {
    pointer-events: none; transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    transform: translate(-50%, 20px); opacity: 0;
}
#toast-notification.show { transform: translate(-50%, 0); opacity: 1; }