/* =========================================================
   RECEBIMENTO DE AMOSTRAS
   ========================================================= */

/* Filtros */

.samples-toolbar {
  grid-template-columns:
    minmax(230px, 1.2fr)
    150px
    165px
    165px
    190px
    auto;
  align-items: end;
}

.samples-toolbar input,
.samples-toolbar select {
  height: 48px;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
}

.samples-toolbar input::placeholder {
  color: #512878;
  font-size: 16px;
}

.samples-toolbar .search-box {
  height: 48px;
}

.samples-toolbar .search-box input {
  height: 100%;
}

.samples-toolbar .search-box span {
  width: 22px;
  font-size: 18px;
}

.date-filter {
  display: grid;
  gap: 5px;
  color: var(--muted);
}

.date-filter > span {
  color: #512878;
  font-size: 12px;
  font-weight: 600;
}

.date-filter input {
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}

/* Tabela */

.samples-table {
  min-width: 1370px;
}

.c-id-recebimento { width: 8%; }

.c-reg {
  width: 7%;
}

.c-farm {
  width: 21%;
}

.c-origin {
  width: 10%;
}

.c-date {
  width: 10%;
}

.c-type {
  width: 13%;
}

.c-qty {
  width: 7%;
}

.c-actions {
  width: 8%;
}

.sample-farm {
  display: flex;
  align-items: center;
  gap: 11px;
}

