/* Laboratorio — simulazioni e pannelli full-screen */

.simulazione {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.simulazione-controlli {
    padding: 16px 20px;
    background: var(--surface);
    border: 1.5px solid var(--rule);
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
}

.istruzioni {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.pulsanti {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.slider-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

#canvas-campo {
    display: block;
    width: 100%;
    max-width: 900px;
    height: auto;
    aspect-ratio: 3 / 2;
    background: var(--surface);
    border: 1.5px solid var(--rule);
    border-radius: 8px;
    cursor: crosshair;
    touch-action: none;
}

/* Barra esperimento breadboard */
.bb-barra-esperimento {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.bb-nome-esp {
    font-weight: 600;
    color: var(--ink);
}

.tool-panel {
        position: fixed;
        inset: 0;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.78);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1rem;
        animation: panel-fade 0.2s ease-out;
    }
    @keyframes panel-fade { from { opacity: 0; } to { opacity: 1; } }
    .tool-panel[hidden] { display: none; }

    .tool-panel-inner {
        position: relative;
        display: grid;
        grid-template-columns: 380px minmax(0, 1fr);
        width: 100%;
        max-width: 1600px;
        height: calc(100vh - 2rem);
        background: #151a23;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
        overflow: hidden;
    }
    @media (max-width: 900px) {
        .tool-panel-inner {
            grid-template-columns: 1fr;
            grid-template-rows: minmax(0, auto) minmax(0, 1fr);
        }
        .tool-sidebar {
            max-height: 42vh;
            border-right: none !important;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }
    }

    /* Override specifico per il pannello lavoro (layout a colonna singola) */
    #panel-lavoro .tool-panel-inner {
        grid-template-columns: 1fr;
        display: block;
        overflow-y: auto;
        background: #10151d;
    }

    .tool-sidebar {
        overflow-y: auto;
        padding: 1.5rem 1.4rem;
        background: rgba(255, 255, 255, 0.02);
        border-right: 1px solid rgba(255, 255, 255, 0.08);
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    .tool-sidebar-head h2 {
        margin: 0 0 0.35rem;
        font-size: 1.3rem;
        color: #fff;
    }
    .tool-sidebar-sub {
        margin: 0;
        color: #b8bcc4;
        font-size: 0.96rem;
        line-height: 1.55;
    }
    .tool-sidebar-titolo {
        margin: 0.75rem 0 0;
        font-size: 0.82rem;
        font-weight: 700;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: #999;
    }

    /* ============================================================
       AREA CANVAS: si adatta allo spazio mantenendo il 3:2
       ============================================================ */
    .tool-main {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1.25rem;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
        background: #12161e;
    }
    .tool-main canvas {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
        background: #1a212c;
        touch-action: none;
    }
    #canvas-campo { cursor: crosshair; }
    #canvas-sovrapposizione { cursor: default; }

    .btn-chiudi {
        position: absolute;
        top: 14px;
        right: 14px;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.55);
        border: 1px solid rgba(255, 255, 255, 0.22);
        color: #fff;
        font-size: 1.45rem;
        line-height: 1;
        cursor: pointer;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s, transform 0.15s, border-color 0.15s;
    }
    .btn-chiudi:hover {
        background: rgba(241, 196, 15, 0.3);
        border-color: rgba(241, 196, 15, 0.75);
        transform: scale(1.06);
    }

    /* ============================================================
       CONTROLLI (sidebar) — font più leggibili
       ============================================================ */
    .gruppo-segno {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
        flex-wrap: wrap;
    }
    .btn-segno.attivo { color: #fff; border-color: transparent; }
    .btn-segno[data-segno="1"].attivo { background: #c62828; }
    .btn-segno[data-segno="-1"].attivo { background: #1565c0; }

    .input-carica {
        padding: .45rem .55rem;
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        font-family: inherit;
        font-size: 1.05rem;
        width: 100px;
        text-align: right;
        background: rgba(0, 0, 0, 0.25);
        color: #fff;
    }
    .input-carica:focus { outline: none; border-color: #90caf9; }
    .slider-label {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: .55rem;
        font-size: 0.96rem;
        color: #ddd;
    }

    /* Cariche sorgente: una per riga, layout orizzontale e compatto */
    #righe-cariche {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .charge-card {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 6px;
        padding: 0.45rem 0.65rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        transition: border-color 0.15s, background 0.15s;
    }
    .charge-card.selezionata {
        background: rgba(241, 196, 15, 0.1);
        border-color: rgba(241, 196, 15, 0.6);
    }
    .charge-name {
        font-weight: 700;
        color: #90caf9;
        font-size: 1.05rem;
        cursor: pointer;
        min-width: 2.5rem;
    }
    .charge-buttons {
        display: flex;
        gap: 2px;
    }
    .btn-tipo {
        padding: .15em .4em;
        font-size: .8rem;
        font-weight: 700;
        border-radius: 4px;
        border: 1px solid transparent;
        cursor: pointer;
        opacity: 0.4;
        transition: opacity 0.15s, box-shadow 0.15s;
    }
    .btn-tipo.attivo {
        opacity: 1;
        box-shadow: 0 0 0 1px currentColor;
    }
    .btn-tipo.protone { background: #ffcdd2; color: #8b0000; }
    .btn-tipo.elettrone { background: #bbdefb; color: #0d47a1; }
    
    .charge-input-wrap {
        width: 65px;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 4px;
        padding: 0.2rem 0.35rem;
    }
    .charge-input-wrap span { font-size: 0.75rem; color: #888; }
    .input-carica-mini {
        width: 100%;
        background: transparent;
        border: none;
        color: #fff;
        font-family: inherit;
        font-size: 0.95rem;
        text-align: right;
    }
    .input-carica-mini:focus { outline: none; }

    /* Dettaglio selezione */
    #dettaglio-selezione {
        display: none;
        padding: .8rem .9rem;
        background: rgba(241, 196, 15, 0.1);
        border: 1px solid rgba(241, 196, 15, 0.4);
        border-radius: 6px;
        font-size: .92rem;
        line-height: 1.55;
        color: #eee;
    }
    #dettaglio-selezione .dettaglio-titolo { margin-bottom: .3rem; color: #fcc419; }
    #dettaglio-selezione .dettaglio-riga.formula {
        font-family: 'Cambria Math', 'Times New Roman', serif;
        font-style: italic;
        margin: 0.25rem 0;
    }

    /* Tabella vettori */
    .info-vettori { overflow-x: auto; }
    .tabella-vettori {
        width: 100%;
        border-collapse: collapse;
        font-size: .88rem;
        color: #ddd;
    }
    .tabella-vettori th,
    .tabella-vettori td {
        padding: .4rem .45rem;
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, .1);
    }
    .tabella-vettori th {
        background: rgba(255, 255, 255, .05);
        font-weight: 600;
        color: #fff;
    }
    .tabella-vettori tr.totale { background: rgba(241, 196, 15, .15); }
    .tabella-vettori tr.selezionata { background: rgba(241, 196, 15, .1); }
    .tabella-vettori tr.appannata { opacity: .35; }
    .tabella-vettori .dot {
        display: inline-block;
        width: 9px;
        height: 9px;
        border-radius: 50%;
        margin-right: .35rem;
        vertical-align: middle;
    }
    .dot.protone { background: #ff6b6b; }
    .dot.elettrone { background: #4dabf7; }
    .dot.totale { background: #fcc419; }

    /* Simulazione */
    .simulazione-controls {
        display: none;
        flex-direction: column;
        gap: 8px;
        background: rgba(241, 196, 15, 0.08);
        padding: 10px 12px;
        border-radius: 8px;
        border: 1px solid rgba(241, 196, 15, 0.3);
    }
    .simulazione-controls .sim-status {
        font-weight: 600;
        color: #fcc419;
        font-size: 0.9rem;
    }
    .sim-buttons {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }
    .sim-buttons .btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.9rem;
    }
    .sim-progress {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .sim-progress input[type="range"] { flex: 1; }
    #sim-percentuale {
        font-family: monospace;
        min-width: 38px;
        text-align: right;
        font-size: 0.9rem;
        color: #fcc419;
    }

    /* Lavoro e percorso (per la card 3 se servono stili extra) */
    .lavoro-risultati { display: flex; flex-direction: column; gap: 10px; }
    .lavoro-percorso { display: flex; flex-direction: column; gap: 4px; }
    .lavoro-percorso-head {
        display: flex; justify-content: space-between; align-items: baseline;
        font-size: 0.92rem;
    }

    /* Bottoni-card: reset stile nativo, stessa grafica della homepage */
    button.home-card-link {
        font: inherit;
        cursor: pointer;
        width: 100%;
    }


/* Breadboard lab */
#breadboard-lab {
    width: 100%;
    min-height: 400px;
    margin-top: 16px;
}
@media (max-width: 900px) {
    #breadboard-lab { height: auto; min-height: 860px; }
}

.proc-misure {
    margin-top: 14px;
    font-size: 0.88rem;
    max-width: 820px;
}
.proc-misure summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
}
.proc-misure .lab-proc {
    margin: 8px 0 0;
    padding-left: 1.2em;
    color: var(--muted);
    line-height: 1.55;
}
.proc-misure .lab-proc li { margin: 4px 0; }

#lab-bb-catalogo { padding: 8px 0 24px; }

.bb-barra-esperimento {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--folder-bg);
    border: 1.5px solid var(--rule);
    border-radius: 8px;
    flex-wrap: wrap;
}
.bb-nome-esp {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 500;
}
