/* Globális stílusok */
*,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Poppins", Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #fff;
    overflow-x: hidden;
}

/* Chart konténer stílusok */
.chart-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    gap: 20px;
}

.chart {
    flex: 1 1 auto;
    max-width: 200px;
    text-align: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.legend-container {
    flex: 0 0 auto;
    width: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    box-sizing: border-box;
}

.legend-container #legend {
    display: flex;
    flex-direction: column;
}

.legend-container #legend-left,
.legend-container #legend-right {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin: 0;
}

#legend-container3 {
    flex: 0 0 auto;
    width: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

#legend-container3 #legend3 {
    display: flex;
    flex-direction: column;
}

.legend-container div {
    display: flex;
    margin-bottom: 5px;
    white-space: nowrap;
}

.legend-container div span {
    width: 20px;
    height: 20px;
    display: inline-block;
    margin-right: 10px;
    flex-shrink: 0;
}

.chart-title {
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1.5em;
    margin: 0;
}

.chart-subtitle {
    text-align: center;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.75em;
    color: #222;
    margin-bottom: 10px;
}

.tooltip,
.legend-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: .8rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 200px;
    max-height: 200px;
    box-sizing: border-box;
}

.legend-disabled {
    text-decoration: line-through;
}

/* Asztali nézet (1200px felett) */
@media (min-width: 1200px) {
    .chart-container {
        flex-wrap: nowrap;
    }

    /* Elem sorrend */
    #legend-container {
        order: 1;
    }

    #chart1 {
        order: 2;
    }

    #chart2 {
        order: 3;
    }

    #chart3 {
        order: 4;
    }

    #legend-container3 {
        order: 5;
    }

    /* Méretezés */
    .chart,
    .legend-container {
        flex: 0 0 auto;
        max-width: none;
    }

    #legend-container,
    #legend-container3 {
        width: 200px;
    }

    .chart {
        width: 200px;
    }
}

/* Közepes nézet (767px és 1199px között) */
@media (min-width: 768px) and (max-width: 1199px) {
    .chart-container {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Az Összes vizsgálat és MD/IVD chartok egymás mellett */
    #chart1,
    #chart2 {
        flex: 1 1 45%;
        max-width: 45%;
    }

    /* Legend-container teljes szélességben */
    #legend-container {
        flex: 1 1 100%;
        max-width: 100%;
    }

    /* Study Types chart és legendája egymás mellett */
    #chart3,
    #legend-container3 {
        flex: 1 1 45%;
        max-width: 45%;
    }

    /* Igazítás */
    .chart,
    .legend-container {
        align-items: center;
        justify-content: center;
    }

    #legend-container #legend {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 20px;
        align-items: center;
        justify-content: center;
    }

    #legend-container3 #legend3 {
        flex-direction: column;
        flex-wrap: wrap;
    }
}

/* Mobil nézet (767px alatt) */
@media (max-width: 767px) {
    .chart-container {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Az Összes vizsgálat és MD/IVD chartok egymás mellett maradnak */
    #chart1,
    #chart2 {
        flex: 1 1 45%;
        max-width: 45%;
    }

    /* Legend-container teljes szélességben */
    #legend-container {
        flex: 1 1 100%;
        max-width: 100%;
        align-items: center;
    }

    #legend-container #legend {
        flex-direction: row;
        gap: 10px;
        column-gap: 20px;
    }

    /* Study Types chart és legendája egymás alatt */
    #legend-container3,
    #chart3 {
        flex: 1 1 100%;
        max-width: 100%;
    }

    /* A Study Types legendája a chart fölött */
    #legend-container3 {
        order: 4;
    }

    #chart3 {
        order: 5;
    }

    /* Igazítás */
    #legend-container #legend,
    #legend-container3 #legend3 {
        flex-wrap: wrap;
        justify-content: center;
    }
}