/* ==========================================================================
   6. ГРАФИКИ
   ========================================================================== */



/* Примечание к графику */
.custom-chart-note {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    margin-top: 10px;
    font-style: italic;
}

/* Контейнер для столбчатого графика */
.custom-moor-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 300px;
    padding: 20px 0;
    border-bottom: 2px solid var(--color-border);
    position: relative;
    min-width: 500px;
}

/* Стиль для столбца графика */
.custom-chart-bar {
    background: linear-gradient(to top, var(--custom-secondary), var(--custom-primary));
    width: 60px;
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    opacity: 0;
    transform: scaleY(0);
    transform-origin: bottom;
    visibility: visible;
    flex-shrink: 0;
    animation: customBarAnimation 0.8s ease forwards;
}

/* Эффект при наведении на столбец */
.custom-chart-bar:hover {
    transform: scaleY(1.05);
    background: linear-gradient(to top, #5d7cb0, #3a506e);
}

/* Подпись под столбцом */
.custom-bar-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
}

/* Значение на вершине столбца */
.custom-bar-value {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--custom-primary);
}

/* Анимация появления столбцов */
@keyframes customBarAnimation {
    from {
        opacity: 0;
        transform: scaleY(0);
    }
    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

/* Анимационные задержки для каждого столбца */
.custom-chart-bar:nth-child(1) { animation-delay: 0.1s; }
.custom-chart-bar:nth-child(2) { animation-delay: 0.2s; }
.custom-chart-bar:nth-child(3) { animation-delay: 0.3s; }
.custom-chart-bar:nth-child(4) { animation-delay: 0.4s; }
.custom-chart-bar:nth-child(5) { animation-delay: 0.5s; }
.custom-chart-bar:nth-child(6) { animation-delay: 0.6s; }
.custom-chart-bar:nth-child(7) { animation-delay: 0.7s; }
.custom-chart-bar:nth-child(8) { animation-delay: 0.8s; }
.custom-chart-bar:nth-child(9) { animation-delay: 0.9s; }
.custom-chart-bar:nth-child(10) { animation-delay: 1.0s; }

/* ==========================================================================
   7.1. МНОГОКОМПОНЕНТНАЯ ДИАГРАММА
   ========================================================================== */

/* Контейнер для многокомпонентной диаграммы */
.custom-multi-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 350px;
    padding: 20px 0 40px 0;
    border-bottom: 2px solid var(--color-border);
    position: relative;
    min-width: 600px;
    gap: 15px;
}

/* Группа столбцов для одного периода */
.chart-period-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
    position: relative;
}

/* Контейнер для столбцов метрик внутри одного периода */
.chart-bars-group {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    gap: 4px;
    margin-bottom: 30px;
}

/* Подпись под группой столбцов */
.period-label {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    color: #666;
    white-space: nowrap;
    font-weight: 500;
    text-align: center;
    width: 100%;
}

/* Базовые стили для столбцов метрик в многокомпонентной диаграмме */
.custom-multi-chart .custom-chart-bar {
    background: linear-gradient(to top, var(--custom-secondary), var(--custom-primary));
    width: 23%;
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
    position: relative;
    transition: all var(--transition-bar);
    cursor: pointer;
    opacity: 1;
    transform: scaleY(1);
    transform-origin: bottom;
    visibility: visible;
    flex-shrink: 0;
    animation: customBarAnimation var(--animation-bar-duration) var(--animation-bar-timing) forwards;
    min-height: 5px;
}

