/* What If Marketcap widget
 * Scoped to #bs-wim — no !important, no global selectors.
 */

#bs-wim {
    --wim-text:        #111318;
    --wim-text-2:      #475569;
    --wim-text-3:      #94a3b8;
    --wim-border:      #e4e7ed;
    --wim-border-2:    #cbd5e1;
    --wim-bg-card:     #ffffff;
    --wim-bg-soft:     #f1f5f9;
    --wim-bg-soft-2:   #f8fafc;
    --wim-accent:      #1DB0E1;
    --wim-accent-light:#EFF6FF;
    --wim-green:       #047857;
    --wim-green-soft:  #D1FAE5;
    --wim-red:         #b91c1c;
    --wim-red-soft:    #FEE2E2;
    --wim-host:        #8b5cf6;
    --wim-target:      #6366f1;

    color: var(--wim-text);
    line-height: 1.5;
    font-size: 14px;
}

#bs-wim * { box-sizing: border-box; }
#bs-wim h2, #bs-wim h3 { margin: 0; font-weight: 600; }

/* ── Header ─────────────────────────────────────── */
.bs-wim__header { margin-bottom: 18px; }
.bs-wim__h1 {
    font-size: 25px;
    /* Use the theme text variable (not a hardcoded near-black) so the title flips
       to light in dark mode like the rest of the widget — it was the one black H2. */
    color: var(--wim-text);
    letter-spacing: -0.01em;
    line-height: 1.25;
    margin-bottom: 6px;
}
.bs-wim__intro {
    color: var(--wim-text-2);
    font-size: 14px;
    margin: 0;
}

/* ── Coin picker button ─────────────────────────── */
.bs-wim__coin-pick {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: var(--wim-bg-card);
    border: 1px solid var(--wim-border);
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
    font: inherit;
    color: inherit;
    text-align: left;
}
.bs-wim__coin-pick:hover { border-color: var(--wim-border-2); }
.bs-wim__coin-pick:focus-visible {
    outline: none;
    border-color: var(--wim-accent);
    box-shadow: 0 0 0 3px var(--wim-accent-light);
}
.bs-wim__coin-meta { display: flex; align-items: center; line-height: 1.2; flex: 1; min-width: 0; }
.bs-wim__coin-name { font-weight: 600; font-size: 16px; }
.bs-wim__coin-ticker { font-size: 14px; color: var(--wim-text-2); font-weight: 400; margin-left: 4px; }
.bs-wim__coin-caret { color: var(--wim-text-3); flex-shrink: 0; margin-left: auto; }
.bs-wim__coin-helper { color: var(--wim-text-2); font-size: 13px; margin: 8px 0 0; }

