/**
 * mod_portfolio_display — theme-adaptive styles.
 * Inherits text color from the site template and uses semi-transparent
 * neutrals so the same CSS reads on both light and dark backgrounds.
 */
.mod-portfolio-display {
    --mpd-neutral-soft:   rgba(127, 127, 127, 0.10);
    --mpd-neutral-medium: rgba(127, 127, 127, 0.18);
    --mpd-border:         rgba(127, 127, 127, 0.30);
    --mpd-accent:         var(--bs-primary, #2563eb);
    --mpd-muted-opacity:  0.65;

    font-family: inherit;
    color: inherit;
    font-size: 1rem;
    line-height: 1.5;
}

.mod-portfolio-display .mpd-login-required,
.mod-portfolio-display .mpd-muted {
    color: inherit;
    opacity: var(--mpd-muted-opacity);
}

/* Empty state */
.mod-portfolio-display .mpd-empty {
    text-align: center;
    padding: 1.2em 0.8em;
}

.mod-portfolio-display .mpd-empty-text {
    color: inherit;
    opacity: var(--mpd-muted-opacity);
    margin-bottom: 0.8em;
    font-size: 0.95em;
}

.mod-portfolio-display .mpd-empty-cta {
    display: inline-block;
    padding: 0.55em 1.1em;
    background: var(--mpd-accent);
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.15s;
}

.mod-portfolio-display .mpd-empty-cta:hover {
    opacity: 0.88;
    color: #fff;
    text-decoration: none;
}

/* Total row */
.mod-portfolio-display .mpd-total {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 0.7em;
    padding-bottom: 0.6em;
    border-bottom: 1px solid var(--mpd-border);
    font-size: 1rem;
}

.mod-portfolio-display .mpd-total-label {
    color: inherit;
    opacity: var(--mpd-muted-opacity);
}

.mod-portfolio-display .mpd-total-value {
    /* Push value (and the toggle after it) to the right side. */
    margin-left: auto;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: inherit;
}

/* Position list */
.mod-portfolio-display .mpd-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mod-portfolio-display .mpd-row {
    padding: 0.55em 0;
    border-bottom: 1px solid var(--mpd-border);
}

.mod-portfolio-display .mpd-row:last-child {
    border-bottom: none;
}

.mod-portfolio-display .mpd-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.8em;
    margin-bottom: 0.3em;
    font-size: 0.95rem;
}