.sample-farm-code {
  width: 43px;
  height: 43px;
  border: 1px solid #DED3E5;
  border-radius: 13px;
  background: linear-gradient(145deg, #F2EDF6, #F9F7FA);
  color: var(--blue-900);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.sample-farm strong,
.sample-farm small {
  display: block;
}

.sample-farm small {
  margin-top: 4px;
  color: var(--muted);
}

.origin-badge,
.sample-type-badge,
.register-badge {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.origin-badge {
  background: #F2EDF6;
  color: #411A5F;
}

.sample-type-badge {
  background: #F9F7FA;
  color: #6545A7;
}

.register-badge {
  background: #F2EDF6;
  color: #411A5F;
}

.pending-value {
  color: #43ADBC;
  font-size: 12px;
}

/* Estado vazio */

.empty-state[hidden] {
  display: none !important;
}

.empty-state {
  min-height: 420px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}

.empty-state-image {
  width: 230px;
  max-width: 80%;
  opacity: .96;
  user-select: none;
  pointer-events: none;
}

.empty-state h3 {
  margin: 0;
  color: #3A1453;
  font-size: 26px;
  font-weight: 750;
}

.empty-state p {
  max-width: 430px;
  margin: 0;
  color: #512878;
  font-size: 16px;
  line-height: 1.5;
}

/* Modal */

.sample-modal-card {
  width: min(970px, 96vw);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
}

.sample-modal-card form {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sample-modal-card .modal-body {
  min-height: 0;
}

.sample-form-grid {
  align-items: start;
}

.notes-control {
  min-height: 105px;
  resize: vertical;
}

.nested-modal {
  z-index: 120;
  background: rgba(42,13,69, .62);
}

.quick-farm-card {
  width: min(820px, 96vw);
}

.code-control {
  background: #F9F7FA;
  color: var(--blue-900);
  font-weight: 800;
  letter-spacing: .1em;
}

.form-message.success {
  color: #087448;
}

/* Garante que os dropdowns possam sobrepor as linhas seguintes */
.sample-modal-card,
.sample-modal-card form,
.sample-modal-card .modal-body,
.sample-form-grid {
  position: relative;
}

.sample-form-grid {
  overflow: visible;
}

.sample-form-grid > .field {
  position: relative;
  z-index: 1;
}

/* O campo que possui uma lista aberta sobe acima dos demais campos do grid. */
.sample-form-grid > .field:has(.lookup-control.open) {
  z-index: 1000;
}

/* =========================================================
   LOOKUPS PERSONALIZADOS
   ========================================================= */

.lookup-control {
  position: relative;
  width: 100%;
  min-width: 0;
  z-index: 1;
}

.lookup-control.open {
  z-index: 1001;
}

.lookup-input {
  width: 100%;
  height: 48px;
  padding: 0 76px 0 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  outline: none;
  transition:
    border-color .18s ease,
    box-shadow .18s ease,
    border-radius .18s ease;
}

.lookup-input::placeholder {
  color: #43ADBC;
  font-size: 16px;
  font-weight: 400;
}

.lookup-input:focus,
.lookup-control.open .lookup-input {
  border-color: #512878;
  box-shadow:
    0 0 0 4px rgba(81,40,120, .11),
    0 8px 20px rgba(65,26,95, .06);
}

.lookup-control.open .lookup-input {
  border-bottom-left-radius: 9px;
  border-bottom-right-radius: 9px;
}

.lookup-clear,
.lookup-toggle {
  position: absolute;
  top: 50%;
  z-index: 5;
  padding: 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transform: translateY(-50%);
}

.lookup-clear {
  right: 41px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #512878;
  display: none;
  font: 20px/1 Arial, sans-serif;
  transition:
    background .16s ease,
    color .16s ease;
}

.lookup-control.has-value .lookup-clear {
  display: grid;
}

.lookup-clear:hover {
  background: #F2EDF6;
  color: #411A5F;
}

.lookup-toggle {
  right: 5px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: #3A1453;
  font-size: 11px;
  transition:
    background .16s ease,
    transform .18s ease;
}

.lookup-toggle:hover {
  background: #F9F7FA;
}

.lookup-control.open .lookup-toggle {
  transform: translateY(-50%) rotate(180deg);
}

.lookup-results {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 1002;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  max-height: 245px;
  padding: 7px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(81,40,120, .24);
  border-radius: 12px 12px 16px 16px;
  background: rgba(255,255,255, .985);
  box-shadow:
    0 14px 30px rgba(58,20,83, .14),
    0 0 0 3px rgba(81,40,120, .04);
  backdrop-filter: blur(12px);
}

.lookup-results[hidden] {
  display: none !important;
}

.lookup-results::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(81,40,120, .46),
    transparent
  );
}

.lookup-result-item {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #3A1453;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background .15s ease,
    color .15s ease,
    transform .15s ease;
}

.lookup-result-item:hover,
.lookup-result-item.active {
  background: linear-gradient(90deg, #F9F7FA, #F9F7FA);
  color: #411A5F;
  transform: translateX(2px);
}

.lookup-result-code {
  min-width: 42px;
  padding: 5px 7px;
  border-radius: 8px;
  background: #F2EDF6;
  color: #411A5F;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}

.lookup-result-content {
  min-width: 0;
  flex: 1;
}

.lookup-result-title,
.lookup-result-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lookup-result-title {
  font-size: 14px;
  font-weight: 700;
}

.lookup-result-subtitle {
  margin-top: 3px;
  color: #512878;
  font-size: 12px;
  font-weight: 400;
}

.lookup-no-result {
  min-height: 65px;
  padding: 16px;
  color: #512878;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
}

.lookup-results::-webkit-scrollbar {
  width: 7px;
}

.lookup-results::-webkit-scrollbar-track {
  background: transparent;
}

.lookup-results::-webkit-scrollbar-thumb {
  border: 2px solid #fff;
  border-radius: 999px;
  background: #DED3E5;
}

.lookup-results::-webkit-scrollbar-thumb:hover {
  background: #B5A8B9;
}

.farm-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.farm-picker-row .quick-add-btn {
  min-height: 48px;
  white-space: nowrap;
}

/* Responsividade */

@media (max-width: 1300px) {
  .samples-toolbar {
    grid-template-columns:
      1fr
      150px
      160px
      160px
      180px
      auto;
  }
}

@media (max-width: 1050px) {
  .samples-toolbar {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .samples-toolbar .search-box:first-child {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .farm-picker-row {
    grid-template-columns: 1fr;
  }

  .farm-picker-row .quick-add-btn {
    width: 100%;
  }
}


/* =========================================================
   ROLAGEM HORIZONTAL DA TABELA DE AMOSTRAS
   Barra inferior visível e cabeçalho sincronizado.
   ========================================================= */
#tableBodyViewport {
  overflow-x: auto !important;
  overflow-y: auto !important;
  scrollbar-width: auto;
  scrollbar-gutter: stable;
}

#tableBodyViewport::-webkit-scrollbar {
  height: 12px;
  width: 10px;
}

#tableBodyViewport::-webkit-scrollbar-track {
  background: #F6E8EB;
}

#tableBodyViewport::-webkit-scrollbar-thumb {
  background: #512878;
  border: 2px solid #F6E8EB;
  border-radius: 999px;
}

#tableBodyViewport::-webkit-scrollbar-thumb:hover {
  background: #411A5F;
}

#tableHeadViewport {
  overflow: hidden !important;
}


