[id*="slim_p"].postbox {
    box-sizing: border-box;
    margin-bottom: 2em;
    width: 100%;
}
[id*="slim_p"].postbox h3 {
    display: none;
}
[id*="slim_p"].postbox .inside {
    max-height: 24em;
    overflow: auto;
}
[id*="slim_p"].postbox p {
    border-bottom: 1px solid #ccc;
    padding: 5px 10px;
    margin: 0;
}
[id*="slim_p"].postbox p span {
    float: right;
    margin-left: 0.5em;
}
[id*="slim_p"].postbox p .slimstat-tooltip-content {
    display: none;
}

/* Charts */

.slimstat-postbox-custom-legend {
    display: flex;
    justify-content: flex-start;
    margin-top: 20px;
    gap: 40px;
    font-size: 14px;
}

#chartjs-tooltip {
    transition: 0.3s all ease-in-out;
    pointer-events: none !important;
    background: white;
    z-index: 9999;
    font: 13px "Open Sans", sans-serif;
    border: solid 1px #e0e0e0;
    border-radius: 12px;
    padding: 10px 18px;
    margin: 0;
    min-width: 180px;
    max-width: 320px;
    opacity: 0.98;
    filter: drop-shadow(0 2px 8px rgba(60, 60, 90, 0.1));
    &:hover {
        opacity: 0.3;
    }

    .slimstat-postbox-chart--item[data-index].active .tooltip-item-content {
        color: #000 !important;
    }
}

@media (max-width: 600px) {
    #chartjs-tooltip {
        min-width: 120px;
        max-width: 98vw;
        font-size: 12px;
        padding: 7px 8px;
    }
}

.slimstat-chart-wrap {
    position: relative;
}

span.slimstat-toggle-prev-datasets {
    position: absolute;
    right: 110px;
    max-width: 80%;
    display: inline-block;
    color: #56585a;
    font-weight: 600;
    vertical-align: top;
    font-size: 12px;
    cursor: pointer;
    font-style: oblique;
    opacity: 0.7;
    &.active {
        opacity: 1;
    }
}

.slimstat-chart-controls {
    position: absolute;
    right: 20px;
    text-align: right;

    & select {
        top: -3px;
        position: relative;
        display: inline-block;
        width: 84px;
        min-height: 11px !important;
        line-height: 22px !important;
        border: none;
        text-decoration: underline dashed 1px;
    }
}

.slimstat-postbox-chart--items {
    display: flex;
    column-gap: 25px;
    row-gap: 20px;
    margin-bottom: 5px;
    flex-wrap: wrap;
    padding: 0px 0px 0px 20px;
    align-items: baseline;
    @media (max-width: 550px) {
        column-gap: 40px;
    }
}

.slimstat-postbox-chart--item {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    cursor: pointer;

    &:not(:last-child) {
        margin-bottom: 5px;
    }

    &.slimstat-postbox-chart--item-hidden {
        opacity: 0.5;
    }

    & > span {
        font-size: 13px;
        font-style: italic;
        font-weight: 400;
        line-height: 15.23px;
        color: #56585a;
        text-transform: capitalize;

        &.slimstat-postbox-chart--item-label {
            font-weight: 500;
            font-size: 12px;
            font-style: italic;
        }
    }

    .slimstat-postbox-chart--item--color {
        display: inline-flex;
        width: 15px;
        border-radius: 2px;
        height: 5px;
        margin-right: 4px;
    }

    .slimstat-postbox-chart--item--prev {
        font-size: 9px;
        color: #616060;
        font-weight: bold;
        letter-spacing: -0.5px;
        margin: 0 3px;
        top: -1px;
        position: relative;
    }

    & > div {
        display: flex;
        gap: 16px;
        align-items: center;
        cursor: pointer;
    }
}

