﻿/* =========================================================================
   MODAIS.CSS
   Configuração dos modais Bootstrap pelas variáveis --bs-modal-* (DS 5.8)
   + o que é específico de cada modal. Botões, campos, alertas e badges
   dentro de modais herdam de main.css / forms.css.
   ========================================================================= */

/* 1. Base: vale para todo .modal -------------------------------------- */

.modal {
  --bs-modal-bg: var(--rb-surface);
  --bs-modal-color: var(--rb-text);
  --bs-modal-border-width: 1px;
  --bs-modal-border-color: var(--rb-border);
  --bs-modal-border-radius: var(--rb-radius-lg);
  --bs-modal-inner-border-radius: calc(var(--rb-radius-lg) - 1px);
  --bs-modal-box-shadow: var(--rb-shadow-lg);
  --bs-modal-header-border-color: var(--rb-border);
  --bs-modal-header-padding: var(--rb-space-4) var(--rb-space-5);
  --bs-modal-padding: var(--rb-space-5);
  --bs-modal-footer-bg: var(--rb-surface-2);
  --bs-modal-footer-border-color: var(--rb-border);
  --bs-modal-footer-gap: var(--rb-space-2);
  --bs-modal-title-line-height: var(--rb-lh-tight);
  /* acima do calculador flutuante (2050) e dos widgets da página */
  --bs-modal-zindex: 2060;
}

.modal-backdrop {
  --bs-backdrop-bg: var(--rb-overlay);
  --bs-backdrop-opacity: 1;
  --bs-backdrop-zindex: 2055;
}

.modal-title {
  margin: 0;
  font-size: var(--rb-fs-md);
  font-weight: var(--rb-fw-semibold);
  color: var(--rb-text);
}

.modal-footer {
  padding: var(--rb-space-3) var(--rb-space-5);
}

/* Animação de abrir/fechar: a padrão do Bootstrap (fade + deslize de 50px,
   .3s), igual ao Reprobank. Não sobrescrever .modal-dialog aqui. */

@media (max-width: 575.98px) {
  .modal {
    --bs-modal-header-padding: var(--rb-space-3) var(--rb-space-4);
    --bs-modal-padding: var(--rb-space-4);
  }
  .modal-footer { padding: var(--rb-space-3) var(--rb-space-4); }
}

/* 2. Tabelas dentro de modais ----------------------------------------- */

:is(#modalLaudosLote, #modalImportacaoMassaReprodutores, #modalPosCqAcoes) .table-responsive {
  overflow: auto;
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius);
}

:is(#modalLaudosLote, #modalImportacaoMassaReprodutores, #modalPosCqAcoes) .table {
  margin-bottom: 0;
}

:is(#modalLaudosLote, #modalImportacaoMassaReprodutores, #modalPosCqAcoes) .table thead th {
  background: var(--rb-surface-2);
  border-bottom: 1px solid var(--rb-border);
  font-size: var(--rb-fs-xs);
  font-weight: var(--rb-fw-semibold);
  letter-spacing: .02em;
  color: var(--rb-text-muted);
  white-space: nowrap;
}

#modalPosCqAcoes .table tfoot td {
  background: var(--rb-surface-2);
  border-top: 1px solid var(--rb-border-strong);
}

#modalPosCqAcoes .card {
  --bs-card-bg: var(--rb-surface-2);
  --bs-card-border-color: var(--rb-border);
  --bs-card-border-radius: var(--rb-radius);
}

#modalPosCqAcoes .fw-semibold.small i.bi {
  color: var(--rb-primary);
}

/* 3. Excluir documento: nome copiável --------------------------------- */

#modalExcluirDocumento .doc-confirm-nome-row {
  display: flex;
  align-items: center;
  gap: var(--rb-space-2);
}

#modalExcluirDocumento .doc-confirm-nome {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--rb-space-2) var(--rb-space-3);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius);
  background: var(--rb-surface-2);
  color: var(--rb-text-muted);
  font-family: var(--rb-font-mono);
  font-size: var(--rb-fs-sm);
  word-break: break-word;
}

#modalExcluirDocumento #btnCopiarNomeDocumentoExcluir {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

/* 4. Menu de QR codes (coleta) ---------------------------------------- */

