/* Página de Devoluções */
.devolucoes-page {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  background: #f8fafc;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 2rem;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-info h1 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 2.5rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.page-icon {
  color: #f59e0b;
}

.header-info p {
  color: #64748b;
  font-size: 1.1rem;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: #64748b;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top: 4px solid #f59e0b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

/* Vendas Container */
.vendas-container {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.vendas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1.5rem;
}

.venda-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.2s;
}

.venda-card:hover {
  border-color: #f59e0b;
  box-shadow: 0 4px 12px -2px rgba(245, 158, 11, 0.1);
}

.venda-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.venda-info h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.venda-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.venda-data,
.venda-cliente {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #64748b;
  font-size: 0.9rem;
}

.venda-valor {
  font-size: 1.5rem;
  font-weight: 700;
  color: #10b981;
}

.venda-itens h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.75rem;
}

.itens-lista {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.item-resumo {
  padding: 0.75rem;
  background: white;
  border-radius: 8px;
  border-left: 3px solid #f59e0b;
  font-size: 0.9rem;
}

.item-info-completa {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.item-nome {
  font-weight: 600;
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.2;
}

.item-variacao {
  font-size: 0.8rem;
  color: #6b7280;
  font-weight: 500;
}

.item-detalhes {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
}

.item-quantidade {
  color: #10b981;
  font-weight: 600;
  font-size: 0.8rem;
}

.item-valor {
  color: #f59e0b;
  font-weight: 600;
  font-size: 0.8rem;
}

.mais-itens {
  font-style: italic;
  justify-content: center;
}

.venda-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-detalhes {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
  flex: 1;
  justify-content: center;
}

.btn-detalhes:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.btn-devolucao {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
  flex: 1;
  justify-content: center;
}

.btn-devolucao:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: #64748b;
}

.empty-icon {
  font-size: 4rem;
  color: #cbd5e1;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 1.1rem;
}

/* Modal de Devolução */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.modal-devolucao {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #64748b;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #f1f5f9;
  color: #374151;
}

.modal-body {
  padding: 2rem;
}

.venda-info-modal {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 12px;
}

.venda-info-modal h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 1rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #64748b;
  font-weight: 500;
}

.info-item svg {
  color: #f59e0b;
}

.itens-devolucao h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 1rem;
}

.itens-lista-modal {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.item-devolucao {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  gap: 1rem;
}

.item-info {
  flex: 1;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.item-foto {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
}

.item-foto img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-dados {
  flex: 1;
}

.item-nome {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.item-codigo {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
  font-family: monospace;
}

.item-detalhes {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.variacao-badge,
.valor-badge,
.quantidade-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.variacao-badge {
  background: #dbeafe;
  color: #1e40af;
}

.valor-badge {
  background: #fef3c7;
  color: #d97706;
}

.quantidade-badge {
  background: #d1fae5;
  color: #065f46;
}

.item-controles {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 150px;
}

.item-controles label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
}

.quantidade-input {
  width: 80px;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  text-align: center;
  font-weight: 600;
}

.quantidade-input:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.valor-devolucao {
  color: #10b981;
  font-weight: 600;
  font-size: 0.9rem;
}

.motivo-devolucao {
  margin-bottom: 2rem;
}

.motivo-devolucao label {
  display: block;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.motivo-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
}

.motivo-textarea:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.resumo-devolucao {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
}

.resumo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.resumo-item:last-child {
  margin-bottom: 0;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

.valor-total {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ef4444;
}

.novo-valor {
  font-size: 1.2rem;
  font-weight: 700;
  color: #10b981;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1rem 2rem 2rem;
  border-top: 1px solid #e2e8f0;
}

.btn-cancelar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #6b7280;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancelar:hover {
  background: #4b5563;
}

.btn-processar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-processar:hover:not(:disabled) {
  background: #059669;
}

.btn-processar:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Tipo de Operação */
.tipo-operacao {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.tipo-operacao h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 1rem;
}

.radio-group {
  display: flex;
  gap: 2rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  color: #374151;
}

.radio-option input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #f59e0b;
}

/* Seção de Troca */
.itens-troca {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
}

.troca-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.troca-header h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin: 0;
}

.btn-adicionar-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-adicionar-item:hover {
  background: #059669;
  transform: translateY(-1px);
}

.lista-troca {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.item-troca {
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 1.5rem;
}

.troca-selects {
  display: grid;
  grid-template-columns: 2fr 2fr 80px 100px;
  gap: 1rem;
  margin-bottom: 1rem;
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.select-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
}

.select-produto,
.select-variacao,
.input-quantidade,
.input-valor {
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
}

.select-produto:focus,
.select-variacao:focus,
.input-quantidade:focus,
.input-valor:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.troca-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.valor-total-item {
  font-weight: 600;
  color: #10b981;
  font-size: 1.1rem;
}

.btn-remover-item {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remover-item:hover {
  background: #dc2626;
}

.empty-troca {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
  font-style: italic;
}

/* Resumo com Troca */
.valor-devolucao {
  color: #ef4444;
  font-weight: 600;
}

.valor-troca {
  color: #10b981;
  font-weight: 600;
}

.diferenca-valor {
  font-weight: 700;
  font-size: 1.1rem;
}

.diferenca-valor.positiva {
  color: #ef4444; /* Vermelho para valores a pagar */
}

.diferenca-valor.negativa {
  color: #10b981; /* Verde para valores a receber */
}

/* Modal de Histórico */
.modal-historico {
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
}

.historico-vazio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #64748b;
  text-align: center;
}

.historico-vazio svg {
  color: #cbd5e1;
  margin-bottom: 1rem;
}

.historico-vazio h3 {
  margin: 0.5rem 0;
  color: #374151;
}

.historico-lista {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.historico-item {
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  border-radius: 12px;
  border: 2px solid #e9ecef;
  padding: 1.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.historico-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e9ecef;
}

.evento-tipo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.evento-data {
  font-size: 0.9rem;
  color: #666;
  font-weight: 500;
}

.evento-produto h4 {
  color: #dc3545;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.produto-card {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 0.5rem;
}

.produto-nome {
  font-weight: 600;
  font-size: 1.1rem;
  color: #333;
  margin-bottom: 0.5rem;
}

.produto-detalhes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
}

.produto-detalhes span {
  background: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  border: 1px solid #e9ecef;
}

.evento-motivo {
  margin-top: 1rem;
  background: #e7f3ff;
  border: 1px solid #b3d9ff;
  border-radius: 8px;
  padding: 1rem;
}

.evento-motivo h4 {
  color: #0066cc;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.motivo-texto {
  background: #fff;
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-style: italic;
  color: #333;
}

/* Responsividade */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
  
  .vendas-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    width: 95%;
    margin: 1rem;
    max-height: 90vh;
  }
  
  .modal-historico {
    max-width: 95%;
  }
  
  .item-info-completa {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  
  .item-detalhes {
    width: 100%;
    justify-content: space-between;
  }
  
  .evento-tipo {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .produto-detalhes {
    grid-template-columns: 1fr;
  }
  
  .modal-devolucao {
    max-height: 95vh;
  }
  
  .modal-footer {
    padding-left: 1rem;
    padding-right: 1rem;
    flex-direction: column;
  }

  .item-devolucao {
    flex-direction: column;
    align-items: stretch;
  }

  .item-controles {
    align-items: stretch;
    min-width: auto;
  }

  .quantidade-input {
    width: 100%;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .radio-group {
    flex-direction: column;
    gap: 1rem;
  }

  .troca-selects {
    grid-template-columns: 1fr;
  }

  .troca-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .troca-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
}
