/* =======================================================
   NavTools - Modellazione Avanzata PIC vs PAC Style
   Stile coerente con l'architettura visiva di NavTools
   ======================================================= */

.tool-container {
    padding-top: 24px;
    padding-bottom: 48px;
}

.back-link {
    display: inline-flex;
    margin-bottom: 20px;
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
    color: var(--primary-dark);
    text-decoration: underline;
}

.tool-header {
    max-width: 760px;
    margin: 0 auto 28px;
    text-align: center;
}

.tool-header .logo {
    width: 96px;
    max-width: 30vw;
    margin: 0 auto 14px;
}

h1 {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: clamp(2rem, 4vw, 2.7rem);
    letter-spacing: 0;
}

.description {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

/* -------------------------------------------------------
   Sezioni della pagina
   ------------------------------------------------------- */

.section-container {
    margin-bottom: 28px;
    padding: 28px;
}

.section-badge-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.active-badge {
    background: #eef7f2;
    color: var(--accent);
    border: 1px solid #b3d9c5;
}

.section-container h2 {
    margin: 0;
    color: var(--primary);
    font-size: 1.3rem;
}

.section-intro {
    color: var(--text);
    line-height: 1.65;
    margin: 0 0 24px;
    font-size: 0.96rem;
}

/* -------------------------------------------------------
   Grid layout calcolatore (Sezioni 1 & 2)
   ------------------------------------------------------- */

.calculator-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 1.2fr);
    gap: 20px;
    align-items: start;
}

.input-column,
.result-column {
    display: grid;
    gap: 20px;
}

.inner-panel {
    padding: 20px;
    background: #fcfdfe;
    border: 1px solid var(--border);
}

.inner-panel h3 {
    margin: 0 0 16px;
    color: var(--primary);
    font-size: 1.05rem;
}

label {
    display: block;
    margin: 14px 0 6px;
    color: #263846;
    font-weight: 700;
    font-size: 0.92rem;
}

label:first-child {
    margin-top: 0;
}

input[type="number"] {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #cddbd6;
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

input[type="number"]:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.15);
}

.field-note {
    margin: 5px 0 0;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.4;
}

/* Box info calcolato (Rata mensile) */
.calculated-info-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0 6px;
    padding: 10px 14px;
    background: #eef7f2;
    border: 1px solid #b3d9c5;
    border-radius: 6px;
}

.calc-label {
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 600;
}

.calc-val {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--accent);
}

/* -------------------------------------------------------
   Tasto Avvio Monte Carlo & Barra di Avanzamento
   ------------------------------------------------------- */

.mc-run-button {
    width: 100%;
    margin-top: 20px;
    padding: 14px 18px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.mc-run-button:hover,
.mc-run-button:focus-visible {
    background: var(--primary-dark);
}

.mc-run-button:disabled {
    background: #9ab4c9;
    cursor: not-allowed;
}

.progress-bar-box {
    margin-top: 16px;
}

.progress-bar-track {
    width: 100%;
    height: 10px;
    background: #e2eaf0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.1s ease;
}

.progress-bar-text {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
    font-weight: 600;
}

/* -------------------------------------------------------
   Card Risultati Sezione 1 (Righe ingrandite senza valore in alto)
   ------------------------------------------------------- */

.result-card {
    padding: 22px;
    text-align: center;
    border-top: 5px solid var(--accent);
}

#resultTitle {
    margin: 0 0 14px;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.result-details-prominent {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.summary-line-large {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 12px 14px;
    border-radius: 6px;
    background: #f8fafb;
    border: 1px solid var(--border);
}

.summary-line-large.pic-line {
    border-left: 4px solid var(--primary);
    background: #f0f4fa;
}

.summary-line-large.pac-line {
    border-left: 4px solid var(--accent);
    background: #eef7f2;
}

.detail-label-large {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.detail-val-large {
    font-size: 1.35rem;
    font-weight: 800;
}

.highlight-line {
    display: block;
    text-align: center;
    font-weight: 700;
    color: var(--primary);
    background: #f0f4fa;
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 4px;
    font-size: 0.95rem;
}

/* -------------------------------------------------------
   Card Probabilità di Vittoria Monte Carlo (Sezione 2)
   ------------------------------------------------------- */

.mc-result-card {
    border-top-color: var(--primary);
}

.mc-result-title {
    margin: 0 0 16px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    text-align: center;
}

.win-prob-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.win-badge-box {
    padding: 14px 12px;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border);
}

.pic-win-box {
    background: #f0f4fa;
    border-color: #b3cae0;
}

.pic-win-box .win-label {
    color: var(--primary);
}

.pic-win-box .win-val {
    color: var(--primary);
}

.pac-win-box {
    background: #eef7f2;
    border-color: #b3d9c5;
}

.pac-win-box .win-label {
    color: var(--accent);
}

.pac-win-box .win-val {
    color: var(--accent);
}

.win-label {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.win-val {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin: 4px 0;
}

.win-subtext {
    font-size: 0.76rem;
    color: var(--muted);
}

/* Tabella Monte Carlo */
.mc-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.mc-table th {
    padding: 8px 4px;
    font-size: 0.78rem;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}

.mc-table td {
    padding: 10px 4px;
    border-bottom: 1px solid #edf2f0;
    font-size: 0.9rem;
}

/* -------------------------------------------------------
   Stile dei Grafici SVG
   ------------------------------------------------------- */

.chart-panel {
    display: flex;
    flex-direction: column;
}

.chart-container {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e2eaf0;
    border-radius: 8px;
    padding: 12px 8px 8px;
    box-sizing: border-box;
}

#picPacChart,
#mcDensityChart {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.chart-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #edf2f0;
    font-size: 0.84rem;
    color: var(--text);
    font-weight: 600;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 14px;
    height: 4px;
    border-radius: 2px;
}

.legend-line {
    display: inline-block;
    width: 18px;
    height: 0;
    border-top-width: 2.5px;
    border-top-style: dashed;
}

.legend-pic {
    background-color: #0f4c81; /* primary */
}

.legend-pac {
    background-color: #237a4b; /* accent */
}

.legend-median-pic {
    border-top-color: #0f4c81;
}

.legend-median-pac {
    border-top-color: #237a4b;
}

.legend-pac-port {
    background-color: #f59e0b; /* warning/amber */
}

/* Elementi interni SVG */
.chart-grid-line {
    stroke: #e6edf2;
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.chart-axis-line {
    stroke: #b0c4de;
    stroke-width: 1.5;
}

.chart-axis-label {
    fill: var(--muted);
    font-size: 11px;
    font-family: inherit;
}

.chart-axis-title {
    fill: var(--primary);
    font-weight: 700;
    font-size: 12px;
}

.chart-path-pic {
    fill: none;
    stroke: #0f4c81;
    stroke-width: 3;
    stroke-linecap: round;
}

.chart-path-pac {
    fill: none;
    stroke: #237a4b;
    stroke-width: 3;
    stroke-linecap: round;
}

.chart-path-pac-port {
    fill: none;
    stroke: #f59e0b;
    stroke-width: 2;
    stroke-dasharray: 5 4;
    stroke-linecap: round;
}

/* Curve densità Monte Carlo */
.density-area-pic {
    fill: rgba(15, 76, 129, 0.15);
    stroke: #0f4c81;
    stroke-width: 2.5;
}

.density-area-pac {
    fill: rgba(35, 122, 75, 0.15);
    stroke: #237a4b;
    stroke-width: 2.5;
}

.chart-point {
    transition: r 0.15s ease;
    cursor: pointer;
}

.chart-point:hover {
    r: 6;
}

/* -------------------------------------------------------
   Sezione Teorica per Monte Carlo
   ------------------------------------------------------- */

.theory-block h3 {
    margin: 0 0 16px;
    color: var(--primary);
    font-size: 1.15rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

.theory-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.theory-item h4 {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 0.96rem;
    font-weight: 700;
}

.theory-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.6;
}

/* -------------------------------------------------------
   Roadmap sezioni 3 e 4 (In programma)
   ------------------------------------------------------- */

.roadmap-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 16px;
}

.roadmap-card {
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #dfe8e4;
    background: #f8fafb;
    display: flex;
    flex-direction: column;
}

.roadmap-badge {
    display: inline-block;
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    background: #fff0e0;
    color: #b26000;
    border: 1px solid #ffe0cc;
    margin-bottom: 12px;
}

.roadmap-card h3 {
    margin: 0 0 10px;
    font-size: 0.96rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.4;
}

.roadmap-card p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.55;
}

/* -------------------------------------------------------
   Hub Indice Moduli
   ------------------------------------------------------- */

.module-hub-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 16px;
}