#qrMenuModal .qr-card {
  height: 100%;
  padding: var(--rb-space-3);
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius-lg);
  cursor: pointer;
  transition: background-color var(--rb-dur) var(--rb-ease),
              border-color var(--rb-dur) var(--rb-ease);
}

#qrMenuModal .qr-card:hover {
  background: var(--rb-surface-2);
  border-color: var(--rb-primary);
}

#qrMenuModal .qr-title {
  margin-bottom: var(--rb-space-1);
  font-size: var(--rb-fs-base);
  font-weight: var(--rb-fw-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#qrMenuModal .qr-command {
  margin-top: var(--rb-space-1);
  font-family: var(--rb-font-mono);
  font-size: var(--rb-fs-sm);
  color: var(--rb-text-muted);
  user-select: all;
}

#qrMenuModal .qr-canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 132px;
}

/* 5. Downloads / Documentos: cartões de ação -------------------------- */

.docs-modal-action {
  display: flex;
  align-items: center;
  gap: var(--rb-space-3);
  width: 100%;
  padding: var(--rb-space-3) var(--rb-space-4);
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius);
  color: var(--rb-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--rb-dur) var(--rb-ease),
              border-color var(--rb-dur) var(--rb-ease);
}

.docs-modal-action:hover {
  background: var(--rb-surface-2);
  border-color: var(--rb-primary);
  color: var(--rb-text);
  text-decoration: none;
}

.docs-modal-action-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--rb-primary-subtle);
  border: 1px solid var(--rb-primary-border);
  border-radius: var(--rb-radius);
  font-size: var(--rb-fs-lg);
  color: var(--rb-primary);
}

.docs-modal-action-icon.is-download {
  background: var(--rb-success-subtle);
  border-color: var(--rb-success-border);
  color: var(--rb-success-text);
}

.docs-modal-action-text {
  flex: 1;
  min-width: 0;
}

.docs-modal-action-text strong {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-size: var(--rb-fs-base);
  font-weight: var(--rb-fw-semibold);
}

.docs-modal-action-text span {
  display: block;
  font-size: var(--rb-fs-sm);
  line-height: 1.35;
  color: var(--rb-text-muted);
}

.docs-modal-action-arrow {
  flex-shrink: 0;
  font-size: var(--rb-fs-xs);
  color: var(--rb-text-subtle);
  transition: color var(--rb-dur) var(--rb-ease), transform var(--rb-dur) var(--rb-ease);
}

.docs-modal-action:hover .docs-modal-action-arrow {
  color: var(--rb-primary);
  transform: translateX(2px);
}

.docs-modal-divider {
  margin: var(--rb-space-1) 0;
  border-color: var(--rb-border);
}

.docs-modal-action-disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.coletor-ver-tag {
  flex-shrink: 0;
  padding: 1px 6px;
  background: var(--rb-primary-subtle);
  border: 1px solid var(--rb-primary-border);
  border-radius: var(--rb-radius-sm);
  font-family: var(--rb-font-mono);
  font-size: var(--rb-fs-xs);
  font-weight: var(--rb-fw-medium);
  color: var(--rb-primary-subtle-text);
}

/* 6. Escolher rack (congelação) --------------------------------------- */

#modalEscolherRack .rack-option-btn {
  --bs-btn-color: var(--rb-text);
  --bs-btn-bg: var(--rb-surface);
  --bs-btn-border-color: var(--rb-border-strong);
  --bs-btn-hover-color: var(--rb-text);
  --bs-btn-hover-bg: var(--rb-surface-2);
  --bs-btn-hover-border-color: var(--rb-primary);
  --bs-btn-active-color: var(--rb-text);
  --bs-btn-active-bg: var(--rb-surface-2);
  --bs-btn-active-border-color: var(--rb-primary);
  display: block;
  width: 100%;
  height: auto;
  padding: var(--rb-space-3) var(--rb-space-4);
  text-align: left;
  white-space: normal;
}

#modalEscolherRack .rack-option-btn .text-body-secondary {
  font-size: var(--rb-fs-sm);
}

/* 7. Atlas morfológico: placa + texto --------------------------------- */

#atlasModal .atlas-side {
  flex-shrink: 0;
  width: 220px;
  padding: var(--rb-space-4);
  background: var(--rb-surface-2);
  border-right: 1px solid var(--rb-border);
}

