/**
 * TRANSAÇÕES
 * Listagem de transações (entradas e saídas)
 */

.despesas-lista,
.transacoes-lista {
    display: grid;
    gap: var(--spacing-md);
}

/* Aba Revisão: selects de categoria/método dentro do card */
.select-mini {
    font-size: .78rem;
    padding: .2rem .4rem;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    max-width: 9rem;
}

/* Aba Revisão: campo de descrição editável dentro do card */
.input-mini {
    font-size: .78rem;
    padding: .2rem .4rem;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}
.despesa-desc-input {
    flex: 1 1 auto;
    min-width: 6rem;
    max-width: 16rem;
}

/* Aba Revisão: dica + botão de sincronizar */
.revisao-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    flex-wrap: wrap;
    margin-bottom: var(--spacing-md);
}
.revisao-topo .menu-hint { margin: 0; flex: 1 1 14rem; }
.revisao-topo-acoes { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.sync-range {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .8rem;
    color: var(--text-muted, #6c757d);
    white-space: nowrap;
}
.sync-qtd { width: 3.6rem; text-align: right; }

/* Faturas de cartão (topo das Próximas) */
.faturas-cartao { display: flex; flex-direction: column; gap: .4rem; margin-bottom: var(--spacing-md); }
.faturas-titulo { font-size: .8rem; font-weight: 700; color: var(--text-muted); margin: 0 0 .1rem; text-transform: uppercase; letter-spacing: .03em; }
.fatura-item {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    padding: .5rem .7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--cor-cartao, var(--primary));
    border-radius: var(--radius-sm);
}
.fatura-nome { flex: 1; min-width: 0; font-weight: var(--font-weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fatura-venc { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.fatura-total { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Alternância de visão da aba Despesas: Por recorrência / Por método */
.modo-lista {
    display: flex;
    gap: .35rem;
    background: var(--surface-3);
    padding: .25rem;
    border-radius: var(--radius-sm);
    margin: 0 0 var(--spacing-md);
}
.modo-lista .modo-btn {
    flex: 1;
    padding: .4rem .5rem;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-size: .8rem;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    white-space: nowrap;
}
.modo-lista .modo-btn.active {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

/* ---- Card único do lançamento: DIA DOW — VALOR MÉTODO CATEGORIA DESCRIÇÃO ---- */
.despesa-item {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .3rem .5rem;
    padding: .55rem var(--spacing-md);
    background: var(--light);
    border-left: 4px solid var(--secondary);
    border-radius: var(--radius-sm);
    transition: box-shadow var(--transition-normal);
}

.despesa-item:hover {
    box-shadow: var(--shadow-sm);
}

.despesa-item.entrada {
    border-left-color: var(--success);
}

.despesa-item.saida {
    border-left-color: var(--danger);
}

/* Dia do mês + tricode do dia da semana (ex.: 28 SEG) */
.despesa-data {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: baseline;
    gap: .25rem;
    font-variant-numeric: tabular-nums;
}
.despesa-dia {
    font-size: 1.05rem;
    line-height: 1;
    font-weight: var(--font-weight-bold);
    color: var(--text);
}
.despesa-dow {
    font-size: .9rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-muted);
}

.despesa-valor {
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

/* Descrição — no fim da linha, discreta */
.despesa-desc {
    color: var(--text-muted);
    font-style: italic;
    word-break: break-word;
}

/* "Chip" / tarjinha colorida para método / categoria / recorrência */
.chip {
    display: inline-block;
    font-size: 0.72rem;
    color: #fff;
    background: var(--primary);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-weight: var(--font-weight-semibold);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.chip--neutro { background: var(--surface-3); color: var(--text-muted); }

/* Info da parcela: "3/12" */
.parcela-tag {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface-3);
    border-radius: 999px;
    padding: .05rem .45rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.quitado-badge {
    font-size: .66rem;
    font-weight: 700;
    color: #059669;
    background: rgba(16, 185, 129, .12);
    border-radius: 999px;
    padding: .05rem .45rem;
    white-space: nowrap;
}

/* Tag "em Xd" / "hoje" (usada nas Próximas) */
.quando-tag {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface-3);
    border-radius: 999px;
    padding: .05rem .45rem;
    white-space: nowrap;
}

/* Ícones de editar/excluir menores nas listas */
.despesa-actions .btn-icon {
    min-width: 24px;
    width: 24px;
    height: 24px;
    font-size: 13px;
    padding: 0;
}

/* ---- Subgrupos recolhíveis por recorrência ---- */
.rec-grupo {
    border: 1px solid var(--border);
    border-left: 3px solid var(--cor-rec, var(--primary));
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    margin-bottom: .5rem;
    overflow: hidden;
}
.rec-grupo > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .7rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text);
}
.rec-grupo > summary::-webkit-details-marker { display: none; }
.rec-grupo > summary::before {
    content: "▸";
    font-size: .8em;
    color: var(--cor-rec, var(--text-muted));
}
.rec-grupo[open] > summary::before { content: "▾"; }
.rec-grupo-nome { flex: 1; }
.rec-grupo-contagem {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface-3);
    border-radius: 999px;
    padding: .05rem .45rem;
}
.rec-grupo-total { font-variant-numeric: tabular-nums; }
.rec-grupo-itens {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    padding: 0 .5rem .5rem;
}

/* Badge de recorrência */
.recorrencia-badge {
    display: inline-block;
    font-size: var(--font-size-sm);
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-xs);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.recorrencia-badge.mensal {
    background: #8B5CF6;
}

.recorrencia-badge.ultimo-util {
    background: #EC4899;
}

.recorrencia-badge.parcelada {
    background: #F59E0B;
}

.recorrencia-badge.vencimento {
    background: #06B6D4;
}

/* Informações adicionais */
.despesa-meta {
    display: flex;
    gap: var(--spacing-lg);
    font-size: var(--font-size-sm);
    color: var(--gray);
    margin-top: var(--spacing-sm);
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    white-space: nowrap;
}

.meta-item strong {
    color: var(--dark);
}

/* Linha 3: "Categoria: descrição" */
.despesa-descricao {
    font-size: var(--font-size-sm);
    color: var(--gray);
    margin: 0;
    line-height: 1.35;
}

/* Valor (linha 1) */
.despesa-valor {
    font-size: 1rem;
    font-weight: var(--font-weight-bold);
    color: var(--danger);
    white-space: nowrap;
}

.despesa-item.entrada .despesa-valor {
    color: var(--success);
}

/* Mensagem vazia */
.empty-message {
    text-align: center;
    color: var(--gray);
    padding: var(--spacing-xl);
    font-style: italic;
    grid-column: 1 / -1;
}

/* Estados especiais */
.despesa-item.pendente {
    opacity: 0.7;
    background: rgba(245, 158, 11, 0.05);
}

.despesa-item.cancelada {
    opacity: 0.5;
    text-decoration: line-through;
}

.despesa-item.ativa {
    background: white;
    box-shadow: var(--shadow-sm);
}

/* Animação de entrada */
@keyframes slideInLeft {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.despesa-item {
    animation: slideInLeft 0.3s ease;
}

/* Efeito ao hover com ícone de ação */
.despesa-item.interativo:hover {
    cursor: pointer;
    background: rgba(79, 70, 229, 0.05);
    border-left-color: var(--primary);
}

/* Breakpoints */
@media (max-width: 768px) {
    .despesa-item {
        flex-direction: row;
        align-items: center;
        gap: var(--spacing-sm);
    }

    .despesa-valor {
        width: auto;
        text-align: right;
    }
}

@media (max-width: 480px) {
    .despesa-item {
        padding: var(--spacing-md);
        border-left-width: 3px;
    }

    .despesa-categoria {
        font-size: var(--font-size-sm);
    }

    .recorrencia-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }

    .despesa-valor {
        font-size: 1rem;
    }
}

/* Ações por transação (editar / excluir) */
.despesa-item { position: relative; }
.despesa-actions {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-shrink: 0;
  margin-left: auto;
}
.despesa-actions .btn-icon.armed {
  width: auto;
  padding: 0 .5rem;
  font-size: .7rem;
  color: #DC2626;
  font-weight: 700;
}

/* Ocorrência pendente (aguardando confirmação) */
.despesa-item.pendente {
  border: 1px dashed #C7B8F5;
  background: rgba(124, 58, 237, .04);
}
.pendente-badge {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: #7C3AED;
  border: 1px solid #C7B8F5;
  border-radius: 6px;
  padding: 1px 5px;
}
.btn-ok {
  border: 0;
  border-radius: 6px;
  background: #7C3AED;
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  padding: .25rem .7rem;
  cursor: pointer;
}

/* Parcela quitada (zerada) */
.despesa-item.quitada .despesa-descricao,
.despesa-item.quitada .despesa-valor {
  text-decoration: line-through;
  opacity: .55;
}
.quitar-check {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .8rem;
  color: #6B7280;
  white-space: nowrap;
  cursor: pointer;
}
.quitar-check input { width: auto; margin: 0; }

/* Diálogo modal */
.dialogo-overlay {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  background: rgba(17, 24, 39, .45);
  padding: 1rem;
}
.dialogo {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 45px rgba(0,0,0,.25);
}
.dialogo h3 { margin: 0 0 .5rem; font-size: 1.05rem; color: #1F2937; }
.dialogo p { margin: 0 0 1.25rem; color: #4B5563; font-size: .92rem; }
.dialogo-acoes { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }

.despesa-valor .valor-meta { font-weight: 400; opacity: .6; font-size: .85em; }

/* Agrupamento Fixas / Pontuais */
.grupo-cab {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 1.25rem 0 .5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: .8rem;
  color: var(--dark);
  border-bottom: 2px solid var(--light);
  padding-bottom: .3rem;
}
.grupo-cab:first-child { margin-top: 0; }
.grupo-sub {
  display: flex;
  justify-content: space-between;
  margin: .6rem 0 .3rem;
  font-weight: 600;
  font-size: .82rem;
  color: var(--gray);
  padding-left: .25rem;
}