.module-hub-card {
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

.active-hub-card {
    background: #ffffff;
    border-color: #c5d0d8;
}

.disabled-hub-card {
    background: #f8fafb;
    border-color: #e2eaf0;
}

.module-status-badge {
    display: inline-block;
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.available-badge {
    background: #eef7f2;
    color: var(--accent);
    border: 1px solid #b3d9c5;
}

.draft-badge {
    background: #fff0e0;
    color: #b26000;
    border: 1px solid #ffe0cc;
}

.module-hub-card h3 {
    margin: 0 0 10px;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary);
}

.module-hub-card p {
    margin: 0 0 16px;
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.55;
}

.button-secondary {
    background: #f0f4fa;
    color: var(--primary);
    border: 1px solid #b3cae0;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
    display: inline-block;
    padding: 10px 16px;
    border-radius: 6px;
}

.button-secondary:hover,
.button-secondary:focus-visible {
    background: var(--primary);
    color: #ffffff;
}

/* -------------------------------------------------------
   Info e Disclaimer
   ------------------------------------------------------- */

.info-card {
    margin-top: 20px;
    padding: 24px;
    color: var(--muted);
}

.info-card h2 {
    margin: 0 0 14px;
    color: var(--primary);
    font-size: 1.1rem;
}

.info-card table {
    width: 100%;
    border-collapse: collapse;
}

.info-card td {
    padding: 11px 0;
    vertical-align: top;
}

.info-card td:first-child {
    color: var(--muted);
}

.info-card td:last-child {
    text-align: right;
    font-weight: 700;
}

.info-card tr:not(:last-child) {
    border-bottom: 1px solid #edf2f0;
}

.disclaimer-text {
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--muted);
    margin: 0;
}

/* -------------------------------------------------------
   Responsività
   ------------------------------------------------------- */

@media (max-width: 1024px) {
    .roadmap-grid,
    .theory-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 840px) {
    .calculator-layout {
        grid-template-columns: 1fr;
    }

    .tool-container {
        width: min(100% - 28px, 680px);
        padding-top: 18px;
    }

    .section-container {
        padding: 20px;
    }

    .win-prob-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .result-card,
    .inner-panel,
    .info-card {
        padding: 16px;
    }

    .detail-val-large {
        font-size: 1.15rem;
    }
}

/* -------------------------------------------------------
   Riepilogo Draw‑down (Coerente con lo stile NavTools)
   ------------------------------------------------------- */
td.better {
    background-color: #eef7f2;
    color: var(--accent, #237a4b);
    font-weight: 700;
    border-radius: 4px;
}

