/* ══════════════════════════════════════════════════════════════════════
   Token-specific table cell formatting — sector pills, badges,
   sparklines, favorites, rank styling, compact mode.
   Loaded on: /spot/tokens, /perps/token/*, /perp/tokens
   ══════════════════════════════════════════════════════════════════════ */

/* ── Tokens table columns ────────────────────────────────────────────── */
.col-chain { width: 28px; min-width: 28px; max-width: 28px; }
.chain-icon-cell { text-align: center; padding: 0 2px !important; }
.chain-icon-tiny { display: block; margin: 0 auto; opacity: 0.7; }
.token-row:hover .chain-icon-tiny { opacity: 1; }
.tokens-table .col-rank { width: 40px; min-width: 40px; }
.tokens-table .col-token-name { width: auto; min-width: 180px; }
.tokens-table .col-sparkline { width: 80px; min-width: 80px; }

.tokens-table td {
    padding: 4px 8px;
}

.token-row { cursor: pointer; }
.row-accent .token-row { border-left: 2px solid transparent; transition: border-color var(--duration-fast); }
.row-accent .token-row:hover { border-left-color: var(--color-hover-primary); }
.tokens-table .token-row:hover {
    background: linear-gradient(to right, rgba(110, 142, 251, 0.08) 0%, transparent 60%) !important;
}

.rank-cell {
    text-align: center !important;
    font-size: var(--fs-sm);
    color: var(--color-text-placeholder);
    font-weight: 500;
}

.token-name-cell { text-align: left; padding: 5px 8px 5px 12px !important; }

.tokens-table .token-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.tokens-table .token-symbol {
    font-size: var(--fs-md);
    font-weight: 400;
    color: var(--table_text_color);
}

.tokens-table .token-full-name {
    font-size: var(--fs-xs);
    color: var(--color-text-placeholder);
    opacity: 0.6;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-copy-addr.copy-flash {
    opacity: 1 !important;
    outline: 1.5px dashed rgba(255, 193, 7, 0.7);
    outline-offset: 2px;
    border-radius: 3px;
}

.btn-copy-addr {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    color: var(--color-text-placeholder);
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}
.btn-copy-addr .material-symbols-rounded {
    font-size: 14px;
}
.token-row:hover .btn-copy-addr {
    opacity: 0.6;
}
.btn-copy-addr:hover {
    opacity: 1 !important;
    color: var(--table_text_color);
}

.tokens-table .token-icon-small {
    width: 26px;
    height: 26px;
}

.tokens-table .token-icon-placeholder {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--table_border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--color-text-placeholder);
    flex-shrink: 0;
}

.sector-cell {
    text-align: left;
    font-size: var(--fs-xs);
    color: var(--color-text-placeholder);
}

/* Sector pill badges */
.sector-cell .sector-pill { cursor: pointer; }
.sector-cell .sector-pill:hover { filter: brightness(1.2); }