/* Специфичные цвета для разных метрик */
.custom-multi-chart .metric-speed {
    background: linear-gradient(to top, #000000, var(--custom-secondary)) !important;
}

.custom-multi-chart .metric-density {
    background: linear-gradient(to top, var(--custom-secondary), #5d7cb0) !important;
}

.custom-multi-chart .metric-gain {
    background: linear-gradient(to top, #27ae60, #2ecc71) !important;
}

.custom-multi-chart .metric-efficiency {
    background: linear-gradient(to top, #e74c3c, #c0392b) !important;
}

/* Значение на вершине столбца в многокомпонентной диаграмме */
.custom-multi-chart .custom-bar-value {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--custom-primary);
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 4px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Легенда диаграммы */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 10px;
    background: var(--custom-light);
    border-radius: var(--border-radius-md);
}

/* Элемент легенды: цвет + текст */
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Цветной квадратик в легенде */
.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Текст в легенде */
.legend-text {
    font-size: 0.9rem;
    color: var(--color-text);
}

/* Цвета для легенды */
.metric-speed-color {
    background: linear-gradient(to top, #000000, var(--custom-secondary));
}

.metric-density-color {
    background: linear-gradient(to top, var(--custom-secondary), #5d7cb0);
}

.metric-gain-color {
    background: linear-gradient(to top, #27ae60, #2ecc71);
}

.metric-efficiency-color {
    background: linear-gradient(to top, #e74c3c, #c0392b);
}

/* ==========================================================================
   7.2. АДАПТИВНОСТЬ ГРАФИКОВ
   ========================================================================== */

/* --- Для планшетов и больших мобильных устройств --- */
@media (max-width: 768px) {
    .custom-multi-chart {
        height: 300px;
        min-width: 500px;
        gap: 10px;
        padding: 15px 0 35px 0;
    }

    .chart-bars-group {
        gap: 3px;
        margin-bottom: 25px;
    }

    .period-label {
        bottom: -25px;
        font-size: 0.8rem;
    }

    .custom-multi-chart .custom-bar-value {
        font-size: 0.65rem;
        top: -20px;
    }

    .custom-moor-chart {
        height: 250px;
        min-width: 400px;
        gap: 8px;
    }

    .custom-chart-bar {
        width: 45px;
    }

    .custom-bar-label {
        font-size: 0.7rem;
        bottom: -20px;
    }

    .custom-bar-value {
        font-size: 0.7rem;
        top: -20px;
    }

    .custom-chart-container {
        padding: 15px;
        margin: 15px 0;
    }
}

/* --- Для мобильных устройств --- */
@media (max-width: 480px) {
    .custom-multi-chart {
        height: 250px;
        min-width: 400px;
        gap: 8px;
        padding: 10px 0 30px 0;
    }

    .chart-bars-group {
        margin-bottom: 20px;
    }

    .period-label {
        bottom: -20px;
        font-size: 0.75rem;
    }

    .custom-multi-chart .custom-bar-value {
        font-size: 0.6rem;
        top: -18px;
        padding: 1px 3px;
    }

    .custom-moor-chart {
        height: 200px;
        min-width: 350px;
        gap: 5px;
        justify-content: space-around;
    }

    .custom-chart-bar {
        width: 35px;
        flex: 0 0 auto;
    }

    /* Наклонные подписи для мобильных */
    .custom-bar-label {
        font-size: 0.65rem;
        bottom: -18px;
        transform: translateX(-50%) rotate(-45deg);
        transform-origin: center;
        white-space: nowrap;
    }

    .custom-bar-value {
        font-size: 0.65rem;
        top: -18px;
    }

    .custom-table {
        font-size: 0.9rem;
    }

    .custom-table th,
    .custom-table td {
        padding: 8px;
    }
}

/* --- Для очень маленьких экранов --- */
@media (max-width: 360px) {
    .custom-multi-chart {
        min-width: 320px;
        height: 220px;
        gap: 5px;
    }

    .period-label {
        font-size: 0.7rem;
        bottom: -18px;
    }

    .custom-moor-chart {
        min-width: 320px;
        height: 180px;
    }

    .custom-chart-bar {
        width: 30px;
    }

    .custom-bar-label {
        font-size: 0.6rem;
        bottom: -16px;
    }

    .custom-bar-value {
        font-size: 0.6rem;
        top: -16px;
    }
}