.bs-wim__coin-logo {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--wim-bg-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    color: var(--wim-text-2);
    flex-shrink: 0;
    overflow: hidden;
}
.bs-wim__coin-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Quick-compare chips ────────────────────────── */
.bs-wim__quick {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 22px;
}
.bs-wim__quick-label { color: var(--wim-text-2); font-size: 13px; font-weight: 500; }
.bs-wim__quick-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bs-wim__quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 6px;
    background: var(--wim-bg-card);
    border: 1px solid var(--wim-border);
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    font-weight: 500;
    font-size: 13px;
    transition: border-color 0.15s, background-color 0.15s;
}
.bs-wim__quick-chip:hover { border-color: var(--wim-border-2); }
.bs-wim__quick-chip.is-active {
    border-color: var(--wim-accent);
    background: var(--wim-accent-light);
}
.bs-wim__quick-logo {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--wim-bg-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 9px;
    color: var(--wim-text-2);
    flex-shrink: 0;
    overflow: hidden;
}
.bs-wim__quick-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Big result panel ───────────────────────────── */
.bs-wim__result {
    background: var(--wim-bg-soft);
    border-radius: 14px;
    padding: 22px 16px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.bs-wim__result-label {
    color: var(--wim-text-2);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.bs-wim__result-price {
    font-size: clamp(36px, 6vw, 56px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--wim-text);
}
.bs-wim__result-mult {
    display: inline-block;
    margin-top: 4px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--wim-green-soft);
    color: var(--wim-green);
    font-weight: 600;
    font-size: 13px;
}
.bs-wim__result-mult.is-loss {
    background: var(--wim-red-soft);
    color: var(--wim-red);
}
.bs-wim__result-mult:empty { display: none; }

/* ── Market cap bars ────────────────────────────── */
.bs-wim__bars { margin: 22px 0 18px; }
.bs-wim__bars-title {
    color: var(--wim-text);
    font-size: 14px;
    margin-bottom: 14px;
}
.bs-wim__bar-row + .bs-wim__bar-row { margin-top: 14px; }
.bs-wim__bar-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}
.bs-wim__bar-name {
    font-size: 14px;
    color: var(--wim-text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.bs-wim__bar-suffix { color: var(--wim-text-2); font-weight: 400; font-size: 13px; }
.bs-wim__bar-value { font-weight: 600; font-size: 14px; color: var(--wim-text); white-space: nowrap; }
.bs-wim__bar-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.bs-wim__bar-dot[data-role="host"]   { background: var(--wim-host); }
.bs-wim__bar-dot[data-role="target"] { background: var(--wim-target); }
.bs-wim__bar-track {
    width: 100%;
    height: 8px;
    background: var(--wim-bg-soft);
    border-radius: 999px;
    overflow: hidden;
}
.bs-wim__bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
    width: 0;
}
.bs-wim__bar-fill[data-role="host"]   { background: var(--wim-host); }
.bs-wim__bar-fill[data-role="target"] { background: var(--wim-target); }

/* ── Divider ────────────────────────────────────── */
.bs-wim__divider {
    border: 0;
    border-top: 1px solid var(--wim-border);
    margin: 22px 0 18px;
}

/* ── Investment section ─────────────────────────── */
.bs-wim__invest { padding: 14px 0 18px; }
.bs-wim__invest-title {
    color: var(--wim-text);
    font-size: 16px;
    margin-bottom: 14px;
}
.bs-wim__amounts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.bs-wim__amount-chip {
    padding: 10px 18px;
    border: 1px dashed var(--wim-border-2);
    border-radius: 10px;
    background: transparent;
    color: var(--wim-text-3);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}
.bs-wim__amount-chip:hover { border-color: var(--wim-accent); color: var(--wim-text-2); }
.bs-wim__amount-chip.is-active {
    border-style: solid;
    border-color: var(--wim-accent);
    color: var(--wim-text);
    background: var(--wim-accent-light);
}

.bs-wim__invest-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
}
.bs-wim__invest-input { min-width: 0; }
.bs-wim__invest-arrow { color: var(--wim-text-3); flex-shrink: 0; }
.bs-wim__invest-output { min-width: 0; }
.bs-wim__invest-out-label {
    display: block;
    color: var(--wim-text-2);
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 500;
}
.bs-wim__invest-out-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--wim-text);
    letter-spacing: -0.01em;
}

.bs-wim__field-label {
    display: block;
    color: var(--wim-text-2);
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 500;
}
.bs-wim__input-wrap { position: relative; }
.bs-wim__input-prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--wim-text-2);
    font-weight: 600;
    font-size: 15px;
    line-height: 1;
    pointer-events: none;
}
#bs-wim .bs-wim__input {
    width: 100%;
    max-width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--wim-border);
    border-radius: 10px;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    background: var(--wim-bg-card);
    color: var(--wim-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
#bs-wim .bs-wim__input.bs-wim__input--prefixed { padding-left: 32px; }
#bs-wim .bs-wim__input:focus {
    outline: none;
    border-color: var(--wim-accent);
    box-shadow: 0 0 0 3px var(--wim-accent-light);
}

