/* =========================================================
   charts.css — chart containers, bracket visualizer
   ========================================================= */

/* =========================================================
   CHARTS SECTION WRAPPER
   ========================================================= */

.charts-section {
    margin-bottom: var(--space-xl);
}

.charts-section__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.charts-section__title i {
    color: var(--green-dark);
}

/* two charts side by side on desktop, stacked on mobile */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

/* ---- individual chart card ---- */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.chart-card__title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.chart-card__title i {
    font-size: 0.9rem;
    color: var(--green-dark);
}

/* donut canvas wrapper — fixed height keeps the chart from growing forever */
.chart-canvas-wrap {
    position: relative;
    width: 100%;
}

.chart-canvas-wrap--donut {
    max-width: 320px;
    margin: 0 auto;
}

.chart-canvas-wrap--bar {
    height: 80px; /* short bar — it's a single row */
}

.chart-canvas-wrap--bar canvas {
    width: 100% !important;
    height: 80px !important;
}

/* empty state shown before a salary is entered */
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-xl) 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.chart-empty i {
    font-size: 1.8rem;
    opacity: 0.4;
}

/* ---- colour legend row (sits below the bar chart) ---- */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm) var(--space-lg);
    margin-top: var(--space-sm);
}

.chart-legend__item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.chart-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-legend__dot--net   { background: var(--color-net);  }
.chart-legend__dot--paye  { background: var(--color-paye); }
.chart-legend__dot--shif  { background: var(--color-shif); }
.chart-legend__dot--nssf  { background: var(--color-nssf); }
.chart-legend__dot--levy  { background: var(--color-levy); }

/* =========================================================
   BRACKET VISUALIZER
   ========================================================= */

.bviz-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.bviz-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.bviz-card__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.bviz-card__title i {
    color: var(--color-paye);
}

.bviz-card__subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-lg);
}

/* ---- the segmented bar ---- */
.bviz-bar-wrap {
    position: relative;
    margin-bottom: var(--space-sm);
}

/* the bar itself — a flex row of coloured segments */
.bviz-bar {
    display: flex;
    height: 44px;
    border-radius: var(--radius-sm);
    overflow: visible; /* let marker poke above */
    gap: 2px;
    position: relative;
}

.bviz-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: opacity 0.3s ease, transform 0.3s ease;
    position: relative;
    min-width: 32px;
    cursor: default;
}

.bviz-segment--active {
    opacity: 1;
}

.bviz-segment--inactive {
    opacity: 0.35;
}

.bviz-segment__rate {
    font-size: 0.75rem;
    font-weight: 800;
    color: #92400E;
    pointer-events: none;
    white-space: nowrap;
}

/* inactive segments show rate in grey */
.bviz-segment--inactive .bviz-segment__rate {
    color: #9CA3AF;
}

/* ---- income marker line ---- */
.bviz-marker {
    position: absolute;
    top: -10px;
    bottom: -28px;
    width: 2px;
    background: var(--text-primary);
    transform: translateX(-50%);
    z-index: 10;
    display: none; /* shown by JS once salary is entered */
}

.bviz-marker::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: var(--text-primary);
    border-radius: 50%;
}

.bviz-marker-label {
    position: absolute;
    bottom: -38px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    background: var(--bg-card);
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* ---- bracket labels below the bar ---- */
.bviz-labels {
    display: flex;
    gap: 2px;
    margin-top: var(--space-xl); /* extra space for the marker label */
}

.bviz-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    padding: var(--space-xs);
}

.bviz-label__rate {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

.bviz-label--active .bviz-label__rate {
    color: #D97706;
}

.bviz-label__threshold {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- rate summary row below labels ---- */
.bviz-summary {
    display: flex;
    gap: var(--space-xl);
    flex-wrap: wrap;
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
}

.bviz-summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bviz-summary-item__label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.bviz-summary-item__value {
    font-size: 1.3rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.bviz-summary-item--effective .bviz-summary-item__value { color: var(--color-paye); }
.bviz-summary-item--marginal  .bviz-summary-item__value { color: var(--teal); }
.bviz-summary-item--taxable   .bviz-summary-item__value { color: var(--text-primary); font-size: 1rem; }

/* ---- empty state before salary entered ---- */
.bviz-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-style: italic;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 767px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .bviz-label__threshold {
        display: none; /* too cramped on small screens — rate % is enough */
    }

    .bviz-segment__rate {
        font-size: 0.68rem;
    }

    .bviz-summary {
        gap: var(--space-md);
    }
}
