/* ═══ 🚨 Divergences (Counter Button + Modal) ═══ */
.btn-divergence {
    position: relative;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(99, 102, 241, 0.1)) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}
.btn-divergence:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(99, 102, 241, 0.15)) !important;
    border-color: var(--danger) !important;
}
.btn-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: white;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 11px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 4px;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
    animation: btn-counter-pulse 2s ease-in-out infinite;
}
.btn-counter.zero {
    background: rgba(148, 163, 184, 0.3);
    color: var(--text-muted);
    box-shadow: none;
    animation: none;
}
@keyframes btn-counter-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Stats grid in modal */
.div-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.div-stat-card {
    background: rgba(20, 27, 45, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.div-stat-card:hover {
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-2px);
}
.div-stat-card.tier-S { border-left: 3px solid var(--gold); }
.div-stat-card.tier-A { border-left: 3px solid var(--success); }
.div-stat-card.tier-B { border-left: 3px solid var(--primary); }
.div-stat-card.buy { border-left: 3px solid var(--success); }
.div-stat-card.sell { border-left: 3px solid var(--danger); }
.div-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.div-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

/* Filters */
.div-filters {
    background: rgba(15, 20, 33, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.div-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.div-filter-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-left: 4px;
}
.div-filter-btn {
    background: rgba(20, 27, 45, 0.5);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    transition: all 0.2s;
}
.div-filter-btn:hover {
    border-color: var(--primary);
}
.div-filter-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--text);
}
.div-filter-btn.buy.active {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
    color: var(--success);
}
.div-filter-btn.sell.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    color: var(--danger);
}



/* ═══ 📊 RSI + Divergence Section ═══ */
.rsi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 8px;
    margin-bottom: 12px;
}
.rsi-consensus {
    font-size: 0.95rem;
    font-weight: 700;
}
.rsi-scores {
    display: flex;
    gap: 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}
.rsi-buy-score { color: var(--success); }
.rsi-sell-score { color: var(--danger); }

.rsi-tf-row {
    display: grid;
    grid-template-columns: 50px 1fr 50px 100px;
    gap: 10px;
    padding: 10px 0;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.rsi-tf-row:last-of-type { border-bottom: none; }
.rsi-tf-empty { color: var(--text-dim); }
.rsi-tf-empty .rsi-tf-content {
    grid-column: 2 / -1;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
}

.rsi-tf-label {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--gold);
    font-size: 0.9rem;
}

.rsi-tf-bar {
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
}
.rsi-bar-bg {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(20, 27, 45, 0.6);
    border-radius: 3px;
    overflow: hidden;
}
.rsi-bar-zone-os {
    position: absolute;
    left: 0;
    top: 0;
    width: 30%;
    height: 100%;
    background: rgba(16, 185, 129, 0.15);
}
.rsi-bar-zone-ob {
    position: absolute;
    right: 0;
    top: 0;
    width: 30%;
    height: 100%;
    background: rgba(239, 68, 68, 0.15);
}
.rsi-bar-marker {
    position: absolute;
    top: -3px;
    width: 4px;
    height: 12px;
    background: var(--gold);
    border-radius: 2px;
    transform: translateX(-50%);
    transition: left 0.3s;
    box-shadow: 0 0 6px rgba(251, 191, 36, 0.6);
}

.rsi-tf-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.95rem;
    text-align: center;
}
.rsi-tf-status {
    font-size: 0.78rem;
    text-align: left;
    font-weight: 600;
}

.rsi-divergence {
    margin: 8px 0 8px 60px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(20, 27, 45, 0.5);
}
.rsi-divergence.div-bullish {
    border-left: 3px solid var(--success);
    background: rgba(16, 185, 129, 0.08);
}
.rsi-divergence.div-bearish {
    border-left: 3px solid var(--danger);
    background: rgba(239, 68, 68, 0.08);
}
.div-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.div-icon { font-size: 1rem; }
.div-title {
    font-weight: 700;
    color: var(--text);
    font-size: 0.85rem;
    flex: 1;
}
.div-tf {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
}
.div-strength {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--gold);
    font-weight: 700;
}
.div-detail {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.5;
}