body.index-php {
    #dashboard-widgets-wrap .postbox .slimstat-tooltip-trigger.corner {
        display: inline-block;
        float: none;
        margin-right: 3px;
        cursor: help;
        left: 90px;
        top: 5px;
    }

    .slimstat-chart-wrap {
        max-width: 100% !important;
        width: 100%;
        aspect-ratio: 16/7;
        min-height: 160px;
        height: auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .inside:has(.slimstat-postbox-chart--canvas) {
        height: auto !important;
        min-height: 180px;
        max-height: none;
        margin-bottom: 20px !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .slimstat-postbox-chart--canvas {
        width: 100% !important;
        max-width: 100%;
        min-width: 100px;
        aspect-ratio: 16/7;
        height: auto !important;
        min-height: 120px;
        max-height: 60vw;
        border-radius: 7px;
        margin: 0 auto 8px auto;
        box-shadow: 0 1px 4px rgba(60, 60, 90, 0.04);
        display: block;
    }
    .slimstat-postbox-custom-legend,
    .slimstat-postbox-chart--items {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
        column-gap: 12px;
        row-gap: 8px;
        padding-left: 0;
        overflow-x: auto;
        font-size: 13px;
        width: 100%;
        box-sizing: border-box;
    }
    .slimstat-postbox-chart--item {
        padding: 3px 7px;
        font-size: 12px;
        border-radius: 5px;
        margin-bottom: 2px;
    }
    .slimstat-chart-controls {
        right: 10px;
        position: absolute;
        display: inline-block;
        width: 80px;
        text-align: left;
        left: unset;
        & select {
            width: 70px;
            font-size: 12px;
            padding: 1px 4px;
            border-radius: 5px;
        }
    }
    @media (max-width: 900px) {
        .slimstat-postbox-chart--canvas {
            aspect-ratio: 16/10;
            min-height: 90px;
            max-height: 50vw;
        }
    }
    @media (max-width: 600px) {
        .slimstat-postbox-custom-legend,
        .slimstat-postbox-chart--items {
            flex-direction: column;
            gap: 8px;
            column-gap: 8px;
            row-gap: 6px;
            font-size: 12px;
            width: 100%;
        }
        .slimstat-postbox-chart--canvas {
            min-width: 80px;
            aspect-ratio: 16/12;
            min-height: 60px;
            max-height: 40vw;
            border-radius: 5px;
        }
        .slimstat-chart-wrap {
            aspect-ratio: 16/12;
            min-height: 60px;
        }
    }
    @media (max-width: 400px) {
        .slimstat-postbox-chart--canvas {
            min-width: 60px;
            min-height: 40px;
            max-height: 30vw;
        }
        .slimstat-chart-wrap {
            min-height: 40px;
        }
    }
}

[dir="rtl"] .slimstat-postbox-custom-legend,
.rtl .slimstat-postbox-custom-legend {
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 40px;
    text-align: right;
}

[dir="rtl"] .slimstat-chart-controls,
.rtl .slimstat-chart-controls {
    right: auto;
    left: 20px;
    text-align: left;
}

[dir="rtl"] #chartjs-tooltip,
.rtl #chartjs-tooltip {
    direction: rtl;
    text-align: right;
    font-family: "Open Sans", sans-serif !important;
}

[dir="rtl"] .slimstat-postbox-custom-legend,
.rtl .slimstat-postbox-custom-legend,
[dir="rtl"] .slimstat-postbox-chart--items,
.rtl .slimstat-postbox-chart--items {
    direction: rtl;
    text-align: right;
    font-family: "Open Sans", sans-serif !important;
}

[dir="rtl"] .slimstat-postbox-chart--item,
.rtl .slimstat-postbox-chart--item {
    direction: rtl;
    text-align: right;
    font-family: "Open Sans", sans-serif !important;
}

[dir="rtl"] .tooltip-item-title,
.rtl .tooltip-item-title,
[dir="rtl"] .tooltip-item-content,
.rtl .tooltip-item-content {
    direction: rtl;
    text-align: right;
    font-family: "Open Sans", sans-serif !important;
}

[dir="rtl"] #chartjs-tooltip table,
.rtl #chartjs-tooltip table {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] #chartjs-tooltip tr.slimstat-postbox-chart--item td,
.rtl #chartjs-tooltip tr.slimstat-postbox-chart--item td {
    padding-right: 0;
    padding-left: 8px;
}

[dir="rtl"] .slimstat-postbox-chart--item,
.rtl .slimstat-postbox-chart--item {
    text-align: right;
    gap: 8px;
}

[dir="rtl"] #chartjs-tooltip tr.slimstat-postbox-chart--item {
    flex-direction: unset !important;
}

[dir="rtl"] .slimstat-toggle-prev-datasets {
    left: 120px !important;
    right: unset;
    direction: ltr;
}
[dir="rtl"] .slimstat-postbox-chart--items {
    padding: 0px 20px 0px 20px;
}

