/* --------------------------------------------------------------------------
 * DonutChartCard — reusable styles for a "donut chart + legend" card.
 *
 * Expected DOM shape:
 *
 * <div class="donut-card">
 *     <div class="donut-card__header">…title…</div>
 *
 *     <div class="donut-wrap">
 *         <div class="donut-container">
 *             <svg class="donut-svg" viewBox="…">
 *                 <defs><filter id="donut-glow">…</filter></defs>
 *                 <circle class="donut-track" … />
 *                 <circle class="donut-slice [active|dimmed]" … />
 *                 …
 *             </svg>
 *             <div class="donut-center">
 *                 <span class="donut-center-caption">…</span>
 *                 <span class="donut-center-total">42</span>
 *                 <span class="donut-center-amount tier-xl">$12.00</span>
 *             </div>
 *         </div>
 *
 *         <div class="donut-legend">
 *             <div class="donut-legend-row [active|dimmed]">
 *                 <span class="donut-legend-swatch"></span>
 *                 <div class="donut-legend-name">…</div>
 *                 <div class="donut-legend-values">…</div>
 *             </div>
 *             …
 *         </div>
 *     </div>
 * </div>
 * -------------------------------------------------------------------------- */

.donut-card {
    height: 100%;
    min-height: 192px;
    display: flex;
    flex-direction: column;
    background-color: #1b1c1e;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
}

/* -------- Layout: donut on the left, legend on the right ----------------- */

.donut-wrap {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex-wrap: nowrap;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.donut-container {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
    align-self: center;
}

@media (max-width: 600px) {
    .donut-container {
        width: 130px;
        height: 130px;
    }
}

/* -------- The SVG pie ---------------------------------------------------- */

.donut-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    transform: rotate(-90deg);
}

.donut-track {
    fill: transparent;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 18;
}

.donut-slice {
    fill: transparent;
    stroke-width: 18;
    stroke-linecap: butt;
    cursor: pointer;
    pointer-events: stroke;
    transition:
        stroke-dasharray 0.6s ease,
        stroke-dashoffset 0.6s ease,
        stroke 0.3s ease,
        opacity 0.25s ease,
        filter 0.25s ease;
}

.donut-slice.dimmed {
    opacity: 0.18;
}

.donut-slice.active {
    filter: url(#donut-glow);
}

/* -------- Center overlay (inside the donut hole) ------------------------- */

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.donut-center-caption {
    color: #fff;
    font-size: 12px;
    letter-spacing: 0.04em;
    font-weight: bold;
    text-transform: uppercase;
}

.donut-center-total {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin-top: 2px;
    transition: color 0.25s ease;
}

.donut-center-count {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    margin-top: 4px;
}

.donut-center-pct {
    color: #fff;
    font-size: 14px;
    margin-top: 2px;
}

/* Center amount — size tier picks by the component (see tier-* modifiers). */
.donut-center-amount {
    color: #fff;
    font-weight: 600;
    margin-top: 2px;
    max-width: 100%;
    line-height: 1.1;
    transition: font-size 0.2s ease;
}

.donut-center-amount.tier-xl { font-size: 18px; }
.donut-center-amount.tier-lg { font-size: 16px; }
.donut-center-amount.tier-md { font-size: 14px; }
.donut-center-amount.tier-sm { font-size: 12px; }
.donut-center-amount.tier-xs { font-size: 10px; }

/* -------- Legend --------------------------------------------------------- */

.donut-legend {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.donut-legend::-webkit-scrollbar {
    width: 6px;
}

.donut-legend::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.donut-legend::-webkit-scrollbar-track {
    background: transparent;
}

.donut-legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    cursor: pointer;
    transition:
        opacity 0.25s ease,
        background-color 0.2s ease;
    border-radius: 20px;
}

.donut-legend-row:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.donut-legend-row.dimmed {
    opacity: 0.4;
}

.donut-legend-row.active {
    background-color: rgba(255, 255, 255, 0.05);
}

.donut-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.donut-legend-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 70px;
}

.donut-legend-values {
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
}

/* -------- Concentric rings variant (Position Summary V2) ---------------- */

/* Thinner strokes than the donut slices so two rings fit comfortably. */
.ring-svg .ring-track {
    fill: transparent;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 8;
}

.ring-svg .ring-bar {
    fill: transparent;
    stroke-width: 8;
    stroke-linecap: round;
    transition:
        stroke-dasharray 0.6s ease,
        stroke 0.3s ease;
}

/* Right-hand legend: pair of long/short rows, divider, three key/value rows. */
.ring-legend {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
}

.ring-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ring-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.ring-legend-values {
    margin-left: auto;
    white-space: nowrap;
}

.ring-legend-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 2px 0;
}

/* Row used while the host component is still loading data. */
.donut-legend-skeleton-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px 0 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.donut-legend-skeleton-row:last-child {
    border-bottom: none;
}