.div-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.div-draw-btn {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.div-draw-btn:hover {
    background: rgba(59, 130, 246, 0.28);
    border-color: rgba(59, 130, 246, 0.7);
}

@media (max-width: 768px) {
    .rsi-tf-row {
        grid-template-columns: 40px 1fr 40px;
        gap: 6px;
    }
    .rsi-tf-status {
        grid-column: 1 / -1;
        text-align: center;
        font-size: 0.7rem;
        margin-top: 2px;
    }
    .rsi-divergence { margin-left: 0; }
}


/* ═══════════════════════════════════════════════════════════════════
 * 🎯 Card Divergence Pulse — frame glow signaling RSI divergence
 * ═══════════════════════════════════════════════════════════════════
 * Driven by attributes set in cards.js (RSI best_divergence):
 *   data-divergence-direction = "BUY" | "SELL"
 *   data-divergence-strength  = "regular" (8) | "hidden" (6)
 *   data-divergence-tf        = "M15" | "H1" | "H4" | "D1"
 *
 * Regular = bold pulse (reversal — strong signal)
 * Hidden  = soft pulse (continuation — weaker signal)
 * ═══════════════════════════════════════════════════════════════════ */

.symbol-card[data-divergence-direction] {
    /* keep border smooth; box-shadow drives the pulse via animation */
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

/* ── Regular (strength 8) — bold reversal pulse ──────────────── */
.symbol-card[data-divergence-direction="BUY"][data-divergence-strength="regular"] {
    animation: cardPulseBuyStrong 1.4s ease-in-out infinite;
    border-color: rgba(16, 185, 129, 0.55) !important;
}
.symbol-card[data-divergence-direction="SELL"][data-divergence-strength="regular"] {
    animation: cardPulseSellStrong 1.4s ease-in-out infinite;
    border-color: rgba(239, 68, 68, 0.55) !important;
}

/* ── Hidden (strength 6) — soft continuation pulse ───────────── */
.symbol-card[data-divergence-direction="BUY"][data-divergence-strength="hidden"] {
    animation: cardPulseBuySoft 2.2s ease-in-out infinite;
    border-color: rgba(16, 185, 129, 0.32) !important;
}
.symbol-card[data-divergence-direction="SELL"][data-divergence-strength="hidden"] {
    animation: cardPulseSellSoft 2.2s ease-in-out infinite;
    border-color: rgba(239, 68, 68, 0.32) !important;
}

/* ── Pause pulse on hover so the user can read the card calmly ── */
.symbol-card[data-divergence-direction]:hover {
    animation-play-state: paused;
}

/* ── Corner badge: shows the timeframe of the divergence ──────── */
/* Placed top-right because .card-remove-btn already occupies top-left */
.symbol-card[data-divergence-direction]::after {
    content: attr(data-divergence-tf);
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 4;
    padding: 3px 7px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.symbol-card[data-divergence-direction="BUY"]::after {
    color: #10b981;
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid rgba(16, 185, 129, 0.45);
}
.symbol-card[data-divergence-direction="SELL"]::after {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.45);
}
.symbol-card[data-divergence-strength="regular"]::after {
    box-shadow: 0 0 10px currentColor, 0 0 4px currentColor inset;
    animation: cardBadgePulse 1.4s ease-in-out infinite;
}

/* ── Keyframes: strong pulse (Regular = reversal) ─────────────── */
@keyframes cardPulseBuyStrong {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(16, 185, 129, 0.65),
            0 0 16px 2px rgba(16, 185, 129, 0.40),
            0 0 28px 6px rgba(16, 185, 129, 0.20);
    }
    50% {
        box-shadow:
            0 0 0 2px rgba(16, 185, 129, 0.95),
            0 0 26px 4px rgba(16, 185, 129, 0.60),
            0 0 44px 10px rgba(16, 185, 129, 0.35);
    }
}
@keyframes cardPulseSellStrong {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(239, 68, 68, 0.65),
            0 0 16px 2px rgba(239, 68, 68, 0.40),
            0 0 28px 6px rgba(239, 68, 68, 0.20);
    }
    50% {
        box-shadow:
            0 0 0 2px rgba(239, 68, 68, 0.95),
            0 0 26px 4px rgba(239, 68, 68, 0.60),
            0 0 44px 10px rgba(239, 68, 68, 0.35);
    }
}

/* ── Keyframes: soft pulse (Hidden = continuation) ────────────── */
@keyframes cardPulseBuySoft {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(16, 185, 129, 0.30),
            0 0 8px 1px rgba(16, 185, 129, 0.18);
    }
    50% {
        box-shadow:
            0 0 0 1px rgba(16, 185, 129, 0.55),
            0 0 16px 3px rgba(16, 185, 129, 0.38);
    }
}
@keyframes cardPulseSellSoft {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(239, 68, 68, 0.30),
            0 0 8px 1px rgba(239, 68, 68, 0.18);
    }
    50% {
        box-shadow:
            0 0 0 1px rgba(239, 68, 68, 0.55),
            0 0 16px 3px rgba(239, 68, 68, 0.38);
    }
}

