/* ========================================
   QUANTIDADES E LEVANTAMENTOS - ESTILOS CORRIGIDOS
   Sistema CF Obras
   Correções: Cabeçalhos legíveis, modal de seleção, busca aprimorada
   ======================================== */

/* ========================================
   HEADER
   ======================================== */
.quantidades-header,
.levantamentos-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.quantidades-header h2,
.levantamentos-header h2 {
  margin: 0 0 1rem 0;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.obra-info {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.obra-info p {
  margin: 0.5rem 0;
  opacity: 0.95;
}

/* ========================================
   CORREÇÃO CRÍTICA: CABEÇALHOS COM CORES LEGÍVEIS
   ======================================== */

/* Cabeçalho da tabela de busca - GARANTIR BRANCO */
.tabela-busca thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.tabela-busca thead tr {
  background: transparent !important;
}

.tabela-busca th {
  padding: 1rem !important;
  text-align: left !important;
  font-weight: 600 !important;
  font-size: 0.95rem !important;
  border-right: 1px solid rgba(255,255,255,0.15) !important;
  color: white !important;
  background: transparent !important;
}

.tabela-busca th:last-child {
  border-right: none !important;
}

/* Cabeçalho da seção de busca - GARANTIR BRANCO */
.busca-resultados-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
}

.busca-resultados-header strong {
  color: white !important;
}

.busca-resultados-header button {
  color: white !important;
}

/* Tabela de insumos - Cabeçalhos BRANCOS */
.tabela-insumos thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.tabela-insumos thead tr {
  background: transparent !important;
}

.tabela-insumos th {
  padding: 1rem !important;
  text-align: left !important;
  font-weight: 600 !important;
  color: white !important;
  background: transparent !important;
  border-right: 1px solid rgba(255,255,255,0.15) !important;
}

.tabela-insumos th:last-child {
  border-right: none !important;
}

/* GARANTIR que TODOS os <th> tenham cor branca */
thead th,
th {
  color: white !important;
}

/* Força cor branca em headings dentro de header colorido */
.quantidades-header h2,
.quantidades-header h3,
.levantamentos-header h2,
.levantamentos-header h3 {
  color: white !important;
}

/* ========================================
   CONTROLES
   ======================================== */
.quantidades-controles {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-bottom: 2rem;
}

/* Import Section */
.import-section {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.import-section h3 {
  margin: 0 0 1.5rem 0;
  color: #333;
  font-size: 1.3rem;
}

.import-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.import-card {
  background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  transition: all 0.3s;
}

.import-card:hover {
  border-color: #667eea;
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15);
}

.import-card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.import-card-header img {
  width: 48px;
  height: 48px;
}

.import-card h4 {
  margin: 0;
  color: #333;
  font-size: 1.3rem;
}

.import-card p {
  color: #666;
  margin: 0 0 1.5rem 0;
  font-size: 0.95rem;
}

.btn-file {
  display: inline-block;
  background: #667eea;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 500;
}

.btn-file:hover {
  background: #5568d3;
}

.btn-file span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* View Controls */
.view-controls {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.view-controls h3 {
  margin: 0 0 1.5rem 0;
  color: #333;
  font-size: 1.3rem;
}

.toggle-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-toggle {
  background: #f5f5f5;
  color: #666;
  border: 2px solid #e0e0e0;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-toggle:hover {
  background: #eeeeee;
  border-color: #bdbdbd;
}

.btn-toggle.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.btn-toggle.active:hover {
  background: #5568d3;
  border-color: #5568d3;
}

/* ========================================
   CARDS DE RESUMO
   ======================================== */
.quantidades-resumo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card-resumo {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-left: 4px solid #667eea;
  transition: transform 0.2s;
}

.card-resumo:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.card-resumo h3 {
  margin: 0 0 0.5rem 0;
  color: #666;
  font-size: 1rem;
  font-weight: 500;
}

.valor-grande {
  font-size: 2rem;
  font-weight: bold;
  color: #333;
  margin: 0.5rem 0;
}

.percentual {
  font-size: 0.9rem;
  color: #667eea;
  font-weight: 500;
}

/* ========================================
   CÉLULAS, ETAPAS E SUBETAPAS
   ======================================== */
.quantidades-celulas h3,
.quantidades-etapas h3,
.quantidades-subetapas h3 {
  margin: 0 0 1rem 0;
  color: #333;
  font-size: 1.3rem;
}

.lista-celulas,
.lista-etapas,
.lista-subetapas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

.card-celula,
.card-etapa,
.card-subetapa {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: all 0.3s;
}

.card-celula {
  border-left: 4px solid #667eea;
}

.card-celula:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  border-left-color: #764ba2;
}

.card-etapa {
  border-left: 4px solid #42a5f5;
}

.card-etapa:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  border-left-color: #1976d2;
}

