/* ==========================================
   🎨 CLASSE DE PALETES DE CORES REATIVAS
   ========================================== */
html[data-theme="dark"] {
    --bg-base: #060913;
    --bg-panel: #0d1222;
    --bg-card: #141b2f;
    --border-line: #1e2942;
    --text-main: #f8fafc;
    --text-muted: #99b4da;
    --glow-effect: rgba(20, 184, 166, 0.15);
}

html[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-card: #f8fafc;
    --border-line: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #475569;
    --glow-effect: rgba(13, 148, 136, 0.05);
}

:root {
    --tok-color: #3b82f6;
    --nft-color: #ff8800;
    --win-green: #10b981;
    --fail-red: #ef4444;
    --gold-whale: #fbbf24;
}

/* ==========================================
   📌 ESTRUTURA BASE DO CORPO
   ========================================== */
body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0; padding: 0;
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Oculta as barras de rolagem cinzentas mantendo a rolagem reativa ativa */
body::-webkit-scrollbar,
.main-content-layout::-webkit-scrollbar {
    display: none;
}
body, .main-content-layout {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ==========================================
   📌 PAINEL FIXO SUPERIOR (HEADER + METRICS)
   ========================================== */
.fixed-top-panel {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    background-color: var(--bg-base);
    padding: 12px 16px 4px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid var(--border-line);
}

.app-header {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-line);
    padding: 10px 16px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-block { display: flex; align-items: center; gap: 10px; }
.brand-block h1 { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; }

/* 🛡️ FIX DO SINAL PULSANTE: Adicionado flex-shrink para travar o formato redondo em Mobile */
.pulse-indicator {
    width: 15px; height: 15px;
    background-color: var(--tok-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--win-green);
    flex-shrink: 0 !important; 
    animation: beaconGlow 2s infinite ease-in-out;
}

.btn-theme {
    background-color: var(--bg-card);
    border: 1px solid var(--border-line);
    color: var(--text-main);
    padding: 4px 10px; 
    border-radius: 6px;
    font-size: 0.7rem; 
    font-weight: 600; 
    cursor: pointer;
    flex-shrink: 0;
}

.meta-shelf {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding-bottom: 8px;
}

@media (min-width: 1024px) {
    .meta-shelf { grid-template-columns: repeat(4, 1fr); }
}

/* 📊 NÓS DE ESTATÍSTICAS HORIZONTAIS COMPACTOS */
.stat-node {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: 10px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    box-sizing: border-box;
    min-height: 40px;
}

.stat-lbl { font-size: 0.55rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.select-node label { margin: 0; }

.stat-val-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.1rem;
    font-weight: 800;
    font-family: monospace;
}

.trend-up { color: var(--win-green); }
.trend-down { color: var(--fail-red); }
.trend-equal { color: var(--text-muted); }

.select-node .ui-dropdown {
    width: auto;
    min-width: 75px;
    text-align: right;
    background-color: var(--bg-card); 
    color: var(--text-main);
    border: 1px solid var(--border-line); 
    padding: 4px 8px; 
    border-radius: 6px;
    font-size: 0.78rem; 
    font-weight: 600; 
    outline: none; 
    cursor: pointer;
}

/* ==========================================
   🏃 ÁREA CENTRAL INTEGRADA NO SCROLL GLOBAL
   ========================================== */
.main-content-layout {
    margin-top: 210px; 
    margin-bottom: 70px; 
    padding: 16px;
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    .main-content-layout { 
        margin-top: 135px; 
        margin-bottom: 54px;
    }
}

.stream-column-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-line);
    border-radius: 12px; 
    padding: 14px;
    display: flex; 
    flex-direction: column;
}

.stream-panel-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    gap: 12px; 
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-line); 
    padding-bottom: 10px;
}

