/* ==========================================================================
   sim.css · Demos estocásticas de GandiaTech
   Hoja compartida por el simulador de caja (Monte Carlo) y el simulador de
   plazos PERT. Usa los tokens globales de main.css y complementa los
   componentes de calculadora.css (.calc, .est-card, .calc-disclaimer).
   Sin frameworks: CSS plano.
   ========================================================================== */

/* --- Campos del formulario ------------------------------------------------ */
.sim-form { display: grid; gap: 16px; margin-top: 4px; }

.sim-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.sim-field { display: grid; gap: 6px; min-width: 0; }
.sim-field > label { font-size: 13.5px; }
.sim-hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.sim-affix { position: relative; }
.sim-affix input { padding-right: 44px; }
.sim-affix .unit {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    font: 600 13px "JetBrains Mono", monospace; color: var(--muted); pointer-events: none;
}

.sim-error {
    background: var(--accent-soft); border: 1px solid rgba(30, 34, 48, .08);
    color: var(--accent-text); border-radius: 16px; padding: 12px 16px;
    font-size: 14px; font-weight: 500; margin: 0;
}

.sim-note { font-size: 13px; color: var(--muted); margin: 14px 0 0; line-height: 1.5; }

/* --- Cabecera de panel + badge de cálculo -------------------------------- */
.sim-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.sim-head h2 { font-size: 22px; }
.sim-badge {
    font: 500 12px "JetBrains Mono", monospace; color: var(--muted);
    background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
    white-space: nowrap;
}

/* --- Gráficos (SVG generado en JS) --------------------------------------- */
.sim-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.sim-chart { margin-top: 6px; }

.sim-legend {
    display: flex; flex-wrap: wrap; gap: 8px 18px;
    font-size: 13px; color: var(--muted); margin-top: 12px;
}
.sim-legend span { display: inline-flex; align-items: center; gap: 7px; }
.sim-legend i { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.sim-legend i.dash { height: 0; border-top: 2px dashed var(--muted); border-radius: 0; }

/* --- Tablas de percentiles y de tareas ----------------------------------- */
.sim-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 18px; }
.sim-table caption {
    text-align: left; font: 600 12.5px "Instrument Sans", sans-serif; text-transform: uppercase;
    letter-spacing: .07em; color: var(--muted); padding-bottom: 10px;
}
.sim-table th, .sim-table td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); }
.sim-table th:first-child, .sim-table td:first-child { text-align: left; padding-left: 0; }
.sim-table thead th {
    font: 600 12px "Instrument Sans", sans-serif; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted);
}
.sim-table tbody td { font-family: "JetBrains Mono", monospace; font-size: 13px; }
.sim-table tbody td:first-child { font-family: "Instrument Sans", sans-serif; font-size: 14px; }
.sim-table tbody tr:last-child td { border-bottom: 0; }
.sim-table .neg { color: var(--accent-text); font-weight: 700; }

/* --- Editor de tareas (PERT) --------------------------------------------- */
.sim-tasks { display: grid; gap: 10px; margin-top: 4px; }
.sim-task-cols, .sim-task {
    display: grid; grid-template-columns: 2.2fr repeat(3, 1fr) 44px; gap: 10px; align-items: center;
}
.sim-task-cols span {
    font: 600 12px "Instrument Sans", sans-serif; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted);
}
.sim-task-cols span:not(:first-child) { text-align: center; }
.sim-task input { padding: 10px 12px; font-size: 15px; text-align: right; }
.sim-task input[type="text"] { text-align: left; }
.sim-del {
    width: 36px; height: 36px; border-radius: 12px; border: 1.5px solid var(--line);
    background: var(--surface); color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer;
    transition: all .15s;
}
.sim-del:hover { border-color: var(--accent); color: var(--accent-text); }
.sim-del:disabled { opacity: .35; cursor: not-allowed; }

.sim-add {
    justify-self: start; margin-top: 4px; padding: 10px 18px; min-height: 40px;
    border-radius: 999px; border: 1.5px solid var(--ink); background: transparent;
    color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; font-family: inherit;
    transition: all .15s;
}
.sim-add:hover { background: var(--ink); color: #fff; }

/* --- Bloques de resultado (panel lateral) -------------------------------- */
.sim-big em { font-style: normal; color: var(--accent); }
.sim-empty { color: var(--muted); font-size: 14px; }

/* --- Aviso de método (bajo los resultados) ------------------------------- */
.sim-method {
    background: var(--sand); border-radius: 20px; padding: 18px 20px; margin-top: 18px;
    font-size: 13.5px; line-height: 1.55; color: var(--ink);
}
.sim-method b { font-weight: 700; }

/* --- Móvil --------------------------------------------------------------- */
@media (max-width: 760px) {
    .sim-task-cols { display: none; }
    .sim-task { grid-template-columns: repeat(3, 1fr) 44px; gap: 8px; }
    .sim-task input[type="text"] { grid-column: 1 / -1; }
    .sim-table th, .sim-table td { padding: 8px 6px; font-size: 13px; }
    .sim-table tbody td { font-size: 12.5px; }
}