@keyframes cardBadgePulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

/* ── Accessibility: respect reduced-motion preference ─────────── */
@media (prefers-reduced-motion: reduce) {
    .symbol-card[data-divergence-direction],
    .symbol-card[data-divergence-strength="regular"]::after {
        animation: none !important;
    }
    .symbol-card[data-divergence-direction="BUY"] {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.5), 0 0 14px rgba(16, 185, 129, 0.25);
    }
    .symbol-card[data-divergence-direction="SELL"] {
        box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5), 0 0 14px rgba(239, 68, 68, 0.25);
    }
}


/* ═══════════════════════════════════════════════════════════════════
 * 💬 Custom Divergence Tooltip — themed, formatted, replaces native title
 * ═══════════════════════════════════════════════════════════════════ */

.card-div-tooltip {
    position: absolute;
    top: 36px;
    right: 8px;
    left: 8px;
    z-index: 5;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(15, 20, 33, 0.96);
    backdrop-filter: blur(10px) saturate(1.2);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    text-align: right;
    direction: rtl;

    /* hidden by default — fades in on card hover */
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
    transition:
        opacity 0.18s ease,
        transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.symbol-card:hover .card-div-tooltip {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition-delay: 0.12s;     /* slight delay so it doesn't flicker on quick passes */
}

/* ── Direction-tinted accents ──────────────────────────────── */
.card-div-tooltip.cdt-buy {
    border: 1px solid rgba(16, 185, 129, 0.55);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 0 18px rgba(16, 185, 129, 0.18);
}
.card-div-tooltip.cdt-sell {
    border: 1px solid rgba(239, 68, 68, 0.55);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 0 18px rgba(239, 68, 68, 0.18);
}

/* ── Pointer arrow up toward the TF badge ──────────────────── */
.cdt-arrow {
    position: absolute;
    top: -6px;
    right: 14px;
    width: 12px;
    height: 12px;
    transform: rotate(45deg);
    background: inherit;
    border-top: 1px solid;
    border-left: 1px solid;
    border-color: inherit;
    border-radius: 2px 0 0 0;
}
.card-div-tooltip.cdt-buy .cdt-arrow {
    background: rgba(15, 20, 33, 0.96);
    border-color: rgba(16, 185, 129, 0.55);
}
.card-div-tooltip.cdt-sell .cdt-arrow {
    background: rgba(15, 20, 33, 0.96);
    border-color: rgba(239, 68, 68, 0.55);
}

/* ── Header row ────────────────────────────────────────────── */
.cdt-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.cdt-icon { font-size: 1.05rem; }
.cdt-title {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}
.cdt-dir-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 5px;
    letter-spacing: 0.06em;
}
.cdt-buy .cdt-dir-badge {
    background: rgba(16, 185, 129, 0.18);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
}
.cdt-sell .cdt-dir-badge {
    background: rgba(239, 68, 68, 0.18);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

/* ── Meta pills (TF / Type / Strength) ─────────────────────── */
.cdt-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.cdt-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 3px 7px;
    font-size: 0.7rem;
}
.cdt-meta-key {
    color: var(--text-muted);
    font-size: 0.65rem;
}
.cdt-meta-val {
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
}
.cdt-buy .cdt-meta-pill .cdt-meta-val { color: #10b981; }
.cdt-sell .cdt-meta-pill .cdt-meta-val { color: #ef4444; }

/* Strong divergence — bold the strength pill so the user feels the weight */
.cdt-regular .cdt-meta-pill:last-child {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}
.cdt-buy.cdt-regular .cdt-meta-pill:last-child  { box-shadow: 0 0 8px rgba(16, 185, 129, 0.25); }
.cdt-sell.cdt-regular .cdt-meta-pill:last-child { box-shadow: 0 0 8px rgba(239, 68, 68, 0.25); }

/* ── Detail line ───────────────────────────────────────────── */
.cdt-detail {
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--text-dim);
    word-break: break-word;
}

/* ── Hide tooltip on touch devices (no hover, would block taps) ─ */
@media (hover: none), (max-width: 768px) {
    .card-div-tooltip {
        display: none !important;
    }
}