.ui-pause-btn {
    background-color: var(--bg-card); border: 1px solid var(--border-line); color: var(--text-main);
    padding: 6px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; gap: 4px;
}
.ui-pause-btn.paused { background-color: var(--fail-red); color: white; border-color: var(--fail-red); }
.badge-buffer { background-color: white; color: var(--fail-red); font-size: 0.65rem; font-weight: 800; padding: 1px 4px; border-radius: 8px; }

.ui-filter-group { display: flex; gap: 2px; background-color: var(--bg-card); padding: 2px; border-radius: 6px; border: 1px solid var(--border-line); }
.filter-btn { background: transparent; border: none; color: var(--text-muted); padding: 4px 10px; border-radius: 4px; font-weight: 600; font-size: 0.75rem; cursor: pointer; }
.filter-btn.active { background-color: #0d9488; color: white; }
.filter-btn[data-filter="whales"].active {
    background-color: var(--gold-whale);
    color: #060913; 
}

.cards-layout-grid {
    display: grid; 
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    height: auto;
    visibility: visible;
    opacity: 1;
}

@media (min-width: 1024px) {
    .cards-layout-grid { 
        grid-template-columns: repeat(4, 1fr); 
    }
}

.grid-placeholder-notice { grid-column: 1 / -1; text-align: center; padding: 30px; color: var(--text-muted); font-size: 0.8rem; }

/* ==========================================
   🖼️ ESTRUTURA SEMÂNTICA DOS CARTÕES (TX-CARD)
   ========================================== */
.tx-card {
    background-color: var(--bg-card); 
    border: 1px solid var(--border-line); 
    border-radius: 10px;
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    position: relative; 
    height: 370px; /* Altura simétrica */
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
  opacity: 1;
  transform: scale(1);
}

.tx-card.dom-fade-out {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none; /* Evita cliques enquanto desaparece */
}

@media (min-width: 1024px) {
    .tx-card {height: 370px;}
}

/* 🛡️ FIX DA BARRA DE TOPO: z-index elevado para 20 garante que a linha nunca fica oculta por baixo do fundo */
.tx-card::before { 
    content: ''; 
    position: absolute; 
    top: 0; left: 0; right: 0; 
    height: 4px; 
    background: var(--tok-color); 
    z-index: 20; 
}
.tx-card.nft-type::before { background: var(--nft-color); }
.tx-card.whale-alert { border-color: var(--gold-whale); box-shadow: 0 4px 12px rgba(251, 191, 36, 0.1); }
.tx-card.whale-alert::before { background: var(--gold-whale); }

.whale-banner { position: absolute; top: 8px; right: 8px; background-color: var(--gold-whale); color: #060913; font-weight: 800; font-size: 0.58rem; padding: 1px 4px; border-radius: 3px; text-transform: uppercase; z-index: 5; }

/* ==========================================
   ⚡ UNIFORMIZAÇÃO DE ELEMENTOS DE MEDIA (130px FIXOS)
   ========================================== */

.media-container,
.skeleton-media { 
    width: 100%;
    height: 130px; 
    min-height: 130px;
    max-height: 130px;
    background-color: var(--bg-base); 
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; 
    border-bottom: 1px solid var(--border-line); 
    box-sizing: border-box;
    margin: 0; padding: 0;
    position: relative;
}

/* Comportamento retangular nativo das imagens de NFTs e Ghost Card */
.media-container img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    opacity: 0; 
    transition: opacity 0.15s ease; 
}
.media-container img.loaded { 
    opacity: 1; 
}

.media-placeholder { 
    font-size: 1.5rem; 
    opacity: 0.25; 
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%; 
}

/* ==========================================
   🪙 🔘 COMPACTAÇÃO DA MOEDA DE TOKENS DENTRO DOS 130PX
   ========================================== */

.tx-card.token-type .media-container img {
    width: 96px;
    min-width: 96px;
    height: 96px;
    min-height: 96px;
    border-radius: 50%; 
    border: 1px solid var(--border-line);
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: block;
    margin: 0 auto;
}

/* 🎯 FORÇA O LOGÓTIPO DO XTZ A SER UMA MOEDA REDONDA CENTRALIZADA */
.xtz-coin-icon {
    width: 64px;
    min-width: 64px;
    height: 64px;
    min-height: 64px;
    border-radius: 50%;
    border: 1px solid var(--border-line);
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: block;
    margin: 0 auto; /* Centralização matemática perfeita no meio dos 130px */
}


/* Centralização estrita do ícone/emoji de fallback de tokens sem imagem */
.tx-card.token-type .media-container .media-placeholder,
.tx-card.token-type .media-container span,
.tx-card.token-type .media-container svg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    min-width: 96px;
    height: 96px;
    min-height: 96px;
    border-radius: 50%;
    border: 1px solid var(--border-line);
    background-color: var(--bg-card);
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    margin: 0 auto;
    box-sizing: border-box;
}

