/* CalculaFin Fundos - Estilos com cores e animações */

/* Animações globais */
@keyframes cf-fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes cf-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes cf-shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

@keyframes cf-bounce {
    0%, 20%, 53%, 80%, 100% { transform: translate3d(0,0,0); }
    40%, 43% { transform: translate3d(0, -8px, 0); }
    70% { transform: translate3d(0, -4px, 0); }
    90% { transform: translate3d(0, -2px, 0); }
}

/* Container principal */
.cf-fundos-wrap {
    animation: cf-fadeIn 0.6s ease-out;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Nota informativa */
.cf-fundos-note {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
    position: relative;
    overflow: hidden;
}

.cf-fundos-note::before {
    content: '';
    position: absolute;
    top: 0;
    left: -200px;
    width: 200px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: cf-shimmer 2s infinite;
}

/* Container da tabela */
.cf-fundos-table-wrap {
    overflow: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    background: white;
    border: 1px solid #e5e7eb;
}

/* Tabela principal */
.cf-fundos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: white;
}

/* Cabeçalho da tabela */
.cf-fundos-table th {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    color: white;
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid #4f46e5;
}

.cf-fundos-table th:first-child {
    border-top-left-radius: 12px;
}

.cf-fundos-table th:last-child {
    border-top-right-radius: 12px;
}

/* Células da tabela */
.cf-fundos-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.3s ease;
    position: relative;
}

/* Linhas da tabela */
.cf-fundos-table tbody tr {
    transition: all 0.3s ease;
    cursor: pointer;
}

