/* ==================== 7. MODAIS E TOAST ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.ativo {
  display: flex;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);

  /* NOVAS REGRAS: Limita a altura e adiciona rolagem */
  max-height: 90vh;
  overflow-y: auto;
}

/* Barra de rolagem estilizada dentro do modal */
.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  /* Garante que os botões fiquem visíveis mesmo com rolagem */
  padding-top: 16px;
  border-top: 1px solid var(--border);
  /* Uma linha sutil para separar */
}

.modal-actions button {
  width: auto;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: transparent;
  color: var(--txt);
  padding: 0;
  border-radius: 0;
  font-weight: 600;
  opacity: 0;
  transform: translateY(14px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 9999;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: none;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.28));
}
.toast.on { opacity: 1; transform: none; }
.toast.tt-com { padding: 0; text-align: center; }
.toast .tt-ic { width: 40px; height: 40px; }
.toast .tt-ic svg { width: 100%; height: 100%; overflow: visible; }
.toast .tt-msg { font-size: 12px; line-height: 1.3; color: var(--txt); font-weight: 600; letter-spacing: .1px; opacity: .85; text-shadow: 0 0 6px var(--bg), 0 0 12px var(--bg); white-space: nowrap; }
.toast svg circle, .toast svg path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.toast .tt-bg { stroke: rgba(148, 163, 184, 0.35); stroke-width: 4; }
.toast .tt-arc { stroke: #ff6a1a; stroke-width: 5; stroke-dasharray: 38 100.2; transform-origin: 26px 26px; transition: stroke-dasharray 0.45s ease, stroke 0.3s; }
.toast.tt-load .tt-arc { animation: tt-gira 0.8s linear infinite; }
.toast .tt-v, .toast .tt-x, .toast .tt-a { stroke-width: 4.5; stroke-dasharray: 40; stroke-dashoffset: 40; }
.toast.tt-ok .tt-arc { stroke: #22c55e; stroke-dasharray: 138.2 0; }
.toast.tt-err .tt-arc { stroke: #ef4444; stroke-dasharray: 138.2 0; }
.toast.tt-warn .tt-arc { stroke: #f5b301; stroke-dasharray: 138.2 0; }
.toast.tt-ok .tt-v { stroke: #22c55e; animation: tt-traco 0.4s 0.25s ease forwards; }
.toast.tt-err .tt-x { stroke: #ef4444; animation: tt-traco 0.4s 0.25s ease forwards; }
.toast.tt-warn .tt-a { stroke: #f5b301; animation: tt-traco 0.4s 0.25s ease forwards; }
.toast.tt-ok .tt-ic { animation: tt-pulo 0.5s 0.2s ease; }
.toast.tt-err .tt-ic { animation: tt-treme 0.45s 0.25s ease; }
.toast.tt-warn .tt-ic { animation: tt-pulo 0.5s 0.2s ease; }
@keyframes tt-gira { to { transform: rotate(360deg); } }
@keyframes tt-traco { to { stroke-dashoffset: 0; } }
@keyframes tt-pulo { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
@keyframes tt-treme { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@media (max-width: 560px) { .toast { left: 50%; right: auto; bottom: 90px; transform: translate(-50%, 14px) scale(0.92); } .toast.on { transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .toast.tt-load .tt-arc { animation-duration: 2s; } }

/* ===== Padrão único dos modais (todas as telas) ===== */
.modal-overlay .modal-content, .modal-overlay .modal-box { position: relative; }
.modal-overlay .md-x { position: absolute; top: 14px; right: 14px; z-index: 3; width: 34px; height: 34px; padding: 0; margin: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1; cursor: pointer; background: rgba(148, 163, 184, 0.14); color: var(--muted); border: 0; box-shadow: none; }
.modal-overlay .md-x:hover { background: rgba(148, 163, 184, 0.26); color: var(--txt); }
.modal-overlay .modal-content > h2:first-of-type, .modal-overlay .modal-box > h2:first-of-type { padding-right: 44px; }
/* botão principal (Salvar/Confirmar) sempre laranja; o de excluir/sair continua vermelho */
.modal-overlay .modal-actions button:not(.ghost):not(.md-x):not([style*="red"]):not([style*="ef4444"]):not(.perigo):not(.danger),
.modal-overlay .ghost ~ button:not(.ghost):not(.md-x):not([style*="red"]):not([style*="ef4444"]):not(.perigo):not(.danger) {
  background: linear-gradient(135deg, #ff6a1a, #ffa04a) !important; color: #fff !important; border: 0 !important; box-shadow: 0 8px 20px rgba(255, 106, 26, 0.28);
}
