/* ============================================================
   CALENDÁRIO FINANCEIRO — v8.4.0
   ============================================================ */

/* Navegação do calendário */
.calendario-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-calendario-nav {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: .85rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-calendario-nav:hover {
  background: var(--primary-light);
  color: white;
  border-color: var(--primary-light);
}

#calendario-mes-atual {
  min-width: 140px;
  text-align: center;
}

/* Grid do calendário */
.calendario-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 8px 0;
}

/* Cabeçalho dos dias da semana */
.calendario-dia-semana {
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 4px;
  background: var(--bg-secondary);
  border-radius: 4px;
}

/* Células do calendário */
.calendario-celula {
  position: relative;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  background: white;
  transition: all 0.2s ease;
}

.calendario-celula:hover {
  border-color: var(--primary-light);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.calendario-celula.vazia {
  background: var(--bg-secondary);
  border-color: transparent;
  pointer-events: none;
}

.calendario-celula.hoje {
  border: 2px solid var(--primary);
  background: #eff6ff;
}

/* Número do dia */
.calendario-dia-numero {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calendario-celula.hoje .calendario-dia-numero {
  color: var(--primary);
  font-weight: 700;
}

/* Valores do dia */
.calendario-dia-valores {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: .7rem;
}

.cal-receita {
  color: #16a34a;
  font-weight: 600;
}

.cal-despesa {
  color: #ef4444;
  font-weight: 600;
}

.cal-resultado {
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: .68rem;
}

.cal-resultado.positivo {
  color: #16a34a;
  background: #f0fdf4;
}

.cal-resultado.negativo {
  color: #ef4444;
  background: #fef2f2;
}

/* Botão expandir */
.calendario-expandir {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  width: 20px;
  height: 20px;
  font-size: .75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.calendario-expandir:hover {
  background: var(--primary-dark);
  transform: scale(1.1);
}

/* ============================================================
   MODAL DE DETALHAMENTO DE DIA
   ============================================================ */

.modal-detalhe-dia {
  max-width: 700px !important;
}

.detalhe-dia-resumo {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.detalhe-kpi {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.detalhe-kpi.receita {
  background: #f0fdf4;
  border-left: 3px solid #16a34a;
}

.detalhe-kpi.despesa {
  background: #fef2f2;
  border-left: 3px solid #ef4444;
}

.detalhe-kpi.resultado {
  background: #f8fafc;
  border-left: 3px solid var(--primary);
}

.detalhe-kpi.resultado.positivo {
  background: #f0fdf4;
  border-left-color: #16a34a;
}

.detalhe-kpi.resultado.negativo {
  background: #fef2f2;
  border-left-color: #ef4444;
}

.detalhe-label {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.detalhe-valor {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.detalhe-dia-lista h4 {
  font-size: .9rem;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.table-detalhe-dia {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}

.table-detalhe-dia thead th {
  background: var(--bg-secondary);
  padding: 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.table-detalhe-dia tbody td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.table-detalhe-dia tbody tr:hover {
  background: var(--bg-secondary);
}

.badge-origem {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 500;
}

/* Cores de valores */
.table-detalhe-dia .positivo {
  color: #16a34a;
  font-weight: 600;
}

.table-detalhe-dia .negativo {
  color: #ef4444;
  font-weight: 600;
}

/* ============================================================
   RESPONSIVIDADE DO CALENDÁRIO
   ============================================================ */

@media (max-width: 768px) {
  .calendario-grid {
    gap: 4px;
  }

  .calendario-celula {
    min-height: 75px;
    padding: 4px;
  }

  .calendario-dia-numero {
    font-size: .7rem;
  }

  .calendario-dia-valores {
    font-size: .65rem;
  }

  .cal-resultado {
    font-size: .62rem;
  }

  .calendario-expandir {
    width: 18px;
    height: 18px;
    font-size: .7rem;
  }

  .detalhe-dia-resumo {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .calendario-nav {
    gap: 8px;
    font-size: .8rem;
  }

  #calendario-mes-atual {
    min-width: 100px;
    font-size: .85rem;
  }

  .btn-calendario-nav {
    padding: 3px 8px;
    font-size: .75rem;
  }

  .calendario-celula {
    min-height: 65px;
    padding: 3px;
  }

  .calendario-dia-valores {
    gap: 2px;
    font-size: .6rem;
  }
}

/* ============================================================
   VENDAS STONE AGRUPADAS (v8.4.0)
   ============================================================ */

.stone-grupo-dia {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.stone-grupo-dia:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stone-grupo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.stone-grupo-header:hover {
  background: #f1f5f9;
}

.stone-grupo-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.stone-grupo-data {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-primary);
}

.stone-grupo-qtd {
  font-size: .8rem;
  color: var(--text-muted);
  background: #e0f2fe;
  padding: 2px 8px;
  border-radius: 12px;
}

.stone-grupo-resumo {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stone-tipo-badge {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: #dbeafe;
  color: #1e40af;
  font-weight: 500;
}

.stone-grupo-valores {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: .85rem;
}

.stone-valor-bruto {
  color: #64748b;
}

.stone-valor-taxas {
  color: #ef4444;
  font-weight: 600;
}

.stone-valor-liquido {
  color: #16a34a;
  font-weight: 700;
  font-size: .95rem;
}

.stone-grupo-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--primary);
  font-size: 1rem;
  transition: transform 0.2s ease;
}

.stone-grupo-toggle:hover {
  color: var(--primary-dark);
}

.stone-grupo-detalhes {
  padding: 16px;
  background: white;
}

.stone-vendas-tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}

.stone-vendas-tabela thead th {
  background: var(--bg-secondary);
  padding: 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  font-size: .75rem;
  text-transform: uppercase;
}

.stone-vendas-tabela tbody td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.stone-vendas-tabela tbody tr:hover {
  background: var(--bg-secondary);
}

.stone-id-cell {
  font-family: monospace;
  font-size: .75rem;
  color: var(--text-muted);
}

.stone-produto-badge {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: #f0fdf4;
  color: #166534;
  font-weight: 500;
}

.valor-positivo {
  color: #16a34a;
  font-weight: 600;
}

.valor-negativo {
  color: #ef4444;
  font-weight: 600;
}

.valor-destaque {
  color: #1e40af;
  font-weight: 700;
}

.stone-total-row {
  background: #f8fafc;
  font-weight: 600;
}

.stone-total-row td {
  padding: 12px 8px !important;
  border-top: 2px solid var(--border);
  border-bottom: none !important;
}

/* Responsividade */
@media (max-width: 768px) {
  .stone-grupo-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .stone-grupo-valores {
    width: 100%;
    justify-content: space-between;
    font-size: .75rem;
  }

  .stone-vendas-tabela {
    font-size: .7rem;
  }

  .stone-vendas-tabela thead th,
  .stone-vendas-tabela tbody td {
    padding: 6px 4px;
  }
}

@media (max-width: 480px) {
  .stone-grupo-resumo {
    display: none;
  }

  .stone-grupo-valores {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