.card-subetapa {
  border-left: 4px solid #66bb6a;
}

.card-subetapa:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  border-left-color: #388e3c;
}

.celula-nome,
.etapa-nome,
.subetapa-nome {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.75rem;
}

.celula-valores,
.etapa-valores,
.subetapa-valores {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
}

.valor-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.valor-item .label {
  color: #666;
  font-weight: 500;
}

.valor-item .valor {
  color: #333;
  font-weight: 600;
}

.valor-item .perc {
  color: #667eea;
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

/* ========================================
   BUSCA DE INSUMOS
   ======================================== */
.quantidades-busca {
  margin-bottom: 2rem;
}

.busca-container {
  position: relative;
  max-width: 600px;
}

.busca-container input[type="text"] {
  width: 100%;
  padding: 1rem 1.5rem;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.2s;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.busca-container input[type="text"]:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.resultados-busca {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #e0e0e0;
  border-top: none;
  border-radius: 0 0 12px 12px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  display: none;
}

.lista-selecao-insumos {
  padding: 0.5rem 0;
}

.selecao-header {
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-weight: 600;
  color: white !important;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

.item-selecao-insumo {
  padding: 1rem 1.5rem;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid #f0f0f0;
}

.item-selecao-insumo:hover {
  background: #f8f9fa;
}

.item-selecao-insumo:last-child {
  border-bottom: none;
}

.insumo-codigo {
  font-weight: 600;
  color: #667eea;
  margin-bottom: 0.25rem;
}

.insumo-desc {
  color: #333;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.insumo-unidade {
  color: #999;
  font-size: 0.85rem;
}

.sem-resultados {
  padding: 2rem 1.5rem;
  text-align: center;
  color: #999;
}

/* ========================================
   TABELA DE INSUMOS
   ======================================== */
.quantidades-insumos {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.quantidades-insumos h3 {
  margin: 0 0 1.5rem 0;
  color: #333;
  font-size: 1.3rem;
}

.tabela-insumos {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
}

.tabela-insumos tbody tr {
  transition: background 0.2s;
}

.tabela-insumos tbody tr:hover {
  background: #f8f9ff;
}

.tabela-insumos td {
  padding: 1rem;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
}

.tabela-insumos td strong {
  color: #667eea;
}

/* Tabela de busca */
.tabela-busca {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.tabela-busca tbody tr {
  transition: background 0.2s;
  cursor: pointer;
}

.tabela-busca tbody tr:hover {
  background: #f8f9ff;
}

.tabela-busca td {
  padding: 1rem;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
}

.tabela-busca td strong {
  color: #667eea;
}

/* ========================================
   BOTÕES
   ======================================== */
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #f8f9ff;
  border-color: #5568d3;
  color: #5568d3;
}

/* Botão de levantamentos */
.btn-levantamentos {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-levantamentos:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-levantamentos:active {
  transform: translateY(0);
}

/* ========================================
   MODAL DE SELEÇÃO DE INSUMOS
   ======================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.modal-seletor {
  background: white;
  border-radius: 16px;
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
}

.modal-header-seletor {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header-seletor h3 {
  margin: 0;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white !important;
}

.modal-icon {
  font-size: 1.8rem;
}

.btn-fechar-modal {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-fechar-modal:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.modal-body-seletor {
  padding: 2rem;
  overflow-y: auto;
  max-height: calc(80vh - 100px);
}

.info-text-seletor {
  background: #f0f9ff;
  border-left: 4px solid #3b82f6;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  color: #1e40af;
}

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

.card-insumo-seletor {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s;
}

.card-insumo-seletor:hover {
  border-color: #667eea;
  background: linear-gradient(135deg, #f0f4ff 0%, #ffffff 100%);
  transform: translateX(8px);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
}

.insumo-codigo-seletor {
  font-size: 1.1rem;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 0.5rem;
  font-family: 'Courier New', monospace;
}

.insumo-descricao-seletor {
  color: #333;
  font-size: 1rem;
  margin-bottom: 1rem;
  line-height: 1.4;
}

.insumo-detalhes-seletor {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.badge-unidade-seletor,
.badge-celula-seletor,
.badge-valores-seletor {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-unidade-seletor {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
}

.badge-celula-seletor {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
}

.badge-valores-seletor {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
}

/* ========================================
   BADGES DE PERCENTUAL - COLUNA LEVANTADO
   ======================================== */
.badge-percentual {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s;
}

.badge-percentual:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.badge-percentual.baixo {
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  color: #c62828;
  border: 1px solid #ef5350;
}

.badge-percentual.medio {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  color: #e65100;
  border: 1px solid #fb8c00;
}

.badge-percentual.alto {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  color: #2e7d32;
  border: 1px solid #66bb6a;
}

.badge-percentual.completo {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  color: #1565c0;
  border: 1px solid #42a5f5;
}

/* Coluna Levantado com destaque */
.col-levantado {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  font-weight: 700;
  color: #667eea;
  border-left: 3px solid #667eea;
  border-right: 3px solid #667eea;
}

/* ========================================
   ESTILOS PARA CÓDIGO E NOME
   ======================================== */
.ctx-code {
  font-weight: 600;
  color: #667eea;
  font-family: 'Courier New', monospace;
}

.ctx-sep {
  color: #999;
  margin: 0 0.3rem;
}

.ctx-nome {
  color: #666;
  font-weight: 400;
}

/* ========================================
   LOADING E NOTIFICAÇÕES
   ======================================== */
.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.mensagem-vazia {
  text-align: center;
  padding: 4rem 2rem;
  color: #999;
  font-size: 1.1rem;
}

.mensagem-importacao {
  text-align: center;
  padding: 4rem 2rem;
}

/* ========================================
   ANIMAÇÕES
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* ========================================
   SCROLLBAR CUSTOMIZADA
   ======================================== */
.modal-body-seletor::-webkit-scrollbar {
  width: 8px;
}

.modal-body-seletor::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.modal-body-seletor::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 4px;
}

.modal-body-seletor::-webkit-scrollbar-thumb:hover {
  background: #5568d3;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .quantidades-header,
  .levantamentos-header {
    padding: 1.5rem;
  }

  .obra-info {
    flex-direction: column;
    gap: 0.5rem;
  }

  .quantidades-resumo {
    grid-template-columns: 1fr;
  }

  .lista-celulas,
  .lista-etapas,
  .lista-subetapas {
    grid-template-columns: 1fr;
  }

  .busca-container {
    max-width: 100%;
  }

  .tabela-insumos,
  .tabela-busca {
    font-size: 0.85rem;
  }

  .tabela-insumos th,
  .tabela-insumos td,
  .tabela-busca th,
  .tabela-busca td {
    padding: 0.75rem 0.5rem;
  }

  .modal-seletor {
    width: 95%;
    max-height: 90vh;
  }

  .modal-header-seletor {
    padding: 1rem 1.5rem;
  }

  .modal-body-seletor {
    padding: 1.5rem;
  }

  .card-insumo-seletor:hover {
    transform: translateX(4px);
  }

  .header-acoes {
    flex-direction: column !important;
  }

  .header-acoes button {
    width: 100%;
  }
}

/* ========================================
   UTILITÁRIOS
   ======================================== */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}
