.rz-spider-chart {
    position: relative !important;
    display: block;
    height: 100%;
    width: 100%;

    // Grid elements styling moved to specific classes below

    // Chart wrapper with flexbox layout
    .rz-spider-chart-wrapper {
        display: flex !important;
        height: 100%;
        align-items: center;
        flex-direction: row;
        gap: 16px;
        justify-content: flex-start;

        // SVG chart takes remaining space
        > svg {
            flex: 1 1 auto;
            overflow: visible;
            min-width: 0;
            min-height: 0;
        }

        // Legend panel beside chart
        > .rz-spider-legend {
            flex: 0 0 auto;
            max-height: 100%;
            overflow-y: auto;
            padding: 0.75rem;
        }

        // Legend positioning variations
        &.rz-spider-legend-left {
            flex-direction: row-reverse;
        }
        
        &.rz-spider-legend-top {
            flex-direction: column;
            align-items: stretch;

            > .rz-spider-legend {
                order: -1;
                align-self: center;
                width: auto;
                max-width: 100%;
                max-height: none;

                .rz-legend-items {
                    flex-direction: row;
                    flex-wrap: wrap;
                    justify-content: center;
                    gap: 1rem;
                    width: 100%;
                }
            }
        }

        &.rz-spider-legend-bottom {
            flex-direction: column;
            align-items: stretch;

            > .rz-spider-legend {
                align-self: center;
                width: auto;
                max-width: 100%;
                max-height: none;

                .rz-legend-items {
                    flex-direction: row;
                    flex-wrap: wrap;
                    justify-content: center;
                    gap: 1rem;
                    width: 100%;
                }
            }
        }
    }
    
    .rz-spider-chart-hit-area {
        cursor: pointer;
    }

    .rz-spider-chart-grid-polygon {
        fill: none;
        stroke: var(--rz-chart-axis-color);
        stroke-width: 1;
    }

    .rz-spider-chart-grid-circle {
        fill: none;
        stroke: var(--rz-chart-axis-color);
        stroke-width: 1;
    }

    .rz-spider-chart-grid-line {
        stroke: var(--rz-chart-axis-color);
        stroke-width: 1;
    }

    .rz-spider-chart-label {
        font-size: 0.875rem;
        fill: var(--rz-text-color) !important;
        user-select: none;
        pointer-events: none;
    }

    .rz-spider-chart-info-panel {
        display: flex;
        gap: 1rem;
        margin-left: 1rem;
    }

    .rz-spider-chart-details {
        width: 180px;
        display: flex;
        flex-direction: column;

        .rz-spider-chart-details-header {
            height: 31px;
            padding: 8px 12px 4px 12px;
            display: flex;
            align-items: center;
            font-weight: 600;
            font-size: 13px;
            color: var(--rz-text-title-color);
        }

        .rz-spider-chart-details-content {
            flex: 1;
            padding: 0 12px 12px 12px;
            overflow-y: auto;
        }

        .rz-spider-chart-details-series-name {
            font-weight: 600;
            font-size: 14px;
            margin-bottom: 12px;
            color: inherit;
        }

        .rz-spider-chart-details-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 6px;
            font-size: 12px;

            .rz-spider-chart-details-category {
                color: var(--rz-text-secondary-color);
            }

            .rz-spider-chart-details-value {
                font-weight: 500;
            }
        }

        .rz-spider-chart-details-placeholder {
            opacity: 0.5;
            font-size: 12px;
            color: var(--rz-text-secondary-color);
            text-align: center;
            padding: 20px 0;
        }
    }


    .rz-spider-chart-area {
        cursor: pointer;
        transition: stroke-width 0.3s ease-in-out, opacity 0.3s ease-in-out, fill-opacity 0.3s ease-in-out;
        fill-opacity: 0.2;
        stroke-linejoin: round;
        stroke-linecap: round;
        stroke-opacity: 1;
        
        &[data-stroke-width="1"] { stroke-width: 1; }
        &[data-stroke-width="2"] { stroke-width: 2; }
        &[data-stroke-width="3"] { stroke-width: 3; }
        &[data-stroke-width="4"] { stroke-width: 4; }
        
        &.rz-state-hover {
            fill-opacity: 0.5;
            stroke-opacity: 1;
            
            &[data-stroke-width="1"] { stroke-width: 1.5; }
            &[data-stroke-width="2"] { stroke-width: 3; }
            &[data-stroke-width="3"] { stroke-width: 4.5; }
            &[data-stroke-width="4"] { stroke-width: 6; }
        }
        
        &.rz-state-hidden {
            opacity: 0;
        }
    }

    .rz-spider-chart-column {
        cursor: pointer;
        transition: opacity 0.3s ease-in-out, fill-opacity 0.3s ease-in-out;
        fill-opacity: 0.7;
        stroke: var(--rz-base-background-color);
        stroke-width: 1;

        &.rz-state-hover {
            fill-opacity: 0.9;
        }

        &.rz-state-hidden {
            opacity: 0;
        }
    }

    .rz-spider-chart-marker {
        cursor: pointer;
        transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
        pointer-events: all;
        stroke-width: 2;
        
        &.rz-state-hover {
            transform: scale(1.25);
            transform-origin: center;
        }
        
        &.rz-state-hidden {
            opacity: 0;
        }
    }

    // Spider legend styles
    .rz-spider-legend {
        display: flex;
        flex-direction: column;

        .rz-legend-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
            padding-bottom: 0.5rem;
            border-bottom: 1px solid var(--rz-border-color);
        }

        .rz-legend-title {
            font-weight: 600;
            font-size: 0.875rem;
            color: var(--rz-text-title-color);
        }

        .rz-legend-actions {
            display: flex;
            gap: 0.25rem;

            .rz-button {
                padding: 0.125rem 0.5rem;
                font-size: 0.75rem;
                min-height: unset;
                line-height: 1.2;
            }
        }

        .rz-legend-items {
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
            width: max-content;
        }

        .rz-legend-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.25rem;
            cursor: pointer;
            border-radius: var(--rz-border-radius);
            transition: background-color 0.2s;
            white-space: nowrap;

            &:hover {
                background-color: var(--rz-base-200);
            }

            &:focus {
                outline: 2px solid var(--rz-primary);
                outline-offset: -2px;
            }

            svg {
                flex-shrink: 0;
            }

            .rz-legend-item-text {
                font-size: 0.875rem;
                color: var(--rz-text-color);
                user-select: none;
            }
        }
    }

    &.rz-animate {
        path {
            stroke-dasharray: 1000;
            stroke-dashoffset: 1000;
            animation: spider-draw 1s ease-out forwards;
        }

        circle {
            opacity: 0;
            animation: spider-fade-in 0.3s ease-out 0.8s forwards;
        }
    }
}

@keyframes spider-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes spider-fade-in {
    to {
        opacity: 1;
    }
}