/* ══════════════════════════════════════════════════════════
   ALINT ERP — CRUD
   alint-crud.css
   Depende de: alint-tokens.css, alint-components.css
   ══════════════════════════════════════════════════════════ */

/* ── Container ─────────────────────────────────────────────── */
.crud-container { padding: 24px; }

/* ── CrudToolbar — componente principal ────────────────────── */
.crud-toolbar {
  display: flex; align-items: center; gap: 8px;      /* era gap:10px */
  margin-bottom: 16px;
  flex-wrap: nowrap;                                  /* NUNCA quebra linha */
  overflow-x: auto;                                   /* scroll se necessário */
  scrollbar-width: none;
}
.crud-toolbar::-webkit-scrollbar { display: none; }

/* ── Busca ─────────────────────────────────────────────────── */
.crud-search {
  flex: 1; min-width: 160px; max-width: 300px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 0 12px;
  height: 32px;                                       /* era 36px */
  transition: border-color .2s, box-shadow .2s;
}
.crud-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.crud-search i     { color: var(--text-3); font-size: 13px; flex-shrink: 0; }
.crud-search input {
  border: none; background: none; outline: none;
  font-family: var(--font-body); font-size: 13px;
  color: var(--text); width: 100%;
}
.crud-search input::placeholder { color: var(--text-3); }

/* ── Filtros ───────────────────────────────────────────────── */
.crud-filters { display: flex; gap: 8px; flex-shrink: 0; }
.crud-filters select {
  height: 32px;                                       /* era 36px */
  padding: 0 28px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2);
  font-family: var(--font-body); font-size: 12px; font-weight: 500;
  cursor: pointer; outline: none; white-space: nowrap; flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2394A3B8' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  -webkit-appearance: none; transition: border-color .15s;
}
.crud-filters select:focus { border-color: var(--primary); }

/* ── Ações (lado direito) ──────────────────────────────────── */
.crud-toolbar-actions {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}

/* ── Botões da toolbar compactos ───────────────────────────── */
/* Todos os .btn dentro de .crud-toolbar ficam menores */
.crud-toolbar .btn,
.crud-toolbar .toolbar-btn {
  height: 32px;                                       /* era 36px */
  padding: 0 12px;
  font-size: 12.5px;
}
.crud-toolbar .btn.btn-icon,
.crud-toolbar .toolbar-btn.icon-only {
  width: 32px; padding: 0;
}

/* ── Buscar inline (wrapper CNPJ / CEP) ────────────────────── */
/*
   EmpresaCRUD e AlintCnpj criam um wrapper div com
   display:flex para colocar input + botão lado a lado.
   Garante alinhamento correto em qualquer contexto.
*/
.input-buscar-wrap {
  display: flex; align-items: center; gap: 8px;
}
.input-buscar-wrap .form-control { flex: 1; }
.input-buscar-wrap .btn           { flex-shrink: 0; white-space: nowrap; }

/* Wrapper criado inline pelo JS (sem classe) — cobre o caso atual */
.form-group > div[style*="display:flex"] {
  align-items: center;
}
.form-group > div[style*="display:flex"] .btn {
  align-self: auto;        /* cancela qualquer stretch herdado */
  flex-shrink: 0;
  white-space: nowrap;
  height: 38px;            /* mesma altura do form-control */
}

/* ── Tabela ─────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: auto;
}
.crud-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.crud-table thead { background: var(--surface-2); }
.crud-table th {
  padding: 10px 16px;                                 /* era 11px — 1px a menos */
  text-align: left;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3); border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
.crud-table th.sortable { cursor: pointer; transition: color .15s; }
.crud-table th.sortable:hover { color: var(--text); }
.crud-table th.sorted { color: var(--primary); }
.crud-table th .sort-icon { margin-left: 4px; font-size: 10px; }

.crud-table td {
  padding: 11px 16px;                                 /* era 12px — 1px a menos */
  border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.crud-table tbody tr:last-child td { border-bottom: none; }
.crud-table tbody tr:hover { background: var(--bg-2); }

/* Coluna de ações */
.crud-table .col-actions { width: 80px; text-align: right; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .crud-container { padding: 12px; }

  /* Toolbar: linha única com scroll, nunca quebra */
  .crud-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    margin-bottom: 10px;
    padding-bottom: 2px; /* evita cortar box-shadow do focus */
  }

  /* Busca no mobile: menor, não expande tanto */
  .crud-search {
    min-width: 120px;
    max-width: 180px;
    height: 32px;
  }

  /* Filtros: menores */
  .crud-filters select { height: 32px; font-size: 11px; padding: 0 22px 0 8px; }

  /* Botões: só ícone no mobile */
  .crud-toolbar .btn span,
  .crud-toolbar .toolbar-btn span { display: none; }
  .crud-toolbar .btn,
  .crud-toolbar .toolbar-btn {
    width: 32px; height: 32px;
    padding: 0; justify-content: center;
    flex-shrink: 0;
  }
  /* Botão Novo (primary) mantém ícone + nada de texto mas fica visível */
  .crud-toolbar .btn.btn-primary { width: 32px; }

  /* Tabela menor */
  .table-wrap  { font-size: 12px; }
  .crud-table td,
  .crud-table th { padding: 9px 10px; }

  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 400px) {
  .crud-search { min-width: 100px; max-width: 140px; }
}