/* ==========================================================================
   Modal (<dialog>) — Área do Cliente Company Conferi
   Depende de css/login.css: usa os tokens de :root e as classes de formulário
   (.login-field, .login-label, .login-control, .login-input, .login-button,
   .login-alert). Carregue login.css antes deste arquivo.
   ========================================================================== */

/* 1. Caixa e fundo
   -------------------------------------------------------------------------- */
.modal {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  overflow: hidden;
  color: var(--texto);
  font-family: var(--fonte);
  line-height: 1.5;
  background: transparent;
  border: 0;
}

.modal::backdrop {
  background: rgba(9, 24, 38, .58);
  backdrop-filter: blur(3px);
}

/* Modais altos (ex.: cadastro) rolam por dentro, sem estourar a viewport */
.modal__box {
  position: relative;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 32px 30px 28px;
  background: var(--branco);
  border-radius: calc(var(--raio) + 2px);
  border-top: 4px solid var(--azul-claro);
  box-shadow: var(--sombra-card);
}

/* Impede a rolagem do fundo enquanto o modal está aberto */
html:has(dialog[open]) {
  overflow: hidden;
}

/* 2. Conteúdo
   -------------------------------------------------------------------------- */
.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--texto-suave);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: color var(--transicao), background var(--transicao);
}

.modal__close:hover {
  color: var(--azul);
  background: var(--cinza-transparente);
}

.modal__close svg {
  width: 20px;
  height: 20px;
}

.modal__title {
  padding-right: 40px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--texto-forte);
  letter-spacing: -.01em;
}

.modal__text {
  margin-top: 8px;
  font-size: .92rem;
  color: var(--texto-suave);
}

.modal__footer {
  margin-top: 22px;
  padding-top: 18px;
  font-size: .87rem;
  color: var(--texto-suave);
  border-top: 1px solid var(--cinza);
}

/* 3. Animação de abertura
   -------------------------------------------------------------------------- */
.modal[open] .modal__box {
  animation: modal-entrada 200ms ease;
}

.modal[open]::backdrop {
  animation: modal-fundo 200ms ease;
}

@keyframes modal-entrada {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.98);
  }
}

@keyframes modal-fundo {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal[open] .modal__box,
  .modal[open]::backdrop {
    animation-duration: 0.01ms;
  }
}

/* 4. Responsivo
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .modal__box {
    padding: 28px 20px 24px;
  }
}
