/* ====== Base / Estabilidade ====== */
html {
  /* mantém a área do scroll estável (evita “pulo” quando a barra surge some) */
  scrollbar-gutter: stable both-edges;
}

body {
  background-color: #f8f9fa;
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  /* evita “sacolejo” lateral causado por .row com margens negativas */
  overflow-x: hidden;
}

/* ====== Header ====== */
.header {
  background: #fff;
  border-bottom: 1px solid #dee2e6;
  padding: 15px 0;
  margin-bottom: 20px;
}

h1 {
  font-size: 1.6rem;
  margin: 0;
  font-weight: 600;
}

/* ====== Busca e Filtros ====== */
.search-container {
  margin: 20px 0;
  padding: 0; /* Deixe o espaçamento para o grid do Bootstrap */
}
.input-group .form-control { border-radius: 6px 0 0 6px; }
.input-group .btn { border-radius: 0 6px 6px 0; }
#btnAddInsumo { margin-left: 10px; }

/* ====== Tabela / Estabilidade visual ====== */
.table-container {
  margin-top: 10px;
  background: #fff;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* Evita recalcular layout conforme conteúdo carrega */
.table {
  width: 100%;
  table-layout: fixed;
}
.table th, .table td {
  vertical-align: middle;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table th {
  background-color: #f1f3f5;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: #495057;
}

/* Larguras fixas de colunas mais críticas */
.img-col { width: 80px; text-align: center; }
.und-col { width: 80px; text-align: center; }

.product-img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #dee2e6;
}

/* ====== Ações ====== */
.btn-edit {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  transition: color 0.2s ease;
  padding: 4px;
  font-size: 1rem;
}
.btn-edit:hover { color: #212529; }

/* ====== Badges ====== */
.retornavel-true .badge { background-color: #28a745 !important; }
.retornavel-false .badge { background-color: #6c757d !important; }

/* ====== Loading / Erro ====== */
.loading-row td { text-align: center; padding: 30px 0; color: #6c757d; }
.spinner-border { width: 2rem; height: 2rem; }
.error-message { text-align: center; color: #dc3545; padding: 15px 0; font-weight: 500; }

/* ====== Modal ====== */
.modal-content {
  border-radius: 8px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background-color: #fff;
}
.modal-header { border-bottom: 1px solid #dee2e6; padding: 1rem 1.2rem; }
.modal-footer { border-top: 1px solid #dee2e6; padding: 0.8rem 1.2rem; }
.modal-title { font-size: 1.3rem; font-weight: 600; color: #212529; }
.modal-body { padding: 1.2rem; }

.modal-body .form-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: #495057;
}
.modal-body .form-control,
.modal-body .form-select {
  border-radius: 6px;
  border: 1px solid #ced4da;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.modal-body .form-control:focus,
.modal-body .form-select:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
  outline: none;
}

/* Preview da imagem */
#imagePreview {
  display: block;
  max-width: 150px;
  height: auto;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  margin-top: 10px;
}

/* ====== Responsividade ====== */
@media (max-width: 768px) {
  h1 { font-size: 1.3rem; }
  .table-container { padding: 10px; }
  .product-img { width: 40px; height: 40px; }
  .modal-dialog { max-width: 95%; margin: 10px auto; }
  .modal-body .row { flex-direction: column; }
  .modal-body .col-md-6 { width: 100%; }
}
/* Neutraliza margens negativas da .row do Bootstrap fora de container */
.row { margin-left: 0; margin-right: 0; }

/* Célula e contêiner fixos pra não “fecharem” mesmo se a imagem falhar */
.img-col { width: 80px; text-align: center; }
.td-img { width: 80px; }
.img-wrap {
  width: 60px;
  height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  background: #f8f9fa; /* “placeholder” visual */
  overflow: hidden;
}

/* A imagem nunca ultrapassa o contêiner */
.img-wrap img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: cover;
}


/* --- Ajuste de Colunas da Tabela --- */

/* Coluna Código: Fica bem estreita, apenas para os números */
.col-codigo {
    width: 10%; 
    white-space: nowrap;
    text-align: center; /* Opcional: centraliza o código */
    padding-left: 15px !important;
    padding-right: 15px !important;
}

/* Coluna Item: Força a ocupar espaço e não espremer o texto */
.col-item {
    width: auto; /* Ocupa o resto do espaço */
    min-width: 350px; /* Garante que nunca fique muito pequena */
}
/* 1. Ajuste do Cabeçalho (TH) */
.col-codigo {
    width: 10%; /* Ajustado para 10% conforme você pediu */
    white-space: nowrap;
    text-align: center;
    padding-left: 5px !important;
    padding-right: 5px !important;
}

/* 2. Ajuste dos DADOS (TD) - Sem mexer no JS */
/* O seletor abaixo pega apenas a 2ª coluna de cada linha do corpo da tabela */
#insumosTable tr td:nth-child(2) {
    text-align: center;
    vertical-align: middle;
}
/* --- Larguras das Colunas --- */

/* Material: 15% */
.col-material {
    width: 15% !important;
}

/* Estoque Mínimo: 10% */
.col-estoque {
    width: 8% !important;
    text-align: center !important; /* Recomendado centralizar */
}

/* Retornável: 15% */
.col-retornavel {
    width: 8% !important;
    text-align: center !important; /* Recomendado centralizar */
}

.und-col {
    width: 5% !important;
}