/* ================================================================
   TradeButtons Dashboard Widgets — Mini Stat Karten
   Coin-Preis, Dominanz, Market Cap, Fear & Greed
   ================================================================ */

/* ── Coin Stat Karte ─────────────────────────────────────────────── */

.tbdw-coin-stat {
    position: absolute;   /* füllt tbdw-panel-content (position:relative) komplett */
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 18px 14px;
    background: linear-gradient(145deg, rgba(15,23,42,.95), rgba(11,15,22,.98));
    overflow: hidden;
}

/* Dezenter Hintergrund-Glow */
.tbdw-coin-stat::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(45,212,191,.08) 0%, transparent 70%);
    pointer-events: none;
}

.tbdw-coin-stat__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.tbdw-coin-stat__logo-wrap {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.tbdw-coin-stat__logo-letter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    color: #94a3b8;
    transition: opacity .3s;
}

.tbdw-coin-stat__logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: contain;
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .3s;
}

.tbdw-coin-stat__logo.loaded {
    opacity: 1;
}
.tbdw-coin-stat__logo.loaded + .tbdw-coin-stat__logo-letter,
.tbdw-coin-stat__logo-letter.hidden {
    opacity: 0;
}

.tbdw-coin-stat__meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.tbdw-coin-stat__name {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tbdw-coin-stat__symbol {
    font-size: 11px;
    color: #475569;
    font-weight: 500;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* Preis — die wichtigste Zahl, groß */
.tbdw-coin-stat__price {
    font-size: 26px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -.02em;
    line-height: 1;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

/* 24h Change */
.tbdw-coin-stat__change {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: auto;
    padding: 3px 8px;
    border-radius: 20px;
    display: inline-block;
    align-self: flex-start;
    background: rgba(255,255,255,.05);
    transition: color .3s, background .3s;
}

.tbdw-coin-stat__change.is-gain {
    color: #22c55e;
    background: rgba(34,197,94,.1);
}

.tbdw-coin-stat__change.is-loss {
    color: #f87171;
    background: rgba(248,113,113,.1);
}

/* Footer mit Market Cap */
.tbdw-coin-stat__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,.06);
}

.tbdw-coin-stat__mcap-label {
    font-size: 10px;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.tbdw-coin-stat__mcap {
    font-size: 11px;
    color: #475569;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ── Market Stat Karte (Dominance, Market Cap) ───────────────────── */

.tbdw-market-stat {
    position: absolute;   /* füllt tbdw-panel-content komplett */
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 18px;
    text-align: center;
    gap: 6px;
    background: linear-gradient(145deg, rgba(15,23,42,.95), rgba(11,15,22,.98));
}

.tbdw-market-stat__icon {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 2px;
    filter: drop-shadow(0 0 8px rgba(45,212,191,.3));
}

.tbdw-market-stat__label {
    font-size: 11px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}

.tbdw-market-stat__value {
    font-size: 28px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.tbdw-market-stat__change {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(255,255,255,.05);
    transition: color .3s, background .3s;
}

.tbdw-market-stat__change.is-gain { color: #22c55e; background: rgba(34,197,94,.1); }
.tbdw-market-stat__change.is-loss { color: #f87171; background: rgba(248,113,113,.1); }

/* Dominance Progress Bar */
.tbdw-market-stat__bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,.08);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.tbdw-market-stat__bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #2dd4bf);
    border-radius: 3px;
    transition: width .8s cubic-bezier(.4, 0, .2, 1);
}

/* ── Fear & Greed Gauge ─────────────────────────────────────────── */

.tbdw-fng {
    position: absolute;   /* füllt tbdw-panel-content komplett */
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    gap: 4px;
    background: linear-gradient(145deg, rgba(15,23,42,.95), rgba(11,15,22,.98));
}

.tbdw-fng__arc-wrap {
    position: relative;
    width: 120px;
    height: 70px;
    flex-shrink: 0;
}

.tbdw-fng__arc {
    width: 120px;
    height: 70px;
}

.tbdw-fng__arc-fill {
    transition: stroke-dashoffset 1s cubic-bezier(.4, 0, .2, 1);
}

/* Value number over the arc */
.tbdw-fng__value {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: #f1f5f9;
    line-height: 1;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    transition: color .5s;
}

.tbdw-fng__label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .06em;
    transition: color .5s;
}

/* Fear & Greed Farb-States */
.tbdw-fng[data-mood="extreme-fear"]  .tbdw-fng__value,
.tbdw-fng[data-mood="extreme-fear"]  .tbdw-fng__label { color: #f87171; }
.tbdw-fng[data-mood="fear"]          .tbdw-fng__value,
.tbdw-fng[data-mood="fear"]          .tbdw-fng__label { color: #fb923c; }
.tbdw-fng[data-mood="neutral"]       .tbdw-fng__value,
.tbdw-fng[data-mood="neutral"]       .tbdw-fng__label { color: #fbbf24; }
.tbdw-fng[data-mood="greed"]         .tbdw-fng__value,
.tbdw-fng[data-mood="greed"]         .tbdw-fng__label { color: #86efac; }
.tbdw-fng[data-mood="extreme-greed"] .tbdw-fng__value,
.tbdw-fng[data-mood="extreme-greed"] .tbdw-fng__label { color: #22c55e; }

/* ── Loading Animation ───────────────────────────────────────────── */

.tbdw-coin-stat__price:empty::after,
.tbdw-coin-stat__change:empty::after,
.tbdw-market-stat__value:empty::after,
.tbdw-fng__value:empty::after {
    content: '—';
    animation: tbdw-stat-blink .8s ease-in-out infinite;
    color: #334155;
}

@keyframes tbdw-stat-blink {
    0%, 100% { opacity: .3; }
    50%       { opacity: .9; }
}

/* ── Update Flash-Animation ────────────────────────────────────────── */

@keyframes tbdw-flash {
    0%   { opacity: .4; }
    50%  { opacity: 1; }
    100% { opacity: 1; }
}

.tbdw-stat-updated {
    animation: tbdw-flash .4s ease-out;
}

/* ================================================================
   KOMPAKT-SCHICHT — Inhalt folgt der WIDGET-GRÖSSE
   ================================================================
   Problem: Die Karten hatten feste Größen (Preis 26px, Wert 28px,
   Padding 16–18px, Logo 36px, Fear&Greed-Bogen fix 120×70px).
   Das Panel liess sich zwar klein ziehen, der Inhalt aber nicht —
   er wurde nur abgeschnitten (panel-content: overflow:hidden).

   Lösung: Der Panel-Inhalt wird zum Größen-Container. Schriften,
   Abstände und der Bogen skalieren stufenlos mit cqh/cqw, und
   Nebensächliches (Footer, Logo, Label) wird gestuft ausgeblendet,
   BEVOR es zerquetscht wird. Die Obergrenzen entsprechen exakt den
   bisherigen Werten → bei normaler Größe ändert sich nichts.

   @supports-Guard: Browser ohne Container-Queries behalten den
   bisherigen Look (kein Bruch, nur kein Kompakt-Modus).
   ================================================================ */

@supports (container-type: size) {

    .tbdw-panel[data-widget-type^="stat-"] > .tbdw-panel-content {
        container-type: size;
        container-name: tbdwkpi;
    }

    /* ── Coin-Stat: fließende Größen ─────────────────────────────── */

    .tbdw-coin-stat {
        padding: clamp(4px, 6cqh, 16px) clamp(5px, 5cqw, 18px) clamp(3px, 5cqh, 14px);
    }
    .tbdw-coin-stat__header {
        margin-bottom: clamp(2px, 5cqh, 12px);
        gap: clamp(4px, 4cqw, 10px);
    }
    .tbdw-coin-stat__logo-wrap,
    .tbdw-coin-stat__logo {
        width: clamp(16px, 24cqh, 36px);
        height: clamp(16px, 24cqh, 36px);
    }
    .tbdw-coin-stat__logo-letter { font-size: clamp(8px, 10cqh, 14px); }
    .tbdw-coin-stat__name        { font-size: clamp(9px, 9cqh, 13px); }
    .tbdw-coin-stat__symbol      { font-size: clamp(8px, 8cqh, 11px); }
    .tbdw-coin-stat__price {
        font-size: clamp(13px, 20cqh, 26px);
        margin-bottom: clamp(1px, 3cqh, 6px);
    }
    .tbdw-coin-stat__change {
        font-size: clamp(9px, 9cqh, 13px);
        padding: clamp(1px, 1cqh, 3px) clamp(4px, 3cqw, 8px);
    }
    .tbdw-coin-stat__footer {
        margin-top: clamp(2px, 4cqh, 10px);
        padding-top: clamp(2px, 3cqh, 8px);
    }
    .tbdw-coin-stat__mcap-label { font-size: clamp(7px, 6cqh, 10px); }
    .tbdw-coin-stat__mcap       { font-size: clamp(8px, 7cqh, 11px); }

    /* Gestuftes Ausblenden nach Höhe */
    @container tbdwkpi (max-height: 108px) {
        .tbdw-coin-stat__footer { display: none; }
    }
    @container tbdwkpi (max-height: 78px) {
        .tbdw-coin-stat__logo-wrap { display: none; }
        .tbdw-coin-stat__name      { display: none; }
        .tbdw-coin-stat__header    { margin-bottom: 2px; }
    }
    @container tbdwkpi (max-height: 56px) {
        .tbdw-coin-stat         { padding: 3px 6px; }
        .tbdw-coin-stat__header { display: none; }
        .tbdw-coin-stat__change { background: none; padding: 0; }
    }

    /* Gestuftes Ausblenden nach Breite */
    @container tbdwkpi (max-width: 112px) {
        .tbdw-coin-stat__name       { display: none; }
        .tbdw-coin-stat__mcap-label { display: none; }
    }
    @container tbdwkpi (max-width: 76px) {
        .tbdw-coin-stat__header { display: none; }
        .tbdw-coin-stat__footer { display: none; }
        .tbdw-coin-stat         { justify-content: center; }
        .tbdw-coin-stat__change { margin-bottom: 0; }
    }

    /* ── Market-Stat (Dominanz / Market Cap) ─────────────────────── */

    .tbdw-market-stat {
        padding: clamp(4px, 5cqh, 16px) clamp(5px, 4cqw, 18px);
        gap: clamp(1px, 2cqh, 6px);
    }
    .tbdw-market-stat__icon   { font-size: clamp(11px, 16cqh, 28px); }
    .tbdw-market-stat__label  { font-size: clamp(8px, 7cqh, 11px); }
    .tbdw-market-stat__value  { font-size: clamp(13px, 20cqh, 28px); }
    .tbdw-market-stat__change { font-size: clamp(8px, 8cqh, 12px); }
    .tbdw-market-stat__bar    { height: clamp(3px, 4cqh, 6px); }

    @container tbdwkpi (max-height: 88px) {
        .tbdw-market-stat__icon { display: none; }
    }
    @container tbdwkpi (max-height: 58px) {
        .tbdw-market-stat__label  { display: none; }
        .tbdw-market-stat__change { display: none; }
    }
    @container tbdwkpi (max-width: 92px) {
        .tbdw-market-stat__label { display: none; }
    }

    /* ── Fear & Greed: Bogen skaliert statt fix 120×70 ───────────── */

    .tbdw-fng {
        padding: clamp(3px, 4cqh, 12px) clamp(4px, 4cqw, 16px);
        gap: clamp(1px, 2cqh, 4px);
    }
    .tbdw-fng__arc-wrap {
        /* Breite treibt, Höhe folgt dem viewBox-Verhältnis (120:70).
           Alle drei Deckel greifen: Original-Größe, Container-Breite, Container-Höhe. */
        width: min(120px, 92cqw, calc(56cqh * 1.7143));
        height: auto;
        aspect-ratio: 120 / 70;
        flex-shrink: 0;
    }
    .tbdw-fng__value { font-size: clamp(11px, 20cqh, 28px); }
    .tbdw-fng__label { font-size: clamp(8px, 7cqh, 12px); }

    @container tbdwkpi (max-height: 62px) {
        .tbdw-fng__label { display: none; }
    }
    @container tbdwkpi (max-width: 80px) {
        .tbdw-fng__label { display: none; }
    }
}