.mod-portfolio-display .mpd-row-ident {
    display: flex;
    align-items: baseline;
    gap: 0.5em;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

.mod-portfolio-display .mpd-ticker {
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-weight: 600;
    color: var(--mpd-accent);
    font-size: 0.95em;
}

.mod-portfolio-display .mpd-name {
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.mod-portfolio-display .mpd-isin {
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 0.82em;
    opacity: 0.55;
    color: inherit;
}

.mod-portfolio-display .mpd-wert {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: inherit;
    white-space: nowrap;
}

.mod-portfolio-display .mpd-currency {
    font-size: 0.78em;
    color: inherit;
    opacity: 0.6;
    margin-left: 0.2em;
    font-weight: normal;
}

/* Gewichtung bar */
.mod-portfolio-display .mpd-bar {
    position: relative;
    height: 6px;
    background: var(--mpd-neutral-soft);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.35em;
}

.mod-portfolio-display .mpd-bar-fill {
    height: 100%;
    background: var(--mpd-accent);
    border-radius: 3px;
    transition: width 0.3s ease-out;
}

.mod-portfolio-display .mpd-bar-label {
    position: absolute;
    right: 0;
    top: -1.3em;
    font-size: 0.78em;
    color: inherit;
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
}

/* More-button: clicking reveals the next batch of hidden positions */
.mod-portfolio-display .mpd-row.mpd-row--hidden {
    display: none;
}
.mod-portfolio-display .mpd-more {
    display: block;
    width: 100%;
    text-align: center;
    margin: 0.4em 0 0;
    padding: 0.5em 0.75em;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: inherit;
    opacity: 0.65;
    font: inherit;
    font-size: 0.88em;
    cursor: pointer;
    transition: opacity 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.mod-portfolio-display .mpd-more:hover,
.mod-portfolio-display .mpd-more:focus-visible {
    opacity: 1;
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--mpd-accent, rgba(255, 255, 255, 0.35));
    color: var(--mpd-accent, inherit);
    outline: none;
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-more {
    border-color: rgba(0, 0, 0, 0.18);
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-more:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mod-portfolio-display .mpd-edit-link {
    text-align: right;
    padding-top: 0.7em;
    margin: 0;
}

.mod-portfolio-display .mpd-edit-link a {
    color: var(--mpd-accent);
    text-decoration: none;
    font-size: 0.92em;
}

.mod-portfolio-display .mpd-edit-link a:hover {
    text-decoration: underline;
}

/* ─── Value-mode toggle (sits to the right of the total value) ───────── */
.mod-portfolio-display .mpd-value-mode-toggle {
    display: inline-flex;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-value-mode-toggle {
    border-color: rgba(0, 0, 0, 0.15);
}
.mod-portfolio-display .mpd-value-mode-toggle button {
    padding: 4px 12px;
    background: transparent;
    color: inherit;
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.88em;
    font-weight: 600;
    transition: background 120ms ease, color 120ms ease;
}
.mod-portfolio-display .mpd-value-mode-toggle button:hover {
    background: rgba(255, 255, 255, 0.04);
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-value-mode-toggle button:hover {
    background: rgba(0, 0, 0, 0.04);
}
.mod-portfolio-display .mpd-value-mode-toggle button.is-active {
    background: var(--mpd-accent, #C8A96E);
    color: #0A0F18;
}

/* ─── Donut chart ─────────────────────────────────────────────────────
   SVG donut with stroke-dasharray slices. Track ring sits beneath in case
   slices don't sum to 100 (defensive). Center shows total value (only in
   € mode — hidden via .mpd-mode-percent class when toggle is on %). */
.mod-portfolio-display .mpd-chart-container {
    position: relative;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto 1.2em;
    /* viewBox is 240x160 (3:2) — wider than tall to give room for the
       outward callout columns and full position names. */
    aspect-ratio: 3 / 2;
}
.mod-portfolio-display .mpd-chart {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}
/* Mode-based SVG visibility — both are pre-rendered in the DOM, CSS
   shows one. Default container class is mpd-chart-mode-summary; JS
   swaps to mpd-chart-mode-all when toggled. */
.mod-portfolio-display .mpd-chart-mode-summary .mpd-chart-svg-all { display: none; }
.mod-portfolio-display .mpd-chart-mode-all     .mpd-chart-svg-summary { display: none; }
/* Toggle-button label visibility mirrors the chart visibility. */
.mod-portfolio-display .mpd-chart-mode-summary .mpd-chart-toggle-show-summary { display: none; }
.mod-portfolio-display .mpd-chart-mode-all     .mpd-chart-toggle-show-all     { display: none; }
.mod-portfolio-display .mpd-chart-track {
    stroke: rgba(255, 255, 255, 0.04);
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-chart-track {
    stroke: rgba(0, 0, 0, 0.05);
}
.mod-portfolio-display .mpd-pie-slice {
    cursor: pointer;
    transition: opacity 140ms ease;
}
/* Inner percentage labels — kept small so they sit comfortably inside
   the donut stroke without crowding. Threshold ≥2.5% applied in template. */
.mod-portfolio-display .mpd-chart-pct {
    font-size: 3px;
    font-weight: 700;
    fill: #FFFFFF;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.35);
    stroke-width: 0.4px;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
}
/* Outer name labels — theme-aware text colour. Font kept small so full
   (untruncated) names fit even for long entries. */
.mod-portfolio-display .mpd-chart-name {
    font-size: 3.4px;
    fill: rgba(244, 246, 250, 0.88);
    pointer-events: none;
    font-family: inherit;
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-chart-name {
    fill: rgba(26, 31, 38, 0.85);
}
/* Leader lines — match slice colour, thin, no pointer events. */
.mod-portfolio-display .mpd-chart-line {
    stroke-width: 0.4px;
    opacity: 0.55;
    pointer-events: none;
}
.mod-portfolio-display .mpd-chart-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 1.6em;
    color: inherit;
}
.mod-portfolio-display .mpd-chart-center-value {
    line-height: 1.2;
}
/* Hide the centre value when the toggle is in % mode — the whole donut
   already represents 100%, so showing "100,0 %" inside is redundant. */
.mod-portfolio-display.mpd-mode-percent .mpd-chart-center {
    display: none;
}

/* Aggregation toggle — sits in the chart's top-right corner. Subtle
   background that adapts to the theme, gentle hover state. Text content
   swaps via the two inner spans based on the container's mode class. */
.mod-portfolio-display .mpd-chart-toggle-agg {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 5px 10px;
    color: inherit;
    font: inherit;
    font-size: 0.78em;
    line-height: 1.2;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.mod-portfolio-display .mpd-chart-toggle-agg:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-chart-toggle-agg {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.12);
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-chart-toggle-agg:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}

/* Hover tooltip (appended to body, positioned fixed) */
.mpd-chart-tooltip {
    background: rgba(20, 24, 30, 0.96);
    color: #F4F6FA;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    max-width: 280px;
    z-index: 9999;
    transition: opacity 120ms ease;
    font-variant-numeric: tabular-nums;
}
[data-color-scheme="light"] .mpd-chart-tooltip {
    background: rgba(255, 255, 255, 0.98);
    color: #1A1F26;
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.mpd-chart-tooltip strong {
    font-weight: 700;
}

/* ─── Header (edit link + total + toggle) ───────────────────────────── */
.mod-portfolio-display .mpd-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 0.8em;
    padding-bottom: 0.6em;
    border-bottom: 1px solid var(--mpd-border);
    font-size: 1rem;
}
.mod-portfolio-display .mpd-header-edit-link {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    opacity: 0.85;
    transition: opacity 120ms ease;
}
.mod-portfolio-display .mpd-header-edit-link:hover {
    opacity: 1;
    text-decoration: underline;
}
.mod-portfolio-display .mpd-header-value {
    margin-left: auto;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: inherit;
}

/* ─── List footer (more + less buttons) ────────────────────────────── */
.mod-portfolio-display .mpd-list-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 0.7em;
}
.mod-portfolio-display .mpd-less {
    /* Same visual treatment as .mpd-more for consistency */
    background: transparent;
    color: inherit;
    border: 1px dashed var(--mpd-border);
    border-radius: 6px;
    padding: 10px 16px;
    font: inherit;
    font-size: 0.9em;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 120ms ease, background 120ms ease;
}
.mod-portfolio-display .mpd-less:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.03);
}
[data-color-scheme="light"] .mod-portfolio-display .mpd-less:hover {
    background: rgba(0, 0, 0, 0.03);
}
