/* TCC Bullion Chart — minimal, theme-agnostic */

.tcc-bullion-chart {
    --tcc-chart-height: 380px;
    font-family: inherit;
    color: inherit;
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: #fff;
}

.tcc-bullion-chart__title {
    margin: 0 0 8px 0;
    font-size: 1.1em;
    font-weight: 600;
}

.tcc-bullion-chart__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.tcc-bullion-chart__metals,
.tcc-bullion-chart__ranges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tcc-bullion-chart__metal,
.tcc-bullion-chart__range {
    appearance: none;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #f6f7f9;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 4px;
    cursor: pointer;
    color: inherit;
    transition:
        background 0.12s,
        border-color 0.12s;
}

.tcc-bullion-chart__metal:hover,
.tcc-bullion-chart__range:hover {
    background: #ebedf0;
}

.tcc-bullion-chart__metal.is-active,
.tcc-bullion-chart__range.is-active {
    background: #1d2327;
    color: #fff;
    border-color: #1d2327;
}

.tcc-bullion-chart__legend {
    font-size: 13px;
    margin: 4px 0 8px;
    min-height: 1.4em;
    font-variant-numeric: tabular-nums;
}

.tcc-bullion-chart__legend .tcc-legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 14px;
}

.tcc-bullion-chart__legend .tcc-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.tcc-bullion-chart__canvas {
    width: 100%;
    height: var(--tcc-chart-height);
    position: relative;
}

.tcc-bullion-chart__canvas .uplot,
.tcc-bullion-chart__canvas .u-wrap {
    width: 100% !important;
}

.tcc-bullion-chart__status {
    font-size: 12px;
    color: #666;
    margin-top: 6px;
    min-height: 1.2em;
}

.tcc-bullion-chart.is-loading .tcc-bullion-chart__canvas {
    opacity: 0.55;
}
.tcc-bullion-chart.is-error .tcc-bullion-chart__status {
    color: #b32d2e;
}

/* ---- Hover tooltip & point highlight ---- */
.tcc-chart-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    background: rgba(29, 35, 39, 0.94);
    color: #fff;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.35;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    font-variant-numeric: tabular-nums;
    transition: opacity 0.08s ease-out;
}

.tcc-chart-tooltip__time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
}

.tcc-chart-tooltip__row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tcc-chart-tooltip__swatch {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.tcc-chart-tooltip__label {
    font-weight: 600;
}

.tcc-chart-tooltip__price {
    margin-left: 4px;
}

.tcc-chart-dot {
    position: absolute;
    pointer-events: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #444;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
    z-index: 4;
}

.tcc-bullion-chart__footer {
    margin-top: 6px;
    font-size: 11px;
    color: #6b7280;
    text-align: right;
    letter-spacing: 0.01em;
}

/* ---- Mobile ---- */
@media (max-width: 560px) {
    .tcc-bullion-chart {
        --tcc-chart-height: 300px;
        padding: 8px;
        border-radius: 6px;
    }

    .tcc-bullion-chart__toolbar {
        gap: 6px 8px;
        margin-bottom: 6px;
    }

    /* Let the range buttons share a single row instead of wrapping */
    .tcc-bullion-chart__ranges {
        flex-wrap: nowrap;
        width: 100%;
        justify-content: space-between;
        gap: 4px;
    }

    .tcc-bullion-chart__metals {
        flex-wrap: wrap;
    }

    .tcc-bullion-chart__metal,
    .tcc-bullion-chart__range {
        flex: 1 1 auto;
        min-width: 0;
        padding: 5px 6px;
        font-size: 11px;
        text-align: center;
    }

    .tcc-bullion-chart__legend {
        font-size: 12px;
        margin: 2px 0 6px;
    }

    .tcc-bullion-chart__footer {
        font-size: 10px;
        text-align: center;
    }

    /* uPlot tooltip: keep it compact on tiny screens */
    .tcc-chart-tooltip {
        padding: 6px 8px;
        font-size: 11px;
    }
}

@media (max-width: 380px) {
    .tcc-bullion-chart {
        --tcc-chart-height: 260px;
    }
    .tcc-bullion-chart__metal,
    .tcc-bullion-chart__range {
        padding: 4px 4px;
        font-size: 10px;
    }
}

/* ---- Dashboard wrapper (chart + side panels) ---- */
.tcc-bullion-dashboard {
    display: grid;
    gap: 16px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

/* Default: chart on the left, panels stacked on the right (desktop). */
.tcc-bullion-dashboard--right {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
}

.tcc-bullion-dashboard--left {
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
}
.tcc-bullion-dashboard--left .tcc-bullion-dashboard__panels {
    order: -1;
}

.tcc-bullion-dashboard--bottom {
    grid-template-columns: minmax(0, 1fr);
}
.tcc-bullion-dashboard--bottom .tcc-bullion-dashboard__panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.tcc-bullion-dashboard.is-chart-only {
    grid-template-columns: minmax(0, 1fr);
}

.tcc-bullion-dashboard__chart-wrap {
    min-width: 0;
}

.tcc-bullion-dashboard__panels {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Panels are full-width inside the column on desktop. */
.tcc-bullion-dashboard__panels > .tcc-bullion-pricepanel,
.tcc-bullion-dashboard__panels > .tcc-bullion-perf,
.tcc-bullion-dashboard__panels > .tcc-bullion-ratio {
    max-width: none;
}

/* Stack everything on narrower viewports so panels never squeeze the chart.
   Also surface the price/perf panels ABOVE the chart on mobile so the user
   can see the headline price + day's range without scrolling past a tall
   chart canvas first. */
@media (max-width: 860px) {
    .tcc-bullion-dashboard--right,
    .tcc-bullion-dashboard--left {
        grid-template-columns: minmax(0, 1fr);
    }
    .tcc-bullion-dashboard--right .tcc-bullion-dashboard__panels,
    .tcc-bullion-dashboard--left .tcc-bullion-dashboard__panels {
        order: -1;
    }
    .tcc-bullion-dashboard--right .tcc-bullion-dashboard__chart-wrap,
    .tcc-bullion-dashboard--left .tcc-bullion-dashboard__chart-wrap {
        order: 0;
    }
}