.cf-fundos-table tbody tr:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cf-fundos-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.cf-fundos-table tbody tr:nth-child(even):hover {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

/* Estilos específicos por tipo de coluna */
.cf-fundos-table td:first-child {
    font-weight: 600;
    color: #1f2937;
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Ticker - destaque especial */
.cf-fundos-table tbody tr td:first-child {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    font-weight: bold;
    text-align: center;
    border-radius: 6px;
    margin: 4px;
    position: relative;
    overflow: hidden;
}

.cf-fundos-table tbody tr td:first-child::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.cf-fundos-table tbody tr:hover td:first-child::before {
    left: 100%;
}

/* Cores por tipo de fundo */
.cf-fundos-table tbody tr[data-tipo*="FII"] td:first-child {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.cf-fundos-table tbody tr[data-tipo*="FIAGRO"] td:first-child {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Indicadores de variação */
.cf-fundos-table .variacao-positiva {
    color: #10b981;
    font-weight: 600;
    position: relative;
}

.cf-fundos-table .variacao-positiva::before {
    content: '▲';
    margin-right: 4px;
    animation: cf-bounce 2s infinite;
}

.cf-fundos-table .variacao-negativa {
    color: #ef4444;
    font-weight: 600;
    position: relative;
}

.cf-fundos-table .variacao-negativa::before {
    content: '▼';
    margin-right: 4px;
    animation: cf-bounce 2s infinite;
}

.cf-fundos-table .variacao-neutra {
    color: #6b7280;
    font-weight: 500;
}

/* Indicador de dividend yield */
.cf-fundos-table .dy-alto {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
}

.cf-fundos-table .dy-medio {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
}

.cf-fundos-table .dy-baixo {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
}

/* Loading state */
.cf-fundos-loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.cf-fundos-loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsividade */
@media (max-width: 768px) {
    .cf-fundos-table {
        font-size: 11px;
        table-layout: fixed;
        min-width: 100%;
        width: 100%;
    }
    
    .cf-fundos-table th,
    .cf-fundos-table td {
        padding: 8px 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .cf-fundos-table th {
        font-size: 10px;
        padding: 12px 6px;
    }
    
    /* Definindo larguras específicas para cada coluna em mobile */
    .cf-fundos-table th:nth-child(1),
    .cf-fundos-table td:nth-child(1) {
        width: 15%;
        min-width: 60px;
    }
    
    .cf-fundos-table th:nth-child(2),
    .cf-fundos-table td:nth-child(2) {
        width: 30%;
        min-width: 120px;
    }
    
    .cf-fundos-table th:nth-child(3),
    .cf-fundos-table td:nth-child(3) {
        width: 12%;
        min-width: 50px;
    }
    
    .cf-fundos-table th:nth-child(4),
    .cf-fundos-table td:nth-child(4) {
        width: 18%;
        min-width: 70px;
    }
    
    .cf-fundos-table th:nth-child(5),
    .cf-fundos-table td:nth-child(5) {
        width: 15%;
        min-width: 60px;
    }
    
    .cf-fundos-table th:nth-child(6),
    .cf-fundos-table td:nth-child(6) {
        width: 10%;
        min-width: 50px;
    }
    
    .cf-fundos-wrap {
        margin: 0 -10px;
    }
    
    .cf-fundos-table-wrap {
        border-radius: 0;
        border-left: none;
        border-right: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #cbd5e0 #f7fafc;
    }
    
    .cf-fundos-table-wrap::-webkit-scrollbar {
        height: 6px;
    }
    
    .cf-fundos-table-wrap::-webkit-scrollbar-track {
        background: #f7fafc;
        border-radius: 3px;
    }
    
    .cf-fundos-table-wrap::-webkit-scrollbar-thumb {
        background: #cbd5e0;
        border-radius: 3px;
    }
    
    .cf-fundos-table-wrap::-webkit-scrollbar-thumb:hover {
        background: #a0aec0;
    }
    
    /* Ajustes específicos para o ticker em mobile */
    .cf-fundos-table tbody tr td:first-child {
        font-size: 10px;
        padding: 6px 4px;
        border-radius: 4px;
        margin: 2px;
    }
    
    /* Ajustes para indicadores de DY em mobile */
    .cf-fundos-table .dy-alto,
    .cf-fundos-table .dy-medio,
    .cf-fundos-table .dy-baixo {
        padding: 2px 4px;
        font-size: 9px;
        border-radius: 8px;
    }
    
    /* Ajustes para variações em mobile */
    .cf-fundos-table .variacao-positiva::before,
    .cf-fundos-table .variacao-negativa::before {
        font-size: 8px;
        margin-right: 2px;
    }
}

/* Container da tabela para mobile */
.cf-fundos-table-wrap {
    -webkit-overflow-scrolling: touch; /* Suave rolagem em dispositivos móveis */
    overflow-x: auto;
    margin: 0 -15px; /* Compensa o padding do container pai */
    padding: 0 15px; /* Adiciona espaço para a sombra */
    position: relative;
}

/* Ajustes para telas pequenas */
@media (max-width: 768px) {
    .cf-fundos-table {
        min-width: 650px; /* Largura mínima para garantir que a tabela não quebre */
        width: 100%;
        display: table; /* Garante que a tabela mantenha o layout de tabela */
        table-layout: fixed;
    }
    
    /* Melhora a legibilidade em telas pequenas */
    .cf-fundos-table th,
    .cf-fundos-table td {
        padding: 12px 8px;
        font-size: 13px;
        white-space: nowrap; /* Impede quebra de linha nas células */
    }
    
    /* Ajusta o tamanho do cabeçalho */
    .cf-fundos-table th {
        font-size: 12px;
        padding: 14px 8px;
    }
    
    /* Ajusta o padding do container principal */
    .cf-fundos-wrap {
        padding: 0 5px;
    }
}

/* Ajustes para telas muito pequenas */
@media (max-width: 480px) {
    .cf-fundos-table {
        min-width: 600px; /* Largura mínima reduzida para telas muito pequenas */
    }
    
    .cf-fundos-table th,
    .cf-fundos-table td {
        padding: 10px 6px;
        font-size: 12px;
    }
    
    /* Melhora a visibilidade do scroll horizontal */
    .cf-fundos-table-wrap::-webkit-scrollbar {
        height: 6px;
    }
    
    .cf-fundos-table-wrap::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }
    
    .cf-fundos-table-wrap::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    
    .cf-fundos-table th {
        font-size: 11px;
        padding: 10px 4px;
        text-align: center;
        white-space: normal;
        line-height: 1.2;
    }
    
    /* Redefinindo larguras para telas muito pequenas - sem espaços vazios */
    .cf-fundos-table th:nth-child(1),
    .cf-fundos-table td:nth-child(1) {
        width: 18%;
        min-width: 60px;
    }
    
    .cf-fundos-table th:nth-child(2),
    .cf-fundos-table td:nth-child(2) {
        width: 32%;
        min-width: 110px;
    }
    
    .cf-fundos-table th:nth-child(3),
    .cf-fundos-table td:nth-child(3) {
        width: 15%;
        min-width: 50px;
    }
    
    .cf-fundos-table th:nth-child(4),
    .cf-fundos-table td:nth-child(4) {
        width: 20%;
        min-width: 70px;
    }
    
    .cf-fundos-table th:nth-child(5),
    .cf-fundos-table td:nth-child(5) {
        width: 18%;
        min-width: 60px;
    }
    
    .cf-fundos-table th:nth-child(6),
    .cf-fundos-table td:nth-child(6) {
        width: 15%;
        min-width: 50px;
    }
    
    .cf-fundos-table tbody tr td:first-child {
        font-size: 9px;
        padding: 4px 2px;
    }
    
    .cf-fundos-table .dy-alto,
    .cf-fundos-table .dy-medio,
    .cf-fundos-table .dy-baixo {
        padding: 1px 3px;
        font-size: 8px;
    }
    
    /* Garante que não haja overflow desnecessário */
    .cf-fundos-table-wrap {
        overflow-x: auto;
        overflow-y: hidden;
    }
}

/* Efeitos especiais */
.cf-fundos-table tbody tr {
    position: relative;
}

.cf-fundos-table tbody tr::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transition: width 0.3s ease;
}

.cf-fundos-table tbody tr:hover::after {
    width: 100%;
}

/* Tooltip personalizado */
.cf-tooltip {
    position: relative;
    cursor: help;
}

.cf-tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.cf-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-8px);
}



/* Melhorias adicionais para dispositivos móveis */
@media (max-width: 768px) {
    /* Adiciona uma dica visual para indicar que a tabela pode ser rolada horizontalmente */
    .cf-fundos-table-wrap::after {
        content: '← Deslize para ver mais →';
        display: block;
        text-align: center;
        font-size: 11px;
        color: #6b7280;
        padding: 8px;
        background: #f9fafb;
        border-top: 1px solid #e5e7eb;
        font-style: italic;
    }
    
    /* Remove a dica após o primeiro scroll */
    .cf-fundos-table-wrap.scrolled::after {
        display: none;
    }
}

/* Melhora a experiência de toque em dispositivos móveis */
@media (hover: none) and (pointer: coarse) {
    .cf-fundos-table tbody tr:hover {
        background: inherit;
        transform: none;
        box-shadow: none;
    }
    
    .cf-fundos-table tbody tr:active {
        background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    }
}

