@use 'variables' as *;

// ─── Charity distribution section (result card) ───────────────────────────────
.charity-dist-section {
    @include card;
    border-top: none;
    border-radius: 0 0 16px 16px;
    padding: 20px 24px;
}

.charity-dist-title {
    @include section-label;
    margin-bottom: 14px;
}

.charity-dist-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.charity-dist-card {
    border: 1px solid #eef0f4;
    border-radius: 10px;
    padding: 10px 12px;
}

.charity-dist-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    margin-bottom: 8px;
    color: $gray-500;
}

.charity-dist-name {
    font-weight: 700;
    color: $gray-700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.charity-dist-bars {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 5px;
    align-items: end;
    min-height: 88px;
}

.charity-dist-bar {
    width: 100%;
    border-radius: 6px 6px 0 0;
    min-height: 3px;
    background: $red-pale;
    opacity: 0.85;

    &.active {
        background: $red-primary;
        opacity: 1;
        outline: 2px solid #7f1d1d;
        outline-offset: -1px;
    }
}

.charity-dist-label-row {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 5px;
    margin-top: 6px;
}

.charity-dist-label {
    font-size: 0.62rem;
    text-align: center;
    color: $gray-400;
    line-height: 1.2;
}

// ─── Historical chart section (result card) ───────────────────────────────────
.historical-section {
    @include card;
    border-top: none;
    padding: 20px 24px;
}

.historical-title {
    @include section-label;
    margin-bottom: 14px;
}

.historical-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.historical-chart {
    border: 1px solid #eef0f4;
    border-radius: 10px;
    padding: 12px;
    background: #fafbfc;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    margin-bottom: 10px;
    color: $gray-500;
}

.chart-name {
    font-weight: 700;
    color: $gray-700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-height: 100px;
    margin-bottom: 4px;
}

.chart-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.chart-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    min-height: 3px;
    background: $red-pale;

    &.revenue { background: $red-primary; }
    &.assets   { background: $red-dark; }
    &.ceo      { background: $green; }
}

.chart-value {
    font-size: 0.68rem;
    font-weight: 600;
    color: $gray-700;
}

.chart-year {
    font-size: 0.64rem;
    color: $gray-400;
}

// Bar group hover interaction (shared across chart types)
.bar-group {
    .bar-tip {
        opacity: 0;
        transition: opacity 0.1s;
        pointer-events: none;
    }

    &:hover {
        .bar-tip  { opacity: 1; }
        .bar-fill { opacity: 0.75; }
    }
}

// ─── Distribution graphs (graphs page / modal) ────────────────────────────────
.graphs-wrap {
    max-width: 1000px;
    margin: 36px auto 0;
}

.graphs-title {
    font-size: 1rem;
    font-weight: 700;
    color: $navy;
    margin-bottom: 14px;
}

.graphs-subtitle {
    font-size: 0.82rem;
    color: $gray-500;
    margin-bottom: 18px;
}

.graphs-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.graph-card {
    background: $white;
    border: $border-width solid $border-color;
    border-radius: 14px;
    padding: 16px 18px;
}

.graph-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
}

.graph-name {
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: $gray-600;
}

.graph-meta {
    font-size: 0.75rem;
    color: $gray-400;
}

.dist-chart {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
    min-height: 170px;
}

.dist-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.dist-count {
    font-size: 0.7rem;
    color: $gray-500;
}

.dist-bar {
    width: 100%;
    min-height: 4px;
    border-radius: 8px 8px 0 0;
    background: $red-primary;
}

.dist-label {
    font-size: 0.66rem;
    color: $gray-500;
    text-align: center;
    line-height: 1.25;
}

// ─── Responsive ───────────────────────────────────────────────────────────────
@media (max-width: $bp-mobile) {
    .dist-chart,
    .charity-dist-bars,
    .charity-dist-label-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .historical-grid {
        grid-template-columns: 1fr;
    }
}