/* Pré-cadastros enviados pelo aplicativo do consultor */
.samples-heading-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.pre-registration-badge{min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:#D73F38;color:#fff;display:inline-grid;place-items:center;font-size:.7rem;font-weight:900}.pre-registration-modal-card{width:min(980px,calc(100vw - 30px));max-height:calc(100vh - 30px);display:grid;grid-template-rows:auto minmax(0,1fr)}.pre-registration-modal-card .modal-body{overflow:auto}.pre-registration-list{display:grid;gap:12px}.pre-registration-item{border:1px solid #DED3E5;border-radius:14px;background:#fff;padding:14px;display:grid;grid-template-columns:110px minmax(0,1fr) auto;gap:14px;align-items:center}.pre-registration-photo{width:110px;height:82px;object-fit:cover;border-radius:10px;background:#F2EDF6;border:1px solid #DED3E5}.pre-registration-photo.placeholder{display:grid;place-items:center;color:#512878;font-size:.72rem;text-align:center}.pre-registration-info strong,.pre-registration-info small{display:block}.pre-registration-info strong{color:#3A1453}.pre-registration-info small{margin-top:4px;color:#512878}.pre-registration-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}@media(max-width:760px){.pre-registration-item{grid-template-columns:82px minmax(0,1fr)}.pre-registration-photo{width:82px;height:70px}.pre-registration-actions{grid-column:1/-1;justify-content:stretch}.pre-registration-actions .btn{flex:1}}


/* Visualização ampliada da foto do pré-cadastro */
.sample-photo-viewer[hidden]{display:none!important}
.sample-photo-viewer{position:fixed;inset:0;z-index:9999;background:rgba(42,13,69,.86);backdrop-filter:blur(4px);display:grid;place-items:center;padding:18px}
.sample-photo-viewer__panel{width:min(1180px,calc(100vw - 36px));height:min(90vh,900px);background:#fff;border-radius:20px;overflow:hidden;box-shadow:0 28px 80px rgba(0,0,0,.35);display:grid;grid-template-rows:auto minmax(0,1fr)}
.sample-photo-viewer__header{min-height:72px;padding:14px 16px 14px 20px;display:flex;align-items:center;justify-content:space-between;gap:16px;border-bottom:1px solid #F2EDF6;background:#fff}
.sample-photo-viewer__header strong,.sample-photo-viewer__header small{display:block}
.sample-photo-viewer__header strong{font-size:1.02rem;color:#3A1453}
.sample-photo-viewer__header small{margin-top:3px;color:#512878;font-size:.78rem}
.sample-photo-viewer__close{width:44px;height:44px;flex:0 0 44px;border:0;border-radius:12px;background:#F2EDF6;color:#3A1453;font-size:2rem;line-height:1;cursor:pointer;display:grid;place-items:center;transition:.18s ease}
.sample-photo-viewer__close:hover{background:#F2EDF6;transform:scale(1.03)}
.sample-photo-viewer__body{min-height:0;background:#2A0D45;display:flex;align-items:center;justify-content:center;padding:12px;overflow:auto}
.sample-photo-viewer__body img{display:block;max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;border-radius:8px;box-shadow:0 10px 30px rgba(0,0,0,.28)}
body.sample-photo-viewer-open{overflow:hidden}
@media(max-width:760px){.sample-photo-viewer{padding:8px}.sample-photo-viewer__panel{width:calc(100vw - 16px);height:calc(100dvh - 16px);border-radius:15px}.sample-photo-viewer__header{min-height:64px;padding:10px 10px 10px 14px}.sample-photo-viewer__header small{display:none}.sample-photo-viewer__close{width:42px;height:42px;flex-basis:42px}.sample-photo-viewer__body{padding:8px}}

.receipt-id-badge{display:inline-flex;align-items:center;justify-content:center;min-width:64px;padding:6px 9px;border-radius:10px;background:#F9F7FA;color:#411A5F;font-weight:900;font-size:.82rem;border:1px solid #DED3E5}

/* =========================================================
   CADASTROS PARCIAIS DE FAZENDA
   ========================================================= */
.partial-farms-button{position:relative;display:inline-flex;align-items:center;gap:8px;}
.partial-farms-icon{display:inline-grid;place-items:center;width:22px;height:22px;border-radius:50%;background:#fff3d6;color:#8a6300;font-weight:900;border:1px solid #efd28a;}
.partial-farms-modal-card{width:min(780px,calc(100vw - 30px));}
.partial-farms-list{display:grid;gap:10px;}
.partial-farm-row{width:100%;display:grid;grid-template-columns:minmax(0,1fr) 170px 120px;align-items:center;gap:14px;padding:14px 15px;border:1px solid #ded3e5;border-radius:13px;background:#fff;text-align:left;cursor:pointer;color:#3a1453;transition:.18s ease;}
.partial-farm-row:hover{border-color:#8f6aa9;box-shadow:0 8px 22px rgba(66,20,95,.09);transform:translateY(-1px);}
.partial-farm-row:disabled{cursor:default;opacity:.7;transform:none;box-shadow:none;}
.partial-farm-main{min-width:0;display:grid;gap:4px;}
.partial-farm-main strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.partial-farm-main small{color:#705e7b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.partial-farm-phone{font-weight:800;color:#512878;}
.partial-farm-action{text-align:right;font-weight:850;color:#42145f;}
.complete-farm-modal-card{width:min(820px,calc(100vw - 30px));}
@media(max-width:700px){.partial-farm-row{grid-template-columns:1fr}.partial-farm-action{text-align:left}.partial-farm-phone{font-size:.88rem}}