/* 📐 ANATOMIA DO CORPO DO CARTÃO UNIFICADO */
.tx-body { 
    padding: 10px; 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    flex-grow: 1; 
    box-sizing: border-box;
}

.tx-card.token-type .tx-body {
    padding-top: 10px; 
}

/* 🔒 QUEBRAS DE LINHA E FLUXO VERTICAL EM MOBILE */

.tx-body-header {display: flex;flex-direction: column;align-items: flex-start;gap: 4px;border-bottom: 1px solid var(--border-line);padding-bottom: 4px;width: 100%;}.tx-card.token-type .tx-body-header {display: flex;flex-direction: column;align-items: flex-start;gap: 4px;}.alias-lbl {font-weight: 700;font-size: 0.8rem;color: var(--text-main);width: 100%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}.tx-card.token-type .alias-lbl {font-size: 0.82rem;white-space: normal;word-break: break-word;line-height: 1.2;}.time-stamp {font-family: monospace;font-size: 0.65rem;color: var(--text-muted);}.tx-card.token-type .time-stamp {display: block;width: 100%;}.address-row { font-family: monospace; font-size: 0.68rem; color: var(--text-muted); background-color: var(--bg-base); padding: 4px 6px; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.address-row strong { color: var(--text-main); font-weight: 600; margin-right: 2px; }.row-pair { display: flex; gap: 6px; width: 100%; }.row-pair .address-row { flex: 1; min-width: 0; }.badge-row-panel {display: flex;flex-direction: column;align-items: flex-start;gap: 4px;margin-top: auto;width: 100%;}.tx-card.token-type .badge-row-panel {display: flex;flex-direction: column;align-items: flex-start;gap: 6px;}.badge-tag { font-size: 0.58rem; font-weight: 800; padding: 1px 4px; border-radius: 3px; text-transform: uppercase; }.badge-tag.token { background-color: rgba(59, 130, 246, 0.1); color: #60a5fa; }.badge-tag.nft { background-color: rgba(168, 85, 247, 0.1); color: #c084fc; }.amount-val {font-size: 0.75rem;font-weight: 700;color: var(--win-green);font-family: monospace;width: 100%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;padding-left: 2px;}.tx-card.token-type .amount-val {font-size: 0.75rem;white-space: normal;line-height: 1.2;}

/* ==========================================
🖥️ COMPATIBILIDADE PARA ECRÃS GRANDES (DESKTOP)========================================== */

@media (min-width: 1024px) {.tx-body-header,.tx-card.token-type .tx-body-header {flex-direction: row;justify-content: space-between;align-items: center;}.alias-lbl { max-width: 50%; }.badge-row-panel,.tx-card.token-type .badge-row-panel {flex-direction: row;justify-content: space-between;align-items: center;}.amount-val { text-align: right; max-width: 60%; }}/* Links do Rodapé Interno do Cartão */
.tx-footer-links { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border-line); background-color: var(--bg-panel); }.explorer-link { text-align: center; font-size: 0.65rem; padding: 8px 0; color: var(--text-muted); text-decoration: none; font-weight: 700; }.explorer-link:first-child { border-right: 1px solid var(--border-line); }.explorer-link:hover { background-color: var(--bg-base); color: #0d9488; }.filtered-out { display: none; }.hidden { display: none; }

/* ==========================================
📌 FOOTER RESPONSSIVO ADAPTIVO (54px Mobile / 40px Desktop)========================================== */

.app-minimal-footer {position: fixed;bottom: 0; left: 0; right: 0;height: 54px;z-index: 100;background-color: var(--bg-panel);border-top: 1px solid var(--border-line);box-sizing: border-box;display: flex;align-items: center;padding: 0 16px;transition: all 0.2s ease;}.footer-inline-container {width: 100%;display: grid;grid-template-columns: repeat(2, 1fr);row-gap: 4px;column-gap: 12px;font-size: 0.72rem;font-weight: 600;color: var(--text-muted);white-space: nowrap;}.footer-inline-container span:nth-child(even),.footer-inline-container a {text-align: right;}.footer-brand { color: var(--text-main); font-weight: 700; }.footer-api-link { color: var(--text-muted); text-decoration: none; transition: color 0.15s ease; }.footer-api-link:hover { color: #4500ff; }
@media (min-width: 1024px) {.app-minimal-footer { height: 40px; }.footer-inline-container {display: flex;justify-content: space-between;align-items: center;grid-template-columns: none;gap: 0;}.footer-inline-container span:nth-child(even) { text-align: left; }}

/* ==========================================
💀 SKELETON SCREEN LOADING COMPONENT (GHOST CARD)========================================== */

.skeleton-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-line);
    border-radius: 10px;
    height: 370px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    pointer-events: none;
    animation: skeletonGlowEffect 2s infinite ease-in-out;
}

/* Barra decorativa reativa superior */
.skeleton-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    z-index: 20;
    animation: skeletonBarColor 3.2s infinite ease-in-out;
}

