/* Pie Chart Calculator — tool-specific styles */

/* Slice color picker (fills the box up to the border, no inner padding) */
.pie-chart-color {
    width: 34px;
    height: 30px;
    padding: 0;
    border: 1px solid #d7d5d5;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    vertical-align: middle;
}

.pie-chart-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.pie-chart-color::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.pie-chart-color::-moz-color-swatch {
    border: none;
    border-radius: 3px;
}

/* Keep the input table within the box on desktop (avoid a horizontal scrollbar) */
#pieChartInputTable .th-min-w100 {
    min-width: 78px;
}

/* Result download buttons (Image / PDF) */
.res-download-btns {
    display: flex;
    align-items: center;
    gap: 20px;
}

.res-download-btns>div {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

/* Whole remove-row cell is clickable */
.pie-chart-cross-icon {
    cursor: pointer;
}

/* Chart + custom wrapping HTML legend layout */
#pie-export {
    display: flex;
}

#pie-export.legend-bottom {
    flex-direction: column;
}

#pie-export.legend-top {
    flex-direction: column-reverse;
}

#pie-export .pie-chart {
    flex: 1 1 auto;
    min-width: 0;
    overflow: visible;
}

/* Allow AnyChart SVG labels to render outside the chart container bounds.
   We must also make every ancestor non-clipping. */
#result-div,
#result-div > div,
#result-div svg,
#result-div > div > svg {
    overflow: visible !important;
}

/* Prevent any ancestor from clipping the overflowing SVG labels */
#tool_results,
#pie-export,
#pie-export .pie-chart {
    overflow: visible !important;
}

.pie-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 8px 18px;
    padding: 12px 10px;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #333;
}

.pie-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex: 0 0 auto;
}

/* Chart style / label / legend option selects */
.pie-chart-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 15px;
    margin-block: 10px;
}

.pie-chart-options select {
    padding: 5px 4px;
    margin-bottom: 10px;
}

/* Mobile: single-column options + a more compact input table */
@media (max-width: 550px) {
    .pie-chart-options {
        grid-template-columns: 1fr;
    }

    body:has(#dont-remove-pie-chart) .box {
        padding-left: 10px;
        padding-right: 10px;
    }

    .pie-chart-input {
        font-size: 14px;
        margin: 5px 2px;
        width: 42px !important;
    }

    .pie-chart-color {
        width: 24px;
        height: 24px;
    }

    #pieChartInputTable .percentage,
    #pieChartInputTable .angle {
        font-size: 14px;
    }

    #pieChartInputTable th {
        font-size: 13px;
        padding: 0 2px;
    }

    #pieChartInputTable td {
        padding: 0 2px;
    }

    /* Give the chart extra vertical padding so outside labels don't get cut */
    #pie-export {
        padding: 16px 0;
    }

    /* Ensure the chart SVG and all ancestors are never clipped on mobile */
    #result-div,
    #result-div > div,
    #result-div svg,
    #tool_results {
        overflow: visible !important;
    }
}