#atlasModal .atlas-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--rb-space-3);
  padding: var(--rb-space-5) var(--rb-space-4);
  overflow-y: auto;
}

/* o corpo recebe flex-direction:row por style="" no template */
@media (max-width: 767.98px) {
  #atlasModal .modal-body {
    flex-direction: column !important;
    overflow-y: auto !important;
  }
  #atlasModal .atlas-side {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--rb-border);
  }
}

/* 8. Análise Casa CQ: referência e linhas aprovadas/reprovadas -------- */

#modalCasaCQ .casa-ref-chip {
  display: inline-block;
  margin-top: var(--rb-space-1);
  padding: 1px 6px;
  background: var(--rb-primary-subtle);
  border: 1px solid var(--rb-primary-border);
  border-radius: var(--rb-radius-sm);
  font-size: var(--rb-fs-xs);
  color: var(--rb-primary-subtle-text);
}

#modalCasaCQ .casa-calc-row.casa-row-ok,
#modalCasaCQ .casa-calc-row.casa-row-fail {
  border-radius: var(--rb-radius);
  transition: background-color var(--rb-dur) var(--rb-ease);
}

#modalCasaCQ .casa-calc-row.casa-row-ok {
  background: var(--rb-success-subtle);
}
#modalCasaCQ .casa-calc-row.casa-row-ok .casa-calc-nome {
  color: var(--rb-success-text);
}

#modalCasaCQ .casa-calc-row.casa-row-fail {
  background: var(--rb-danger-subtle);
}
#modalCasaCQ .casa-calc-row.casa-row-fail .casa-calc-nome {
  color: var(--rb-danger-text);
  text-decoration: line-through;
}

/* 9. Movimento reduzido ------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .modal.fade .modal-dialog,
  .modal-backdrop,
  .docs-modal-action,
  .docs-modal-action-arrow,
  #qrMenuModal .qr-card,
  #modalCasaCQ .casa-calc-row {
    transition: none !important;
    animation: none !important;
  }
  .docs-modal-action:hover .docs-modal-action-arrow { transform: none; }
}

/* ─── Busca global (Ctrl+K) ──────────────────────────────────────────────── */

#modalBuscaGlobal .busca-dialog {
  max-width: 640px;
  margin-top: 10vh;
}
#modalBuscaGlobal .modal-content { overflow: hidden; }

.busca-campo {
  display: flex;
  align-items: center;
  gap: var(--rb-space-3);
  padding: var(--rb-space-3) var(--rb-space-4);
  border-bottom: 1px solid var(--rb-border);
}
.busca-campo > .bi { font-size: var(--rb-fs-lg); color: var(--rb-text-muted); }

.busca-input {
  flex: 1;
  min-width: 0;
  padding: var(--rb-space-2) 0;
  font-family: inherit;
  font-size: var(--rb-fs-lg);
  color: var(--rb-text);
  background: transparent;
  border: 0;
  outline: 0;
}
.busca-input::placeholder { color: var(--rb-text-subtle); }

.busca-kbd,
.busca-rodape kbd {
  padding: 1px 6px;
  font-family: var(--rb-font-mono);
  font-size: var(--rb-fs-xs);
  line-height: 18px;
  color: var(--rb-text-muted);
  background: var(--rb-surface-2);
  border: 1px solid var(--rb-border-strong);
  border-radius: var(--rb-radius-sm);
}

.busca-corpo { max-height: 55vh; padding: var(--rb-space-2); }

.busca-lista { margin: 0; padding: 0; list-style: none; }

.busca-grupo {
  padding: var(--rb-space-3) var(--rb-space-3) var(--rb-space-1);
  font-size: var(--rb-fs-xs);
  font-weight: var(--rb-fw-semibold);
  color: var(--rb-text-subtle);
}