[dir="rtl"] .slimstat-postbox-chart--item > span,
.rtl .slimstat-postbox-chart--item > span {
    text-align: right;
}

[dir="rtl"] .slimstat-postbox-chart--item .slimstat-postbox-chart--item--color,
.rtl .slimstat-postbox-chart--item .slimstat-postbox-chart--item--color {
    margin-left: 0px !important;
    margin-right: 10px !important;
}

[dir="rtl"] #chartjs-tooltip .slimstat-postbox-chart--item .slimstat-postbox-chart--item--color,
.rtl #chartjs-tooltip .slimstat-postbox-chart--item .slimstat-postbox-chart--item--color {
    margin-left: 10px !important;
    margin-right: 10px !important;
}

[dir="rtl"] .slimstat-postbox-chart--item:not(:first-child) {
    margin-bottom: 0px;
}

[dir="rtl"] .slimstat-postbox-chart--item:not(:last-child) {
    margin-bottom: 0px;
}

[dir="rtl"] .slimstat-postbox-chart--item .slimstat-postbox-chart--item--prev,
.rtl .slimstat-postbox-chart--item .slimstat-postbox-chart--item--prev {
    margin: 0 3px 0 0;
}

[dir="rtl"] .tooltip-item-title,
.rtl .tooltip-item-title {
    text-align: right;
}

[dir="rtl"] .tooltip-item-content,
.rtl .tooltip-item-content {
    direction: rtl;
    text-align: right;
}

.slimstat-tooltip-trigger {
    .slimstat-tooltip-bar-wrap {
        z-index: 0 !important;
        position: absolute;
        display: block;
        width: calc(100% - 30px);
        height: 100%;
        top: 0;
        left: 0;
        margin: 0px 15px;
        box-sizing: border-box;
    }

    * {
        z-index: 2 !important;
        position: relative;
    }

    a {
        max-width: 80%;
        display: inline-block;
        color: #202224;
        font-weight: 600;
        vertical-align: middle;
        font-size: 12px;
    }
}
.slimstat-tooltip-content {
    display: none;
}
[id^="slim_"] p .slimstat-tooltip-trigger.corner {
    -moz-transform: scaleX(-1);
    -o-transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    transform: scaleX(-1);
    filter: FlipH;
    -ms-filter: "FlipH";
    left: 0;
}
.tooltip-item-title {
    font-size: 13px;
    font-weight: 500;
}
.tooltip-item-content {
    font-size: 13px;
    font-weight: normal;
    font-style: italic;
}

/* Bar Chart Styles */
.slimstat-chart-wrap .slimstat-postbox-chart--canvas {
    transition: all 0.3s ease;
}

/* Bar chart specific styling */
.chart-bar .slimstat-postbox-chart--canvas {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Bar chart hover effects */
.chart-bar .slimstat-postbox-chart--canvas:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Legend styling for bar charts */
.chart-bar .slimstat-postbox-chart--item {
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.chart-bar .slimstat-postbox-chart--item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.chart-bar .slimstat-postbox-chart--item--color {
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Animation for bar charts */
@keyframes barChartLoad {
    from {
        opacity: 0;
        transform: scaleY(0);
        transform-origin: bottom;
    }
    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

.chart-bar .slimstat-postbox-chart--canvas {
    animation: barChartLoad 0.6s ease-out;
}

/* Responsive bar chart adjustments */
@media (max-width: 768px) {
    .chart-bar .slimstat-postbox-chart--canvas {
        height: 200px !important;
    }

    .chart-bar .slimstat-postbox-chart--items {
        flex-direction: column;
        gap: 8px;
    }

    .chart-bar .slimstat-postbox-chart--item {
        padding: 6px 10px;
        font-size: 13px;
    }
}

/* Bar chart loading state */
.chart-bar.loading .slimstat-postbox-chart--canvas {
    opacity: 0.6;
    filter: blur(1px);
}

/* Bar chart peak highlighting */
.chart-bar .bar-peak {
    background: linear-gradient(135deg, #e8294c 0%, #ff6b7d 100%) !important;
    box-shadow: 0 4px 12px rgba(232, 41, 76, 0.3) !important;
    transform: scaleY(1.1);
    z-index: 10;
}