/* ── Share row ──────────────────────────────────── */
.bs-wim__share {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--wim-border);
    flex-wrap: wrap;
}
.bs-wim__share-label {
    color: var(--wim-text-2);
    font-size: 13px;
    font-weight: 500;
}
.bs-wim__share-btns { display: flex; gap: 8px; }
.bs-wim__share-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--wim-bg-soft);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wim-text-2);
    transition: background-color 0.15s, color 0.15s;
    padding: 0;
}
.bs-wim__share-btn svg { display: block; }
.bs-wim__share-btn:hover,
.bs-wim__share-btn:focus-visible {
    outline: none;
    background: var(--wim-border);
}
.bs-wim__share-x:hover, .bs-wim__share-x:focus-visible { color: #000; }
.bs-wim__share-tg:hover, .bs-wim__share-tg:focus-visible { color: #229ED9; }
.bs-wim__share-wa:hover, .bs-wim__share-wa:focus-visible { color: #25D366; }
.bs-wim__share-copy:hover, .bs-wim__share-copy:focus-visible { color: var(--wim-accent); }
.bs-wim__share-copy.is-copied { color: var(--wim-green); background: var(--wim-green-soft); }

/* ── Picker modal ───────────────────────────────── */
.bs-wim__modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.bs-wim__modal[hidden] { display: none; }
.bs-wim__modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}
.bs-wim__modal-card {
    position: relative;
    background: var(--wim-bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px -10px rgba(0,0,0,0.45);
}
.bs-wim__modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--wim-border);
}
.bs-wim__modal-title { font-size: 16px; font-weight: 600; margin: 0; }
.bs-wim__modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--wim-text-2);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.bs-wim__modal-close:hover { background: var(--wim-bg-soft); color: var(--wim-text); }
.bs-wim__modal-search { padding: 12px 16px; border-bottom: 1px solid var(--wim-border); }
.bs-wim__modal-list {
    list-style: none;
    padding: 6px 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}
.bs-wim__modal-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    color: inherit;
    font: inherit;
}
.bs-wim__modal-item:hover, .bs-wim__modal-item:focus-visible { background: var(--wim-bg-soft); outline: none; }
.bs-wim__modal-item .bs-wim__coin-logo { width: 26px; height: 26px; }
.bs-wim__modal-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bs-wim__modal-name { font-weight: 500; font-size: 14px; }
.bs-wim__modal-ticker { color: var(--wim-text-2); font-size: 12px; }
.bs-wim__modal-mcap { color: var(--wim-text-2); font-size: 12px; }
.bs-wim__modal-rank { color: var(--wim-text-3); font-size: 12px; flex-shrink: 0; }
.bs-wim__modal-empty { padding: 16px; color: var(--wim-text-2); text-align: center; font-size: 13px; list-style: none; }

/* ── Mobile ─────────────────────────────────────── */
@media (max-width: 640px) {
    .bs-wim__invest-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .bs-wim__invest-arrow { display: none; }
    .bs-wim__invest-out-value { font-size: 20px; }
    .bs-wim__quick { gap: 8px; }
    .bs-wim__quick-chip { padding: 5px 12px 5px 5px; font-size: 12px; }
    .bs-wim__amount-chip { padding: 8px 14px; font-size: 13px; }
}

/* ── Dark mode ──────────────────────────────────── */
html.bs-dark #bs-wim {
    --wim-text:        #e2e8f0;
    --wim-text-2:      #94a3b8;
    --wim-text-3:      #64748b;
    --wim-border:      #334155;
    --wim-border-2:    #475569;
    --wim-bg-card:     #1e293b;
    --wim-bg-soft:     #0f172a;
    --wim-bg-soft-2:   #0f172a;
    --wim-accent-light:rgba(29, 176, 225, 0.15);
    --wim-green:       #6ee7b7;
    --wim-green-soft:  rgba(110, 231, 183, 0.15);
    --wim-red:         #fca5a5;
    --wim-red-soft:    rgba(252, 165, 165, 0.15);
}
/* The X-share icon hover hardcodes #000 (invisible on a dark card) — lighten it. */
html.bs-dark #bs-wim .bs-wim__share-x:hover,
html.bs-dark #bs-wim .bs-wim__share-x:focus-visible { color: var(--wim-text); }