.busca-item {
  display: flex;
  align-items: center;
  gap: var(--rb-space-3);
  padding: var(--rb-space-2) var(--rb-space-3);
  font-size: var(--rb-fs-base);
  color: var(--rb-text);
  border-radius: var(--rb-radius);
  cursor: pointer;
}
.busca-item > .bi:first-child,
.busca-item > .fa-solid:first-child { width: 18px; text-align: center; color: var(--rb-text-muted); }
.busca-item__texto { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.busca-item__texto strong { font-weight: var(--rb-fw-bold); }
.busca-item__extra { font-size: var(--rb-fs-xs); color: var(--rb-text-subtle); }

.busca-item[aria-selected="true"] {
  color: var(--rb-primary-subtle-text);
  background: var(--rb-primary-subtle);
}
.busca-item[aria-selected="true"] > .bi:first-child,
.busca-item[aria-selected="true"] > .fa-solid:first-child { color: inherit; }

.busca-vazio {
  margin: 0;
  padding: var(--rb-space-6) var(--rb-space-4);
  text-align: center;
  color: var(--rb-text-muted);
}

.busca-rodape {
  display: flex;
  gap: var(--rb-space-4);
  padding: var(--rb-space-2) var(--rb-space-4);
  font-size: var(--rb-fs-xs);
  color: var(--rb-text-muted);
  background: var(--rb-surface-2);
  border-top: 1px solid var(--rb-border);
}
.busca-rodape kbd { margin-right: 2px; }

@media (max-width: 575.98px) {
  #modalBuscaGlobal .busca-dialog { margin-top: var(--rb-space-3); }
  .busca-rodape { display: none; }
}

/* ─── Detalhes do reprodutor (duplo clique na lista) ─────────────────────── */

.rep-detalhe-secao {
  padding: var(--rb-space-3) 0;
  border-bottom: 1px solid var(--rb-border);
}
.rep-detalhe-secao:first-child { padding-top: 0; }
.rep-detalhe-secao:last-child { padding-bottom: 0; border-bottom: 0; }

.rep-detalhe-secao-titulo {
  margin: 0 0 var(--rb-space-3);
  font-size: var(--rb-fs-sm);
  font-weight: var(--rb-fw-semibold);
  color: var(--rb-text-muted);
}
.rep-detalhe-secao-titulo i { color: var(--rb-primary); }

.rep-detalhe-label {
  margin-bottom: 2px;
  font-size: var(--rb-fs-xs);
  color: var(--rb-text-muted);
}
.rep-detalhe-valor {
  font-size: var(--rb-fs-base);
  font-weight: var(--rb-fw-medium);
  color: var(--rb-text);
  overflow-wrap: anywhere;
}
.rep-detalhe-texto { font-weight: var(--rb-fw-regular); }

.rep-detalhe-tabela > thead > tr > th {
  font-size: var(--rb-fs-xs);
  font-weight: var(--rb-fw-semibold);
  color: var(--rb-text-muted);
  background: var(--rb-surface-2);
  white-space: nowrap;
}
.rep-detalhe-tabela > tbody > tr.rep-detalhe-grupo > th {
  font-size: var(--rb-fs-xs);
  font-weight: var(--rb-fw-semibold);
  color: var(--rb-primary-subtle-text);
  background: var(--rb-primary-subtle);
}
.rep-detalhe-tabela td.text-monospace { font-size: var(--rb-fs-sm); white-space: nowrap; }

/* ─── Visualizador de documentos (PDF e imagens) ─────────────────────────── */

.doc-viewer-body {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 75vh;
  padding: 0;
  background: var(--rb-surface-2);
}
.doc-viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--rb-surface);
}
.doc-viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.doc-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--rb-space-3);
  color: var(--rb-text-muted);
}
.doc-viewer-vazio {
  padding: var(--rb-space-6) var(--rb-space-4);
  text-align: center;
  color: var(--rb-text-muted);
}
.doc-viewer-vazio > i {
  display: block;
  margin-bottom: var(--rb-space-3);
  font-size: 40px;
  color: var(--rb-text-subtle);
}

@media (max-width: 575.98px) {
  .doc-viewer-body { height: 70vh; }
}

/* Genealogia no modal de detalhes: alternador Tabela / Árvore (a árvore é a do formulário) */
.rep-gen-barra {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--rb-space-3);
}
.rep-gen-barra .btn.active {
  color: var(--rb-primary-subtle-text);
  background: var(--rb-primary-subtle);
  border-color: var(--rb-primary-border);
}
.rep-gen[data-visao="tabela"] .rep-gen-arvore,
.rep-gen[data-visao="arvore"] .rep-gen-tabela { display: none; }

/* a árvore tem largura mínima de 1120px: o modal de detalhes precisa de espaço */
.rep-detalhe-dialog { --bs-modal-width: min(1280px, 96vw); }