/* Caixa de Media Superior Sincronizada */
.skeleton-media {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-base);
    width: 100%;
    height: 130px;
    box-sizing: border-box;
}

.skeleton-logo-center {
    width: 96px;
    min-width: 96px;
    height: 96px;
    min-height: 96px;
    border-radius: 50%;
    border: 1px solid var(--border-line);
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: block;
    margin: 0 auto;
    
    /* Mantém uma ligeira animação de pulsação suave em sintonia com o esqueleto */
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

/* 🎯 AREA DE SPINNER INLINE: Ocupa o espaço exato onde viviam as linhas escuras */
.skeleton-body-spinner-workspace {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    /* Desconta os 130px do topo e os 42px do rodapé, isolando a área do texto */
    height: calc(350px - 172px); 
    box-sizing: border-box;
}

/* 🌀 O ANEL INTERNO DE CARREGAMENTO ROTATIVO (Spinner Compacto) */
.tezos-inline-spinner {
    width: 54px;
    height: 54px;
    border: 3px solid var(--border-line);
    border-top: 3px solid var(--tok-color); /* Acende com o azul ativo da rede Tezos */
    border-radius: 50%;
    position: absolute;
    z-index: 5;
    animation: fastContinuousRotation 1.1s linear infinite;
}

/* ꜩ SÍMBOLO DA TEZOS ENQUADRADO */
.tezos-inline-symbol {
    font-size: 1.8rem;
    font-weight: 400;
    color: var(--text-main);
    opacity: 0.75;
    z-index: 10;
    position: absolute;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1;
    margin-top: -4px;
}

/* Rotação Contínua Fluida Acelerada por Hardware */
@keyframes fastContinuousRotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Rodapé Fantasma */
.skeleton-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--border-line);
    background-color: var(--bg-panel);
    height: 28px;
    min-height: 28px;
    max-height: 42px;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%;
}
.skeleton-button-long {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.6px;
    text-align: center;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    line-height: 1;
}

@media (min-width: 1024px) {
    .skeleton-card {height: 370px;}
    .skeleton-body-spinner-workspace {height: calc(370px - 162px);}
    .skeleton-footer {height: 28px; min-height: 28px; max-height: 28px;}
}