.sector-pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: var(--fs-xs);
    line-height: 1.6;
    white-space: nowrap;
    background: rgba(110, 142, 251, 0.08);
    color: var(--color-text-placeholder);
}
.sector-pill.s-defi { background: rgba(110, 142, 251, 0.12); color: #6e8efb; }
.sector-pill.s-meme { background: rgba(251, 191, 36, 0.12); color: var(--color-warning); }
.sector-pill.s-layer1, .sector-pill.s-layer-1 { background: rgba(139, 92, 246, 0.12); color: var(--color-purple); }
.sector-pill.s-layer2, .sector-pill.s-layer-2 { background: rgba(99, 102, 241, 0.12); color: var(--color-indigo); }
.sector-pill.s-gamefi, .sector-pill.s-gaming { background: rgba(236, 72, 153, 0.12); color: var(--color-pink); }
.sector-pill.s-ai { background: rgba(6, 182, 212, 0.12); color: var(--color-cyan); }
.sector-pill.s-nft { background: rgba(244, 114, 182, 0.12); color: var(--color-pink-light); }
.sector-pill.s-stablecoin, .sector-pill.s-stablecoins { background: rgba(34, 197, 94, 0.12); color: var(--color-positive); }
.sector-pill.s-dex { background: rgba(168, 85, 247, 0.12); color: var(--color-purple-light); }
.sector-pill.s-lending { background: rgba(20, 184, 166, 0.12); color: var(--color-teal); }
.sector-pill.s-oracle { background: rgba(245, 158, 11, 0.12); color: var(--color-warning); }
.sector-pill.s-infrastructure { background: rgba(100, 116, 139, 0.12); color: #64748b; }
.sector-pill.s-rwa { background: rgba(59, 130, 246, 0.12); color: var(--color-blue); }

/* ── Change pill badges ──────────────────────────────────────────────── */
.chg-pill {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    letter-spacing: 0.1px;
}
.chg-intensity.positive .chg-pill { background: rgba(59, 185, 80, 0.12); }
.chg-intensity.negative .chg-pill { background: rgba(248, 81, 73, 0.12); }

.mcap-cell > div:first-child { line-height: 1.2; }
.mcap-supply {
    font-size: 9px;
    color: var(--color-text-placeholder);
    opacity: 0.45;
    line-height: 1.1;
    transition: opacity var(--duration-fast);
}
.token-row:hover .mcap-supply { opacity: 0.8; }

/* ── Favorites star ─────────────────────────────────────────────────── */
.col-fav { width: 28px; min-width: 28px; max-width: 28px; }
.fav-star {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--table_border);
    font-size: 16px;
    line-height: 1;
    transition: color var(--duration-fast);
}
.fav-star:hover { color: var(--color-warning); }
.fav-star.active { color: var(--color-warning); }
.fav-star .material-symbols-rounded { font-size: 16px; font-variation-settings: 'FILL' 0; }
.fav-star.active .material-symbols-rounded { font-variation-settings: 'FILL' 1; }

/* ── Summary stats bar ─────────────────────────────────────────────── */
.tokens-stats-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    margin-bottom: 6px;
    font-size: var(--fs-xs);
    color: var(--color-text-placeholder);
    flex-wrap: nowrap;
}
.tokens-stat { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.tokens-stat-link {
    text-decoration: none;
    cursor: pointer;
    transition: color var(--duration-fast);
    border-radius: var(--radius-sm);
    padding: 1px 4px;
}
.tokens-stat-link:hover { color: var(--color-hover-primary); }
.tokens-stat-link.active { color: var(--color-hover-primary); }
.tokens-stats-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.tokens-stat-value { color: var(--table_text_color); font-weight: 500; font-variant-numeric: tabular-nums; }
.tokens-stat-gainers { color: var(--color-positive); }
.tokens-stat-losers { color: var(--color-negative); }
.tokens-stat .tokens-stat-gainers::before { content: '\25B2 '; font-size: 8px; }
.tokens-stat .tokens-stat-losers::before  { content: '\25BC '; font-size: 8px; }

/* ── Fav filter header button ────────────────────────────────────────── */
.col-fav .fav-star {
    opacity: 0.3;
    transition: opacity var(--duration-fast);
}
.col-fav .fav-star:hover { opacity: 0.7; }
.col-fav .fav-star.active { opacity: 1; color: var(--color-warning); }
.tokens-stats-bar .stat-divider {
    width: 1px;
    height: 12px;
    background: var(--table_border);
    flex-shrink: 0;
}

/* ── Sort column highlight ─────────────────────────────────────────── */
.tokens-table[data-sort="rank"] td:nth-child(3),
.tokens-table[data-sort="symbol"] td:nth-child(4),
.tokens-table[data-sort="sector"] td:nth-child(5),
.tokens-table[data-sort="price"] td:nth-child(6),
.tokens-table[data-sort="chg_24h"] td:nth-child(7),
.tokens-table[data-sort="chg_7d"] td:nth-child(8),
.tokens-table[data-sort="volume"] td:nth-child(9),
.tokens-table[data-sort="mcap"] td:nth-child(11) {
    background: rgba(110, 142, 251, 0.02);
}

/* ── Rank color tiers ──────────────────────────────────────────────── */
.rank-cell.rank-gold {
    color: var(--color-warning);
    font-weight: 600;
}
.rank-cell.rank-silver {
    color: var(--color-hover-primary);
    font-weight: 500;
}

/* ── Compact / comfortable mode ────────────────────────────────────── */
.tokens-table-wrap.compact-mode .tokens-table td { padding: 2px 6px; }
.tokens-table-wrap.compact-mode .token-name-cell { padding: 2px 6px !important; }
.tokens-table-wrap.compact-mode .tokens-table .token-icon-small,
.tokens-table-wrap.compact-mode .tokens-table .token-icon-placeholder { width: 20px; height: 20px; }
.tokens-table-wrap.compact-mode .tokens-table .token-info { gap: 5px; }

.compact-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: none;
    border: 1px solid var(--table_border);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    cursor: pointer;
    color: var(--color-text-placeholder);
    font-size: var(--fs-xs);
    transition: all var(--duration-fast);
}
.compact-toggle:hover { border-color: var(--color-hover-primary); color: var(--color-hover-primary); }
.compact-toggle .material-symbols-rounded { font-size: 14px; }

