/*
 * Final form-action width overrides.
 *
 * Loaded after stability and position overrides to preserve the canonical
 * action hierarchy in row-equal footers. Nas telas de STEP/wizard o botão
 * PRIMÁRIO tem mais destaque (maior) e fica sempre à direita (último filho);
 * telas de login/externas seguem o padrão próprio (auth-*). #UX
 * - one action: 100%
 * - secondary + primary: 33% / 67% (primário maior, à direita)
 * - two secondary actions + primary: 25% / 25% / 50% (primário maior)
 */

@media (min-width: 640px) {
  .admin-notification-compose-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    width: max-content;
    margin-left: auto;
  }

  .admin-notification-compose-actions > .btn-canonical {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
  }

  .workspace-panel-footer.btn-row-equal:has(> :first-child:last-child),
  .portal-modal-footer.btn-row-equal:has(> :first-child:last-child) {
    /* display:grid é obrigatório para o grid-template valer — sem ele o rodapé
       fica em inline-flex + botões width:100% e os botões vazam da box. */
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-columns: unset;
  }

  .workspace-panel-footer.btn-row-equal:not(.form-actions-split-50):has(> .btn-canonical-secondary:first-child:nth-last-child(2)):has(> :last-child:is(.btn-canonical-primary, .btn-canonical-success, .btn-canonical-warning, .btn-canonical-danger)),
  .workspace-panel-footer.btn-row-equal:not(.form-actions-split-50):has(> .btn-canonical-ghost:first-child:nth-last-child(2)):has(> :last-child:is(.btn-canonical-primary, .btn-canonical-success, .btn-canonical-warning, .btn-canonical-danger)),
  .workspace-panel-footer.btn-row-equal:not(.form-actions-split-50):has(> form:first-child:nth-last-child(2)):has(> form:last-child),
  .portal-modal-footer.btn-row-equal:not(.form-actions-split-50):has(> .btn-canonical-secondary:first-child:nth-last-child(2)):has(> :last-child:is(.btn-canonical-primary, .btn-canonical-success, .btn-canonical-warning, .btn-canonical-danger)),
  .portal-modal-footer.btn-row-equal:not(.form-actions-split-50):has(> .btn-canonical-ghost:first-child:nth-last-child(2)):has(> :last-child:is(.btn-canonical-primary, .btn-canonical-success, .btn-canonical-warning, .btn-canonical-danger)),
  .portal-modal-footer.btn-row-equal:not(.form-actions-split-50):has(> form:first-child:nth-last-child(2)):has(> form:last-child) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) !important;
    grid-auto-columns: unset;
  }

  .workspace-panel-footer.btn-row-equal:not(.form-actions-split-50):has(> :nth-child(3)):not(:has(> :nth-child(4))),
  .portal-modal-footer.btn-row-equal:not(.form-actions-split-50):has(> :nth-child(3)):not(:has(> :nth-child(4))) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr) !important;
    grid-auto-columns: unset;
  }
}

@media (max-width: 639px) {
  .admin-notification-compose-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.75rem;
    width: 100%;
    margin-left: 0;
  }

  .admin-notification-compose-actions > .btn-canonical {
    width: 100%;
    min-width: 0;
  }
}