/* ==========================================================
   🧹 CLASSES VISUAIS PARA BOTÃO DE REFRESH E PURGA DO DOM
   ======================================================= */

/* Transição suave de cor para o novo botão de Refresh */
.btn-refresh-ui {
    transition: background-color 0.2s ease, transform 0.1s ease;
}

/* Feedback visual quando o utilizador passa o rato (Hover) */
.btn-refresh-ui:hover {
    background-color: var(--accent-color, rgb(0, 175, 0)) !important; /* Usa a tua cor de destaque ou um tom vivo */
    transform: translateY(-1px);
    cursor: pointer;
}

/* Feedback visual quando o utilizador clica (Active) */
.btn-refresh-ui:active {
    transform: translateY(1px);
}

/* Transição geométrica suave para os cartões ativos da grelha */
#stream .tx-card {
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    opacity: 1;
    transform: scale(1);
}

/* Classe aplicada em microssegundos pelo motor gráfico antes da purga */
.dom-fade-out {
    opacity: 0 !important;
    transform: scale(0.95) !important;
    pointer-events: none;
}

/* 🔄 ANIMAÇÕES DE SINCRONIZAÇÃO */
@keyframes beaconGlow { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }@keyframes skeletonBarColor {0% { background-color: var(--tok-color); }50% { background-color: var(--nft-color); }100% { background-color: var(--tok-color); }}@keyframes skeletonGlowEffect {0% { background-color: var(--bg-card); }50% { background-color: var(--bg-base); }100% { background-color: var(--bg-card); }}

#open-modal-link {cursor: pointer; text-decoration: none;}


.simple-modal {
    display: none; /* Ativado como 'flex' via JS */
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(5px); 
    -webkit-backdrop-filter: blur(5px); 
    z-index: 9999; 
    
    /* Centralização universal */
    display: flex;
    align-items: center; 
    justify-content: center;
    text-align: justify;
    
    /* 🌟 NOVO: Margem de segurança para o modal respirar em ecrãs pequenos */
    padding: 16px; 
    box-sizing: border-box;
}

/* Garante que cada parágrafo do modal respira de forma igual */
.modal-div p {
    margin-bottom: 10px;
    line-height: 1.25; 
    font-size: small;
}

/* ✏️ EDITADO: A Caixa Principal do Modal */
.modal-div {
    background: #1e293b; 
    color: white; 
    padding: 16px; 
    border-radius: 12px; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3); 
    
    width: 90%; 
    max-width: 545px; 
    box-sizing: border-box; 
    
    /* 🌟 AS DUAS REGRAS QUE RESOLVEM O TEU PROBLEMA 🌟 */
    max-height: 85vh;       /* Limita a altura total da caixa a 85% da altura do ecrã */
    overflow-y: auto;       /* Ativa o scroll na caixa inteira. Os botões sobem junto com o texto! */
}

/* ✏️ EDITADO: Painel de Botões (Fica naturalmente no fim do fluxo de scroll) */
.simple-modal .div-btn {
    display: flex; 
    justify-content: flex-end; 
    gap: 12px; 
    margin-top: 20px; /* Espaço extra para separar claramente o fim do texto dos botões */
    flex-wrap: wrap; 
}

#accept-modal-btn {cursor: pointer; background: green; color: white; border: none; padding: 3px 3px; border-radius: 0px; float: right; font-size: smaller;}
#reject-modal-btn {cursor: pointer; background: red; color: white; border: none; padding: 3px 3px; border-radius: 0px; float: right; font-size: smaller;}

@media (min-width: 1024px) {
    .modal-div p {line-height: 1.45; font-size: medium;}
    #accept-modal-btn {padding: 4px 8px; font-size: medium;}
    #reject-modal-btn {padding: 4px 8px; font-size: medium;}
}

.purplematter a { color: #a855f7; text-decoration: none; font-size: small; }