/* ── Gainers / Losers quick tabs ───────────────────────────────────── */
.quick-filter-tabs {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}
.quick-filter-tab {
    padding: 0 8px;
    border: 1px solid var(--table_border);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 200;
    background: none;
    cursor: pointer;
    transition: all var(--duration-fast);
    white-space: nowrap;
    height: 24px;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
}
.quick-filter-tab:hover { border-color: var(--color-hover-primary); }
.quick-filter-tab.active { border-color: var(--color-hover-primary); color: var(--color-hover-primary); background: rgba(110, 142, 251, 0.08); }
.quick-filter-tab.tab-gainers { color: var(--color-positive); }
.quick-filter-tab.tab-gainers:hover, .quick-filter-tab.tab-gainers.active { border-color: var(--color-positive); background: rgba(34, 197, 94, 0.08); }
.quick-filter-tab.tab-losers { color: var(--color-negative); }
.quick-filter-tab.tab-losers:hover, .quick-filter-tab.tab-losers.active { border-color: var(--color-negative); background: rgba(239, 68, 68, 0.08); }

/* ── Row enter animation ───────────────────────────────────────────── */
@keyframes tokenRowFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
.tokens-table tbody .token-row {
    animation: tokenRowFadeIn 0.25s ease-out both;
}
.tokens-table tbody .token-row:nth-child(2) { animation-delay: 0.02s; }
.tokens-table tbody .token-row:nth-child(3) { animation-delay: 0.04s; }
.tokens-table tbody .token-row:nth-child(4) { animation-delay: 0.06s; }
.tokens-table tbody .token-row:nth-child(5) { animation-delay: 0.08s; }
.tokens-table tbody .token-row:nth-child(6) { animation-delay: 0.10s; }
.tokens-table tbody .token-row:nth-child(7) { animation-delay: 0.12s; }
.tokens-table tbody .token-row:nth-child(8) { animation-delay: 0.14s; }
.tokens-table tbody .token-row:nth-child(9) { animation-delay: 0.16s; }
.tokens-table tbody .token-row:nth-child(10) { animation-delay: 0.18s; }

/* ── Volume mini-bar ───────────────────────────────────────────────── */
.vol-cell {
    position: relative;
}
.vol-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    background: var(--color-hover-primary);
    opacity: 0.15;
    border-radius: 0 2px 2px 0;
    transition: width 0.3s;
}

/* ── No-results message ─────────────────────────────────────────────── */
.tokens-no-results {
    display: none;
    text-align: center;
    padding: 24px 16px;
    color: var(--color-text-placeholder);
    font-size: var(--fs-sm);
    opacity: 0.7;
}

/* ── Sparkline header icon ─────────────────────────────────────────── */
.sparkline-header-icon {
    font-size: 16px;
    color: var(--color-text-placeholder);
    opacity: 0.6;
}

/* ── Sparkline ───────────────────────────────────────────────────────── */
.sparkline-cell {
    padding: 4px !important;
    text-align: center !important;
}

.sparkline-svg {
    width: 70px;
    height: 24px;
    display: block;
    margin: 0 auto;
}

.funding-spark-cell {
    padding: 4px !important;
    text-align: center !important;
}

.funding-spark-svg {
    width: 100px;
    height: 24px;
    display: block;
    margin: 0 auto;
}

/* ── Sort links ──────────────────────────────────────────────────────── */
.sort-link {
    color: var(--color-text-placeholder);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.sort-link:hover { color: var(--table_text_color); }
.sort-link.active { color: var(--table_text_color); }

/* Sector filter modal */
.sector-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.sector-filter-btn {
    font-size: var(--fs-xs);
    padding: 4px 10px;
    white-space: nowrap;
}
